Hi everyone,
I`m trying to run the code of Chapter 2. On google colab the download_images() function is working fine, but on Jarvislabs, it’s not. (I tried Google Cloud Platform too, that one time that I got a GPU, and also there it wasn’t working…)
The Bing API works as I get a list of working URL’s of bear pictures. Just the actual downloading into the folders doesn’t work.
I don’t get any error messages. The function creates the folders but no images are placed in it.
Google colab, the platform where I got it working is using a much older version of FastAI, that might have something to do with it?
Any ideas?
Would love to keep moving forward with the course!
in case anyone is having the same issue. Instead of using the download_images() function I made up this piece of code. (which probably has bugs but is does the job in this case)
from urllib import request
if not path.exists():
path.mkdir()
for o in bear_types:
dest = (path/o)
dest.mkdir(exist_ok=True)
results = search_images_bing(key, f'{o} bear')
pic_id = 0
for url in results.attrgot('contentUrl'):
url_last_part = url.rsplit('/', 1)[-1]
file_extension = url_last_part.rsplit('.', 1)[-1]
try:
request.urlretrieve(url, f'{dest}/{o}{pic_id}.jpg')
except:
pic_id += 1
continue
pic_id += 1
The download_images function has a bug in fastai version 2.5.0, which is fixed in the latest version 2.5.2. You can look into the issue to understand more.
You can upgrade the fastai version by
pip install fastai --upgrade
We will update the base version in Jarvislabs.ai soon, so you do not need to do it manually.