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

Assertion error at LoadBatches.py for training #35

Closed
matheuscass opened this issue Aug 7, 2018 · 13 comments
Closed

Assertion error at LoadBatches.py for training #35

matheuscass opened this issue Aug 7, 2018 · 13 comments

Comments

@matheuscass
Copy link

I'm having the following error: /LoadBatches.py", line 71, in imageSegmentationGenerator
assert( im.split('/')[-1].split(".")[0] == seg.split('/')[-1].split(".")[0] )
AssertionError

Any thoughts? =(

@giomhugo
Copy link

giomhugo commented Aug 8, 2018

Am I right when I say you are on windows?
If you are on windows, you can change the / with "\\" . (To actually see what is happening, try printing im and seg)

If you're not, then sorry but I don't have any ideas.

Have a good one :)

@matheuscass
Copy link
Author

Yes, I'm on windows. I did the following (after aplying the modification you suggested):
print(im)
print(seg)

and that was the response:

data/dataset1/images_prepped_test\0016E5_08159.png
data/dataset1/annotations_prepped_test\0016E5_08159.png
data/dataset1/images_prepped_train\0016E5_08640.png
data/dataset1/annotations_prepped_train\0016E5_08640.png

@giomhugo
Copy link

giomhugo commented Aug 8, 2018

So it worked?
you forgot :
Change the assert( im.split('/')[-1].split(".")[0] == seg.split('/')[-1].split(".")[0] )
to assert( im.split('\\')[-1].split(".")[0] == seg.split('\\')[-1].split(".")[0] )

@matheuscass
Copy link
Author

Now I'm having this error:
Traceback (most recent call last):
File "train.py", line 90, in
m.fit_generator( G , 512 , validation_data=G2 , validation_steps=200 , epochs=1 )
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py", line 1415, in fit_generator
initial_epoch=initial_epoch)
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training_generator.py", line 177, in fit_generator
generator_output = next(output_generator)
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\data_utils.py", line 793, in get
six.reraise(value.class, value, value.traceback)
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Users\Matheus\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\data_utils.py", line 658, in _data_generator_task
generator_output = next(self._generator)
File "C:\Users\Matheus\Desktop\UFRGS\Mestrado\tutorial_python\APLICACAO_A_AGRICULTURA\image-segmentation-keras-master\LoadBatches.py", line 82, in imageSegmentationGenerator
im , seg = zipped.next()
AttributeError: 'itertools.cycle' object has no attribute 'next'

=(

@matheuscass
Copy link
Author

I made the modification you mentioned, I think that assertion error is ok now, but I'm having this new error I've just mentioned above =(

@giomhugo
Copy link

giomhugo commented Aug 8, 2018

Ok that error is because you are on python 3.X
modification :
itertools.cycle().next() to next(itertools.cycle())

So in your case :
zipped.next() to next(zipped)

@matheuscass
Copy link
Author

It worked! thanks a lot for your time!!! I'm rookie on python, so it's kind of hard to solve these errors on my own... I want to use the code to apply to my own dataset, so it's likely I'll need help again...

Thanks again!

@giomhugo
Copy link

giomhugo commented Aug 8, 2018

You're very welcome !
If you ever have a problem or an error just type it in google and you will surely find solutions :p

@matheuscass
Copy link
Author

matheuscass commented Aug 8, 2018

Could you answer one more question? The instructions by the author tell us to use --input_height = 320 and --input_width = 640, but these are not the exact dimensions of the images from the dataset. How those values influence on the code?

@giomhugo
Copy link

giomhugo commented Aug 8, 2018

For me, they cause an error for me ! I removed these arguments
Sorry can't help you on that :(

@divamgupta
Copy link
Owner

@matheuscass there are multiple reasons that we do not use the original size of the images. If the images are very large, the the size of the CNN would also increase which means slower training time and more memory. In most cases, larger the image, you would have to use more number of layers.

@giomhugo
Copy link

giomhugo commented Aug 9, 2018

@divamgupta
Let’s say my dataset are images of same dimensions (weird ratio 624*464) but the images I want to predict come from a phone (so dimensions like 1080p). What should I modify in order to get good dimensions on the prediction ?

@divamgupta
Copy link
Owner

You can first resize the image before inputting to the model and resize the output to the original dimensions

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