olgaliak / active-learning-detect

Active learning + object detection
MIT License
100 stars 33 forks source link

File_type is case sensitive, creates problems during prediction generation #50

Open andrebriggs opened 5 years ago

andrebriggs commented 5 years ago

If you have a file_type defined in the config.ini such ".jpg" and have images that are .JPG then during prediction creation you will have zero files and the TF Detector code will fail the script. Root cause seems to be the way code is handled here for instance. Why wait all the way up until Create Predictions for this to surface? Do we need to be case sensitive here?

Just logging this as a bug. I will probably fix

yashpande commented 5 years ago

This issue also occurs with .jpeg extensions not being recognized as .jpg, which is probably also not ideal. The more robust way would be to use something like imghdr to get the actual type of all files, and take only the ones that are of the desired type (which would then be narrowed down to either 'jpeg' or 'png'). Even replacing the linked code with something like this would probably work:

# all_image_files = list(basedir.rglob(filetype))
# replace this with:
import imghdr
all_image_files = [image_file for image_file in subdir.iterdir() 
                             if image_file.is_file() and imghdr.what(image_file)=='jpeg']