Hi everyone!
I am getting this error “AttributeError: ‘ImageList’ object has no attribute ‘cat_names’” when I execute interp.plot_top_losses(k = 5) on a ClassificationInterpretation object created from cnn learner. The learner was trained on an ImageDataBunch, which was created by first calling ImageList.from_df() and after splitting, labeling, converted to a databunch (and finally normalized).
Interestingly, the file where the error originates in is shown to be: <path_preix>/python3.7/site-packages/fastai/tabular/models.py; I am wondering why a function call on an ImageDataBunch would go to the tabular module. Does it look alright? Can someone help me understand how to fix the problem?
Here’s the code creating the databunch and the learner:
data = (ImageList.from_df(data_df, im_path, cols=‘path’)
.split_by_idxs(train_idxs, val_idxs)
.label_from_df(cols=‘class_label’)
.transform(get_transforms())
.databunch(bs=32)
).normalize(imagenet_stats)learn = cnn_learner(data, models.resnet34, metrics=[error_rate, accuracy], callback_fns = learner_callbacks);
Here’s the complete error message:
AttributeError Traceback (most recent call last)
in
----> 1 interp.plot_top_losses(k=10)~/anaconda3/envs/project_WACV/lib/python3.7/site-packages/fastai/tabular/models.py in _cl_int_plot_top_losses(self, k, largest, return_table)
53 tl_val, tl_idx = self.top_losses(k, largest)
54 classes = self.data.classes
—> 55 cat_names = self.data.x.cat_names
56 cont_names = self.data.x.cont_names
57 df = pd.DataFrame(columns=[[‘Prediction’, ‘Actual’, ‘Loss’, ‘Probability’] + cat_names + cont_names])AttributeError: ‘ImageList’ object has no attribute ‘cat_names’
Here’s my install config:
=== Software ===
python : 3.7.3
fastai : 1.0.55
fastprogress : 0.1.21
torch : 1.1.0
nvidia driver : 410.104
torch cuda : 10.0.130 / is available
torch cudnn : 7501 / is enabled
=== Hardware ===
nvidia gpus : 1
torch devices : 1
- gpu0 : 12192MB | TITAN X (Pascal)
=== Environment ===
platform : Linux-4.15.0-54-generic-x86_64-with-debian-buster-sid
distro : #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019
Cheers.
Tarik