cwerner / fastclass

Little tools to download and then weed through images, delete and classify them into groups for building deep learning image datasets (based on crawler and tkinter)
Apache License 2.0
133 stars 25 forks source link

ValueError: images do not match (I think during cropping) #6

Closed joergsimon closed 4 years ago

joergsimon commented 5 years ago

I get an error using !fcd -c GOOGLE -s 224 query.csv with a simple query dictionary

searchterm,exclude keys, key glasses, glasses sunglasses, glasses shades, glasses remote controll, remote controll phone, phone smartphone, phone mobilephone, phone wallet, wallet cash cart, cash cart atm card, cash cart credit card, cash cart

when it searches for glasses Searching: >> glasses << I get: ..... trace till imageprocessing.py line 35 then File "/anaconda3/envs/fastai/lib/python3.7/site-packages/PIL/Image.py", line 1442, in paste self.im.paste(im, box) ValueError: images do not match

From what I found on stack overflow it seems to be that error: https://stackoverflow.com/questions/12291641/python-pil-valueerror-images-do-not-match

I guess ignoring such an image would be enough (just a try catch). It is 2am so I just quickly did put a try catch within the for loop of imageprocessing.py to resolve it for me and go do bed xD. Maybe there is a better solution to that?

Edit: Later while writing this post I also had a IsADirectoryError in the download so I brainlessly also did put a try catch around im = Image.open(f)....

Nice lib btw.!

cwerner commented 5 years ago

Hi

I think there is a misunderstanding of the usage and content of the csv file... The second column (exclude) contains words of your first column that should not be used for naming the classes.

To focus on guitars you specify that for each search, but exclude it for naming...

Example:

searchterm, exclude
guitar fender stratocaster, guitar
gibson les paul, 

If you do not want to exclude anything from the search term, simply end the line with an empty column: ", "

For your example I tested that (and it worked with the current code):

searchterm,exclude
keys, 
glasses, 
sunglasses, 
shades, 
remote controll, 
phone, 
smartphone, 
mobilephone, 
wallet, 
cash cart, 
atm card, 
credit card, 

Let me know if this works for you

joergsimon commented 5 years ago

Yes, that worked for me. That is the problem if you do things during night o_O It is not important, it works, but I wonder why this triggered that specific error? Anyway, thx for the help!

cwerner commented 5 years ago

Good.

I think there were empty string as a result. I'll mod the code to guard against this...