ImageClassifierCleaner

Was wondering if someone can help me to figure out how to get this class working on fastai2. Is not showing any of the images…

Or is there a way to it manualy? to delete the top lost images from the index of the dls?

Thanks!

1 Like

Hi, I tried the ImageClassifierCleaner now, but it showing up for me.
Can you check you used the learn before use the ImageClassifierCleaner on the learn?
I mean learn.fit() or fine_tune() or fit_one_cycle() and after use the cleaner.

Hi @AmorfEvo,

Thanks a lot for the response! I need to pass a learn to te ImageClassifierCleaner in order to instanciate it.

What version of fastai are you using ? and what imports?

1.- Yes I am using learn.

learn.fit_one_cycle(5, 3e-3)

Then I used,

learn.unfreeze()
learn.fit_one_cycle(7, 
                    lr_max=slice(1e-6, 1e-4), 
                    div_factor=100, 
                    pct_start=0.0, 
                    callbacks = [SaveModelCallback(name=f'model', 
                                                  monitor='kappa_score')])

Hmm, interesting so the top losses are shown properly, but the cleaner does not…

I checked for you, my installed fastai2 version is 0.0.17.

I used these fastai2 specific imports in my notebook:
from fastai2.vision.all import *
from fastprogress import fastprogress
from fastscript import *
from fastai2.basics import *
from fastai2.callback.all import *

Can you try import vision all not just the widgets? maybe something else is missing

Or try not import utils, I don’t know what it imports, but I didn’t used it, maybe there is something which override something about cleaner (I don’t know I just purely guessing, but worth a try)

Let me know if it solved, then later I don’t go into the same problem sometime ^^

dear @AmorfEvo,

thanks for the response, let me make some changes and let you know, give me like an hour when I get back.

Thanks!

Hi @AmorfEvo

When I took my imports and used yours this is what I get…

cleaner = ImageClassifierCleaner(learn)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-16-f9810ac9b6a1> in <module>
----> 1 cleaner = ImageClassifierCleaner(learn)

NameError: name 'ImageClassifierCleaner' is not defined

import fastai2
from fastai2.vision.all import *
from fastprogress import fastprogress
from fastscript import *
from fastai2.basics import *
from fastai2.callback.all import *
print(fastai2.version)
and I have fastai2 ver:0.0.18

Yes, but it’s not defined because you removed the widget import, I meant to copy those beside urs and lets see they add something to it or not :slight_smile:

Hi there @AmorfEvo,

this is what I have now and not getting anymore the ‘Not defined’ error

from fastai2 import *
from fastai2.vision.all import *
from fastai2.callback.fp16 import *
from fastai2.vision.widgets import *

But still same problem…

1 Like

I could reproduce your problem. I got the same empty cleaner ui when I run your notebook with your dataset.

When I changed the dls to imagenette2-160 which is a small dataset, only 100 MB and it’s without .cvs file, so its directory hierarchy gives where is train and valid data.
Then the cleaner showed up.

The ImageClassifierCleaner cannot remove rows from your csv files, only real files from real directories - which makes sense.

+Even if you make it work this way - you cannot really see with human eyes the different Gleason patterns to decide which image is in which category from the 6 categories - or if you can, then you are a prepared doctor for that. But the dataset is 28 GB and it has 10’616 images - so I think you cannot clean it with this simple cleaning idea - sorry to say that.
The good news is, you should not clean it at all this way, because even highly skilled doctors do NOT agree on the proper Gleason score of all images -> that is the reason why they put this challenge on kaggle to improve human decisions with DL.

@AmorfEvo,

Hey thanks a lot!!! for the effort, I guess it is a bug. To answer your questions

1.- you have a goo point where you cant eliminate images directly from the csv, but the idea was to see if it worked.
2.- but the way I am deleting images was going manually in the directory and deleting the image that did not come out correctly from the csv. The way its was done was copying code from lafoss where each image if about 64 mega bits, so we needed to reduce the image and create the block, all three first places in the competition did it this way.

3.- I did a decent score.

4.-

1 Like

Hmm, okey, that’s nice ^^ Congrat :slight_smile:

1 Like

I am trying to use the ImageClassifierCleaner to clean my data. However, when I select the items to keep and delete from one category and then change the category to select images for deleting/changing in another category, the widget is losing the data of the previous category which ones to delete/change, and I cannot delete all the required images of all categories at once. I’ve used Colab and Paperspace Gradient, and its the same result on both. Can someone help me with some workaround with this problem?

Thank you @orangelmx it’s worked

1 Like

Thank you @jeremy and fastai forum

I just came across this issue. Did you ever figure out a solution?

Yes, you have to unlink the selected images. Check out the fastai docs on how to do that. After selecting, just unlink the images, and they will be removed.