Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depth load in dataloader file #7

Open
FengLoveBella opened this issue Dec 21, 2019 · 2 comments
Open

depth load in dataloader file #7

FengLoveBella opened this issue Dec 21, 2019 · 2 comments

Comments

@FengLoveBella
Copy link

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

@jiwei0921
Copy link
Owner

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.

@Jrokisky
Copy link

Jrokisky commented Feb 3, 2020

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants