joedockrill / jmd_imagescraper

Image scraping library for creating deep learning datasets
https://joedockrill.github.io/jmd_imagescraper/
Apache License 2.0
33 stars 15 forks source link

Add random filenames feature #1

Closed butchland closed 4 years ago

butchland commented 4 years ago

Hi Joe,

This is just a feature enhancement that allows the filenames to have a random string tacked on at the end, allowing the filenames to be unique, even across directories.

This is to fix a problem with running the fastai.vision.widgets.ImageClassifierCleaner which moves the images across the folders if you change their categories.

This in turn, triggers an error because the filenames are unique within a folder, but not across the different category folders (e.g. reclassifying 003.jpg in teddys folder to a grizzly could trigger an error because there might already be a file named 003.jpg in the grizzly folder)

Adding a random string at the end of the name eg. 001_cc13976d.jpg instead 001.jpg makes sure this doesn't happen since each file will be unique even if both files start with 001.

This additional functionality is turned off by default, so everything works the same unless you explicitly pass the random_names parameter to True.

Hope you find this a useful feature to merge.

Best regards, Butch

joedockrill commented 4 years ago

Like it! Thanks @butchland.

joedockrill commented 4 years ago

@butchland FYI:

thanks dude!