Beginner: Using Colab or Kaggle ✅

Thank you @bencoman.
I already fixed the widget issue, I had to

pip install ipywidgets


import widget from ipywidget

and it is now working and interactive.

Thanks so much for your response.


@deelight_del, Thanks for reporting back!!! That will help the next person.

1 Like

Whenever using the fastbook search_images_ddg function in Colab I get the following error:

@LeoJuhlin This error pops up when interacting with a folder as if it’s a file.

I believe you have your results and dest flipped around, it should be something more akin to:

download_images(dest, urls=results.attrgot('contentURL')

You can take a look at this code from chapter 2 of the fastbook as an example (use a ctrl + f search for “download_images” if you wanna find the specific code block):

bear_types = 'grizzly','black','teddy'
path = Path('bears')

if not path.exists():
    for o in bear_types:
        dest = (path/o)
        results = search_images_bing(key, f'{o} bear')
        download_images(dest, urls=results.attrgot('contentUrl'))
1 Like

I’m having trouble with autocomplete suggestion in Kaggle. I’m getting no suggestions, even when I hit tab, for both native Python functions and functions included in packages that I imported. Any advice on how to get autocomplete suggestions in Kaggle?

1 Like

It worked now. Thank you!

hey guys!

started lesson 1 yesterday, however when i copy the notebook “is it a bird?” in kaggle or re-write it from scratch in colab, i get this error when trying to run the fourth cell:

# searching for a batman photo
urls = search_images('batman photos', max_images = 1)

it comes with HTTP Error 403: Forbidden raised.

however, when I change the url of the previous cell from ‘’ to ‘’, i got another type of error: HTTP Error 405: Method not allowed.

and when changed from ‘’ to ‘’ (russian-based search engine) it throws another error: AttributeError: 'NoneType' object has no attribute 'group'.

is something wrong with my colab environment?


Hey everyone

I too am getting a HTTP Error 403: Forbidden in lesson 1. Appreciate any help on this

/opt/conda/lib/python3.7/site-packages/fastcore/ in urlread(url, data, headers, decode, return_json, return_headers, timeout, **kwargs)
    113         with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs =,u.headers
    114     except HTTPError as e:
--> 115         if 400 <= e.code < 500: raise ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp) from None
    116         else: raise

HTTP403ForbiddenError: HTTP Error 403: Forbidden

@svrmnnk @seiger I’m also getting these issues inside the Kaggle notebook itself, even when running it all vanilla, definitely not an issue with Colab.

Not exactly sure what the issue is, perhaps the notebook needs an update.

Hi Guys, I am seeing the same error and not sure what needs to be done. Can anyone help?

HTTP403ForbiddenError                     Traceback (most recent call last)
/tmp/ipykernel_17/ in <module>
----> 1 urls = search_images('bird photos', max_images=1)
      2 urls[0]

/tmp/ipykernel_17/ in search_images(term, max_images)
     10     urls,data = set(),{'next':1}
     11     while len(urls)<max_images and 'next' in data:
---> 12         data = urljson(requestUrl,data=params)
     13         urls.update(L(data['results']).itemgot('image'))
     14         requestUrl = url + data['next']

/opt/conda/lib/python3.7/site-packages/fastcore/ in urljson(url, data, timeout)
    123 def urljson(url, data=None, timeout=None):
    124     "Retrieve `url` and decode json"
--> 125     res = urlread(url, data=data, timeout=timeout)
    126     return json.loads(res) if res else {}

/opt/conda/lib/python3.7/site-packages/fastcore/ in urlread(url, data, headers, decode, return_json, return_headers, timeout, **kwargs)
    113         with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs =,u.headers
    114     except HTTPError as e:
--> 115         if 400 <= e.code < 500: raise ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp) from None
    116         else: raise

HTTP403ForbiddenError: HTTP Error 403: Forbidden

@chsheth @seiger @svrmnnk seems a solution has been found: Lesson 1 official topic - #288 by ltogniolli

1 Like

yeah, i saw it, thank you for mentioning!

Thanks @DylanWu

EDIT: Figured it out
timm has to be imported BEFORE fastbook

When using Colab, or Paperspace I cannot use timm models:

from import *
import timm

learn = vision_learner(dls, 'convnext_nano', metrics=accuracy)

gives me

/usr/local/lib/python3.7/dist-packages/fastai/vision/ in create_timm_model(arch, n_out, cut, pretrained, n_in, init, custom_head, concat_pool, pool, lin_ftrs, ps, first_bn, bn_final, lin_first, y_range, **kwargs)
    181                      concat_pool=True, pool=True, lin_ftrs=None, ps=0.5, first_bn=True, bn_final=False, lin_first=False, y_range=None, **kwargs):
    182     "Create custom architecture using `arch`, `n_in` and `n_out` from the `timm` library"
--> 183     model = timm.create_model(arch, pretrained=pretrained, num_classes=0, in_chans=n_in, **kwargs)
    184     body = TimmBody(model, pretrained, None, n_in)
    185     nf = body.model.num_features

NameError: name 'timm' is not defined

I think that is not a correct conclusion.

I was already looking into this for you, so tried your solution, but still get the same error…

import timm
from import *
path = untar_data(URLs.MNIST_SAMPLE)
block = DataBlock(
        blocks=(ImageBlock, CategoryBlock),
dls = block.dataloaders(path/"train")
#learn = vision_learner(dls, 'resnet18', metrics=accuracy)
learn = vision_learner(dls, 'convnext_nano', metrics=accuracy)

…so perhaps there was some other change you made?

Looking at Line 177 and researching here:
I found “How to use - Create a model” provides a better Minimum Reproducible Example…

import timm
model = timm.create_model('resnet18')
model = timm.create_model('convnext_nano')


Further down the page, “list_models()” looks useful…

import timm
models = timm.list_models()
[ s for s in models if 'convnext' in s ]


which simply doesn’t list the model you were trying to use. So maybe its the version of timm installed?
So trying the following worked for me…

!pip install -U timm
import timm
model = timm.create_model('convnext_nano')

There are competitions in kaggle that they do not give training images without folders. Supposedly someone could use panda and match image with its category using image_id and image_category in cvs file that they give. (I do not know how to do it but I will figure this out, nice challenge to get more familiar with panda). However , I like to create subfolders and put those images in their folder so it would be way easier to use fastai and fastkaggle. Does kaggle allow me to do that in kaggle ? The data is 360G so I do not want to download it locally. I have M1 Mac. It does not have GPU.I am also not sure I could do this in paperspace. Any idea to create subfolders in train folder in kaggle? does kaggle has terminal we could manipulate data set. (Create subfolders and put each images to their subfolders)

@bahman_apl : Kaggle input folder is read-only, so you cannot just create folders and move images in place. You could copy in the working directory, but likely room is not sufficient. In general, you may execute shell commands in a notebook cell by prefixing them with ! .
However, since you refer to the Strip AI challenge, consider that they are extremely large digital slides that need tiling, possibly downsizing, etc.

1 Like

I can’t seem to get the ‘H’ hotkey to work in command mode in Kaggle.

To see a complete list of all of the functions available, press H

Any thoughts?

I have the same problem here. I tried running %config Completer.use_jedi = False, which worked the last few nights, but stopped working today. I’m keen to hear if anyone has the same problem.

I believe it was a correct solution, because

from import *
!pip install -U timm
import timm

doesn’t work, whereas

!pip install -U timm
import timm
from import *


the reason why I focused on this was I heard Jeremy pointing this out in one of the videos (live coding sessions I believe)

1 Like