ImageClassifierCleaner doesn't save my choices

Hello, I am at the lesson 2 (deployment) and I try to build my own model based on the example with bears. Everything works great till when I get to the point where I have to use ImageClassiierCleaner. I inspect images and mark them as other category (e.g. ‘delete’) and I switch between train and valid datasets (as Jeremy did) or labels, the classifier does not save my choices. Does anyone have the same issue? How can I solve it?
Thank you in advance!

ImageClassifierCleaner doesn’t delete or relabel. It returns indices that are to be deleted or relabeled.

You’ll need to run the following code snippet to actually delete or relabel.

# Delete images selected for deletion.
for index in cleaner.delete():

# Relabel images selected for relabeling.
for index, category in cleaner.change():
    shutil.move(str(cleaner.fns[index]), path/category)
1 Like

Dear Salman,
Thank you so much for your time and your answer! However it does not solve my problem completely, perhaps I didn’t explain clearly. I am trying to classify hot peppers in terms of spiciness. I have habanero, jalapeno, poblano and bell pepper. I do the following steps:

  1. I run the cleaner
  2. I clean training dataset for e.g poblano
  3. I switch to validation set for poblano and clean it
  4. I switch to e.g habanero and repeat cleaning as for poblano
  5. I continue doing stpes 2 and 3 for all categories of peppers
  6. I run the code you wrote.

It seams like the cleaner do not “remember” the indices while I switch between datasets (train vs valid) and categories (kinds of peppers). Therefore, when I run the code you provided, it does not delete or relabel images. From what I saw on the video, Jeremy first cleans datasets ( training set and validation set and he switches between them) and then he runs the code. for deletion or relabeling.

I wonder why it doesn’t work for me and what I do wrong…?

Ah, I remember I encountered something similar. You’ll have to run the snippet above before switching datasets and labels.

For example, clean the training dataset for poblano and then immediately run the snippet. Then switch to the validation for poblano and then run the snippet right after again.


Thank you! It worked. Good to know I wasn’t the only one having this issue:) Have a good day!

1 Like