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

broken images stop the whole program #22

Closed tfriedel closed 4 years ago

tfriedel commented 5 years ago

I saw this error:

  File "/miniconda/bin/fcd", line 10, in <module>
    sys.exit(cli())                             
  File "/miniconda/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)                                                                                                                                                                                
  File "/miniconda/lib/python3.6/site-packages/click/core.py", line 717, in main                                                                                                                                    
    rv = self.invoke(ctx)
  File "/miniconda/lib/python3.6/site-packages/click/core.py", line 956, in invoke                                                                                                                                   
    return ctx.invoke(self.callback, **ctx.params)
  File "/miniconda/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/miniconda/lib/python3.6/site-packages/fastclass/fc_download.py", line 163, in cli
    main(infile, size, crawler, keep, maxnum, outpath)
  File "/miniconda/lib/python3.6/site-packages/fastclass/fc_download.py", line 126, in main
    source_urls = resize(files, outpath=out_resized, size=SIZE, urls=source_urls)                                                                                                                                    
  File "/miniconda/lib/python3.6/site-packages/fastclass/imageprocessing.py", line 45, in resize
    bg = bg.convert('RGB')
  File "/miniconda/lib/python3.6/site-packages/PIL/Image.py", line 912, in convert
    self.load()
  File "/miniconda/lib/python3.6/site-packages/PIL/ImageFile.py", line 239, in load
    len(b))        
OSError: image file is truncated (24 bytes not processed) 

and the whole program stopped of course. I suggest catching this exception and skipping the file.

cwerner commented 4 years ago

Hi. And thanks for reporting this.

Sorry for the long response time. I'll look into this...