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

IndexError: list index out of range #20

Open
bsahil29 opened this issue Jun 4, 2019 · 5 comments
Open

IndexError: list index out of range #20

bsahil29 opened this issue Jun 4, 2019 · 5 comments

Comments

@bsahil29
Copy link

bsahil29 commented Jun 4, 2019

I am trying to train the InstaGAN on a smaller dataset of around 40 images from both domains. But I am getting the following error :
File "/network/home/bansalsa/instagan/data/unaligned_seg_dataset.py", line 49, in read_segs
segs.append(-torch.ones(segs[0].size()))
IndexError: list index out of range

I have read the already available issues and double-checked that there is a mask for every image in the trainA and trainB folders but still I'm getting the same error. Also, the images are readable via PIL, I have checked that too.

This is the screenshot to the output that I'm getting :

Screenshot 2019-06-04 at 16 43 32

What could be a reason for getting this error?

@sangwoomo
Copy link
Owner

Hi, it seems that the code fails to read the mask. You'd better to check for which image/mask the code fails to read exactly, e.g., by printing the ID of the image before the failure.
#5 (comment)

@bsahil29
Copy link
Author

bsahil29 commented Jun 7, 2019

Yeah it worked. There was an issue with reading some of the masks. Thanks! :)

@bsahil29 bsahil29 closed this as completed Jun 7, 2019
@kalai2033
Copy link

Hi @sangwoomo and @bsahil29 I face the same issue...

I have printed the seg_paths ... Every time it breaks at random point. But i have corresponding mask images in both the train and train_seg folder with same name and same dimensions. I cant understand why it fails.

Can you please help me fix it?

@sangwoomo
Copy link
Owner

I'm sorry but I have no idea since I had never encountered this problem.
Can you simply remove the problematic index?

@jdunkelheit
Copy link

In addition to missing masks, this issue can also happen when the masks have a wrong name. The mask cannot simply have the exact same name as the image.
Make sure the name of the masks is composed of "image name" + "_0". For example:

    ├── trainA
        ├── 1.png
        ├── 2.png
        └── ...
    ├── trainA_seg
        ├── 1_0.png
        ├── 2_0.png
        └── ...
    ├── trainB
        ├── 1.png
        ├── 2.png
        └── ...
    ├── trainB_seg
        ├── 1_0.png
        ├── 2_0.png
        └── ...

In case you have more than one mask for the same image, it will be like:

    ├── trainA
        ├── 1.png
        ├── 2.png
        └── ...
    ├── trainA_seg
        ├── 1_0.png
        ├── 1_1.png
        ├── 2_0.png
        ├── 2_1.png
        └── ...
    ├── trainB
        ├── 1.png
        ├── 2.png
        └── ...
    ├── trainB_seg
        ├── 1_0.png
        ├── 1_1.png
        ├── 2_0.png
        ├── 2_1.png
        └── ...

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

4 participants