I am attempting the iWildCam 2019 Animal Classification Challenge on Kaggle using what I’ve learned in Lesson 1.
The data is provided as both a set of images and a train.csv
file. The train.csv
file contains both the names of images and their corresponding classifications. I created an ImageList
from the CSV file using ImageList.from_df
.
imgList = ImageList.from_df(df = data, path = train_path, cols = ‘file_name’)
imgList.items[:10]
array([‘/kaggle/input/iwildcam-2019-fgvc6/train_images/5998cfa4-23d2-11e8-a6a3-ec086b02610b.jpg’,
‘/kaggle/input/iwildcam-2019-fgvc6/train_images/588a679f-23d2-11e8-a6a3-ec086b02610b.jpg’,
‘/kaggle/input/iwildcam-2019-fgvc6/train_images/59279ce3-23d2-11e8-a6a3-ec086b02610b.jpg’,…], dtype=‘<U88’)
But when I try to run the following:
dataBunch = ImageDataBunch.from_lists(path = train_path, fnames = imgList, labels = classification, size = 224)
(train_path = "/kaggle/input/iwildcam-2019-fgvc6/train_images"
,
classification
= The labels associated with each image extracted from the CSV file.)
I get the following error:
TypeError Traceback (most recent call last)
in
1 # labels_ls = list(map(classification, imgList.items))
----> 2 dataBunch = ImageDataBunch.from_lists(path = train_path, fnames = imgList, labels = classification, size = 224)
/opt/conda/lib/python3.6/site-packages/fastai/vision/data.py in from_lists(cls, path, fnames, labels, valid_pct, seed, item_cls, **kwargs)
135 “Create from list offnames
inpath
.”
136 item_cls = ifnone(item_cls, ImageList)
→ 137 fname2label = {f:l for (f,l) in zip(fnames, labels)}
138 src = (item_cls(fnames, path=path).split_by_rand_pct(valid_pct, seed)
139 .label_from_func(lambda x:fname2label))
/opt/conda/lib/python3.6/site-packages/fastai/vision/data.py in (.0)
135 “Create from list offnames
inpath
.”
136 item_cls = ifnone(item_cls, ImageList)
→ 137 fname2label = {f:l for (f,l) in zip(fnames, labels)}
138 src = (item_cls(fnames, path=path).split_by_rand_pct(valid_pct, seed)
139 .label_from_func(lambda x:fname2label))
TypeError: unhashable type: ‘Image’
I’m not sure what’s causing this error. If somebody could point me in the right direction I’d be grateful. Thank you.