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

TypeError: 'NoneType' object is not subscriptable #13

Closed
manvirvirk opened this issue Apr 7, 2020 · 30 comments
Closed

TypeError: 'NoneType' object is not subscriptable #13

manvirvirk opened this issue Apr 7, 2020 · 30 comments

Comments

@manvirvirk
Copy link

File "D:\pytorch-nested-unet-master\dataset.py", line 63, in getitem
img_id + self.mask_ext), cv2.IMREAD_GRAYSCALE)[..., None])
TypeError: 'NoneType' object is not subscriptable

i m getting this error while training model, Can anyone help??

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

@manvirvirk
Does the file look like the following?

inputs
├── data-science-bowl-2018
|   ├── stage1_train
|   |   ├── 00ae65...
|   │   │   ├── images
|   │   │   │   └── 00ae65...
|   │   │   └── masks
|   │   │       └── 00ae65...            
|   │   ├── ...
|   |
|   ...
└── dsb2018_96
    ├── images
    └── masks
             └── 0
                     ├── 00ae65...
                     ...

@balag59
Copy link

balag59 commented Apr 7, 2020

Thank you for the implementation! I have the same issue with the latest commit. I'm training on an original dataset and this is how it looks:

Original_Dataset
images
1.jpg
masks
0
1.png

I'm am able to print all the img_ids successfully after reading them so the dataset is being read correctly I guess.

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

@balag59
Thanks for letting me know.
How do you set img_ext and mask_ext?

@manvirvirk
Copy link
Author

i want to train on my own database. I have 20 colored images and respective masks. HOow to make directory of database. Thanks

@balag59
Copy link

balag59 commented Apr 7, 2020

@balag59
Thanks for letting me know.
How do you set img_ext and mask_ext?

I was able to rectify this error as I forgot to set the right mask dir in train.py. That error has been resolved now. Thank you for your time!

@manvirvirk
Copy link
Author

did you train this model on your own database?? @balag59

@balag59
Copy link

balag59 commented Apr 7, 2020

did you train this model on your own database?? @balag59

Yes with just 1 class.

@manvirvirk
Copy link
Author

Thanks for reply. I want to train it with my own database which contains 20 training images and respective masks. So what all changes we have to make. Please help as i m getting lot of errors. @balag59

@manvirvirk
Copy link
Author

this is my directory:
input-dataset_name-image(it contains 20 images in png format)
masks(it contains 20 images in png format)
now what changes we need to make??? @balag59 @4uiiurz1

@balag59
Copy link

balag59 commented Apr 7, 2020

this is my directory:
input-dataset_name-image(it contains 20 images in png format)
masks(it contains 20 images in png format)
now what changes we need to make??? @balag59 @4uiiurz1

I didn't run into any issues as soon as I fixed my mask directory path. Make sure that you are setting the right path for the image and mask directories. According to what you've mentioned above, you aren't placing the masks class wise right? All your masks are directly under the masks directory? If so, then you will need to place it class wise as mentioned in the README starting with class 0.

@manvirvirk
Copy link
Author

thanks . now i enetered in this error:
File "C:\Users\virkt\Anaconda3\envs\unet\lib\site-packages\sklearn\model_selection_split.py", line 1805, in _validate_shuffle_split
train_size)
ValueError: With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.

@balag59
Copy link

balag59 commented Apr 7, 2020

thanks . now i enetered in this error:
File "C:\Users\virkt\Anaconda3\envs\unet\lib\site-packages\sklearn\model_selection_split.py", line 1805, in _validate_shuffle_split
train_size)
ValueError: With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.

This error means that your image_ids directory is still not set correctly and that's why the n_samples is equal to 0. You will need to cross-check your image_ids path again and see if it's accurate.

@manvirvirk
Copy link
Author

can you specify where in code i need to cross verify image_ids path??

@manvirvirk
Copy link
Author

I m beginner so i m getting bit confused. Please specify where how to set image_ids path? Thanks for helping long way. @balag59

@manvirvirk
Copy link
Author

this is how my directory looks like
input
dataset name
-images : contains 20 rgb images png format
-mask
-0 : contains 20 masks png format

@balag59
Copy link

balag59 commented Apr 7, 2020

can you specify where in code i need to cross verify image_ids path??

Check line 247

@manvirvirk
Copy link
Author

in train.py file???

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

@manvirvirk Please try to change directory name input to inputs

@manvirvirk
Copy link
Author

img_ids = glob(os.path.join('inputs', config['dataset'], 'images', '*' + config['img_ext']))
img_ids = [os.path.splitext(os.path.basename(p))[0] for p in img_ids]
i think these lines? what changes need to be made here? thanks @balag59

@manvirvirk
Copy link
Author

oh got it

@manvirvirk
Copy link
Author

its already inputs

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

ok...

@manvirvirk
Copy link
Author

so what changes need to be made in image_ids path?

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

Please try the following code:

img_ids = glob(os.path.join('inputs', config['dataset'], 'images', '*' + config['img_ext']))
img_ids = [os.path.splitext(os.path.basename(p))[0] for p in img_ids]
print(img_ids)

@manvirvirk
Copy link
Author

Capture

started training , thanks for helping long way :)

@manvirvirk
Copy link
Author

i think print(img_ids) command worked:)

@manvirvirk
Copy link
Author

did you do testing also???

@manvirvirk
Copy link
Author

did you validate the model? @balag59

@manvirvirk
Copy link
Author

how we get segmented image???

@4uiiurz1
Copy link
Owner

4uiiurz1 commented Apr 7, 2020

Please read README.

@4uiiurz1 4uiiurz1 closed this as completed Apr 7, 2020
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