muellerzr / ClassConfusion

A useful tool for visualizing and analyzing where our models weaknesses are
13 stars 3 forks source link

ClassConfusion throwing an AttributeError #2

Closed oo92 closed 3 years ago

oo92 commented 4 years ago

Hi.

I’m currently going through Lesson 2 using the ClassConfusion class in Google Colab in the following way:

ClassConfusion(interp, classes, is_ordered=False, figsize=(8,8))

When I ran the cell, I was asked to enter a value for ‘k’, or the top images you will see. I didn’t know what this was about so I entered 5. I was met with the following error message:

0%|          | 0/3 [00:00<?, ?it/s]  0%|          | 0/3 [00:00<?, ?it/s]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-6a81612b4be5> in <module>()
----> 1 ClassConfusion(interp, classes, is_ordered=False, figsize=(8,8))

4 frames
/content/ClassConfusion/classConfusion.py in _plot_imgs(self, tab, i, **kwargs)
     92                 img, lbl = self.interp.data.valid_ds[idx]
     93                 fn = self.interp.data.valid_ds.x.items[idx]
---> 94                 fn = re.search('([^/*]+)_\d+.*$', str(fn)).group(0)
     95                 img.show(ax=ax[row, col])
     96                 ax[row,col].set_title(fn)

AttributeError: 'NoneType' object has no attribute 'group'

I know that we can’t really use widgets in Colab but I was under the impression that ClassConfusion would remedy that problem. Its my 1st time ever using it and I am a newbie so this is most likely on me.

Thank you.

muellerzr commented 4 years ago

How are your images saved away on file?

muellerzr commented 4 years ago

Can you give me an example filename from your dataset? (quickest way is to tell me the result of data.valid_ds.x.items[0])

oo92 commented 4 years ago

Can you give me an example filename from your dataset? (quickest way is to tell me the result of data.valid_ds.x.items[0])

PosixPath('data/bears/teddys/00000120.jpg')

mrcchef commented 4 years ago

same problem with me.

muellerzr commented 4 years ago

Can you try using the new version in fastai2? I have not updated this version for quite some time and don't plan on updating it due to the new library version. See here:

https://github.com/muellerzr/ClassConfusion2

thhung commented 4 years ago

I fixed this problem by set classList to a pair of classes but the problem now is no image showed.

m-ali-awan commented 3 years ago

Can you try using the new version in fastai2? I have not updated this version for quite some time and don't plan on updating it due to the new library version. See here:

https://github.com/muellerzr/ClassConfusion2

Hi Muellezr, this link is broken?

muellerzr commented 3 years ago

ClassConfusion is a part of my fastinference library:

htttps://github.com/muellerzr/fastinference

m-ali-awan commented 3 years ago

Thanks Muellerzr for such quick help. And I am getting this error: AttributeError: 'ClassificationInterpretation' object has no attribute 'data'

And this error usually shows up, sometimes we donot have .classes attribute, so why is it so?

And, now in fastai latest version, with plot_top_losses we cannot get heatmaps.Is there any way to have them?

Thanks..

muellerzr commented 3 years ago

Which version of fastai are you using @m-ali-awan? (for your question relating to this library)

m-ali-awan commented 3 years ago

I am using colab, and installing it via --upgrade flag..

m-ali-awan commented 3 years ago

It is 2.3.0

muellerzr commented 3 years ago

This is designed for fastai v1, not v2. You need to use fastinference for the v2 version (as I noted above)

m-ali-awan commented 3 years ago

Sorry, but where to find that?

m-ali-awan commented 3 years ago

ClassConfusion is a part of my fastinference library:

htttps://github.com/muellerzr/fastinference

Isn't this for v2?

muellerzr commented 3 years ago

muellerzr.github.io/fastinference (also the first thing that pops up when you google "fastinference")

And yes, fastai 2.0.0 + is fastai v2

m-ali-awan commented 3 years ago

Now, it is throwing this error:

For: ClassConfusion(interp, classlist, is_ordered=False, figsize=(8,8))

AttributeError: 'ClassificationInterpretation' object has no attribute 'data'

muellerzr commented 3 years ago

Please include stack traces for everything you are doing. If you are trying to use this library with fastai version 2, I repeat it will not work for this. Open an issue on the fastinference repository if you have any errors with it, and include a full stack trace, exactly how you installed the library, exactly how you used the library, how you built your Learner, and so forth. The repo is https://github.com/muellerzr/fastinference

m-ali-awan commented 3 years ago

Ok, thanks alot.. And sorry to disturb you...

m-ali-awan commented 3 years ago

Hi Mueller, I also checked you repo of WalkWithFastai.. But I cannnot find any helping code that can guide me to use Class Confusion for vision..?