Lesson2-download notebook

In this notebook, the command to download images is:

download_images(path/file, dest, max_pics=200)

It should be:

download_images(dest/file, dest, max_pics=200)

The first command will give you a file not found error.


IMO - you should probably put this in https://forums.fast.ai/t/lesson-2-further-discussion/28706 or https://forums.fast.ai/t/lesson-2-in-class-discussion/28632/339 rather than creating a new thread.

1 Like

@Mauro I don’t know why , but even dest/file shows the same error. Can you help me out?

Can you post your code?

Oh sorry . It was a mistake that I understood. My destination was different . So the file name was also different. That’s why it’s said no directory found. Sorry for disturbing you…

It was caused by what Jeremy had mentioned about not reproducible research…


I have been working on the notebook to classify some images from different sports. However, when I run this cell block:

pred_class,pred_idx,outputs = learn.predict(img)

I get an output like:

<fastai.core.Category at 0x7f1d75f28470>

However, when I execute:


I get,


, which is the correct index of the array of classes. But, for obvious reasons, I want the name of the class and not just the index. What is going wrong here?

The category name can now be accessed by using the .obj attribute. So in this case, pred_class.obj should work. Check documentation as previous methods/functions can be deprecated or changed in newer versions if similar problems arise.

Yup, perfect. Thanks a lot!

Did that and I’m still getting a FileNotFoundError.

In the Data file I have a folder labeled “balls” and two files

folder = 'balls'
file = 'volleyball.csv'
file = 'soccerball.csv'

path = Path('data')
dest = path/folder
dest.mkdir(parents=True, exist_ok=True)

When I run path.ls() I get PosixPath('data/balls'), PosixPath('data/bears') as the output which is odd considering I don’t have a folder labeled bears in my folder so I’m not sure where that’s coming from.

classes = ['soccerball','volleyball']
download_images(dest/file, dest, max_pics=200)

This is the error message I’m getting:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-12-7b9f18bbeaca> in <module>
----> 1 download_images(dest/file, dest, max_pics=200)

/opt/anaconda3/lib/python3.7/site-packages/fastai/vision/data.py in download_images(urls, dest, max_pics, max_workers, timeout)
    191 def download_images(urls:Collection[str], dest:PathOrStr, max_pics:int=1000, max_workers:int=8, timeout=4):
    192     "Download images listed in text file `urls` to path `dest`, at most `max_pics`"
--> 193     urls = open(urls).read().strip().split("\n")[:max_pics]
    194     dest = Path(dest)
    195     dest.mkdir(exist_ok=True)

FileNotFoundError: [Errno 2] No such file or directory: 'data/balls/soccerball.csv'

I can’t figure out why it’s not finding my files.

I’m not sure on that one Michael. I haven’t run that notebook in months. Something could have changed in the fastai library. Your code looks like how I had it when I ran it months ago.

Did any one solve this issue? As i am having the same problem, where it cant find the csv file,
and i an running the exect copy of the Code provided in lesson 2

Hi, I was able to successfully run the notebook. Here’s what I tried.

After this, I ran :

download_images(path/file, dest, max_pics=200)

I have Solved it, the file directory was wrong

The original command is OK. The point is that all the urls files should be in
path/file which is the directory data/bears. So the 3 files urls_black.csv, urls_grizzly.csv and
urls_teddys.csv should be together in this directory. Observe also that does not matter if the
urls files are .csv or .txt as long as they are consistently defined above the download command.

wow how ignorant i was, this was super helpful! thanks :slight_smile: