DMRA
DMRA copied to clipboard
depth load in dataloader file
In your code you use "depth = np.array(depth, dtype=np.uint8)" to load your depth image, I was wondering maybe this is not okay. Because of the depth value is much bigger than 255. If you use 'np.uint8', the depth value is not correct when loaded. Thank you very much. @jiwei0921
Thank you for your interests very much. I really missed your point. Before, what I did was I normalized all the input images. There is no problem with that, so ignore your problem. You can directly use this link(https://github.com/jiwei0921/RGBD-SOD-datasets) to download and test images, which is available. I will pay attention to the problems you mentioned and update them in time. Thanks again.
Hi @jiwei0921 I think I ran into a similar issue as @zhoufengbuaa .
Versions: Pytorch==1.1 Pillow==5.4.0
When trying to load the files: 1342_ro90 & 1323_flr in the data_loaders __getitem__
method I get the error:
int() argument must be a string, a bytes-like object or a number, not 'PngImageFile'
When depth = np.array(depth, dtype=np.uint8)
is called.
I'm going to test removing those files from the provided training dataset and see if that fixes the issue. Will report back if that fixes the issue.
Here's the code I used to find the files w/ issues:
import PIL.Image
import numpy as np
import os
base = REPLACE_WITH_DIRECTORY_ROOT
img_root = os.path.join(base, 'train_images')
lbl_root = os.path.join(base, 'train_masks')
depth_root = os.path.join(base, 'train_depth')
file_names = os.listdir(img_root)
for i, name in enumerate(file_names):
if not name.endswith('.jpg'):
continue
lbl = os.path.join(lbl_root, name[:-4]+'.png')
img = os.path.join(img_root, name)
dep = os.path.join(depth_root, name[:-4]+'.png')
try:
imgL = PIL.Image.open(lbl)
np.array(imgL, dtype=np.int32)
imgI = PIL.Image.open(img)
np.array(imgI, dtype=np.uint8)
imgD = PIL.Image.open(dep)
np.array(imgD, dtype=np.uint8)
except Exception as e:
print(e)
print(name +" => " + str(i) + "\n")