Import Labels from CSV can find my Images


I have the Stanford Cars Dataset. My labels are in a csv file

train/000001.jpg,AM General Hummer SUV 2000
train/000002.jpg,AM General Hummer SUV 2000
train/000003.jpg,AM General Hummer SUV 2000
train/000004.jpg,AM General Hummer SUV 2000

when I run this

tfms = get_transforms(do_flip=False)
data = ImageDataBunch.from_csv(path, ds_tfms=tfms, size=28)
data.show_batch(rows=3, figsize=(5,5))

I got an file not found error
FileNotFoundError: Traceback (most recent call last):
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/torch/utils/data/”, line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/torch/utils/data/”, line 138, in
samples = collate_fn([dataset[i] for i in batch_indices])
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/fastai/”, line 483, in getitem
if self.item is None: x,y = self.x[idxs],self.y[idxs]
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/fastai/”, line 92, in getitem
if isinstance(try_int(idxs), int): return self.get(idxs)
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/fastai/vision/”, line 266, in get
res =
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/fastai/vision/”, line 262, in open
return open_image(fn, convert_mode=self.convert_mode)
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/fastai/vision/”, line 376, in open_image
x =
File “/home/nbuser/.anaconda3/lib/python3.7/site-packages/PIL/”, line 2580, in open
fp =, “rb”)
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/nbuser/courses/fast-ai/course-v3/nbs/data/Cars/./valid/002774.jpg’

Here is as ‘/.’ too much between Cars/ and /valid

Where does it come from? I have no idea? Cant find something in the doc of

Please give me a thought-provoked



You need to specify folder and csv file

Path = path to the root folder
It should has arch like

You can use whatever names you like.

.from_csv(path, folder=‘train’,label_csv=‘your.csv’…)

You can take a close look of the Image databunch API, I didn’t use much of the factory method, data block API gives you more control of the steps :slight_smile: Apology if I didn’t get the name right…

Did it.

same result bei ImageImageList.from_csv