Skip to content

Instantly share code, notes, and snippets.

@tom-doerr
Created August 6, 2021 01:18
Show Gist options
  • Save tom-doerr/138de0d49224d765cc81c7cb492150dd to your computer and use it in GitHub Desktop.
Save tom-doerr/138de0d49224d765cc81c7cb492150dd to your computer and use it in GitHub Desktop.
# How do I start the fastai class label cleaner?
You can start it by executing
```
import ipywidgets
from fastai.vision.widgets import ImageClassifierCleaner
cleaner = ImageClassifierCleaner(learn)
cleaner
```
# How do I save the results of the cleaning process?
Assuming your dataset is structured with samples in folders
with the corrosponding class labels you can directly update your
dataset by running
```
for idx in cleaner.delete():
cleaner.fns[idx].unlink()
```
to delete the items marked for deletion and running
```
for idx, cat in cleaner.change():
print(cat)
print(cleaner.fns[idx])
shutil.move(str(cleaner.fns[idx]), 'data/train/' + cat)
```
to move the files into the directory which matches their new label.
You will likely need to adjust the destination path in the `shutil.move`
command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment