Resnet 18 in "is it a bird" and why not restnet26d or others?

Hi everyone,
In Jeremy’s notebook “is it a bird” , if I put resnet26d instead of resnet18,it gives an error. Why this happen? Why I can’t put another model?

Jeremy’s code:

learn = vision_learner(dls, resnet18, metrics=error_rate)
learn.fine_tune(10)

My code:

learn = vision_learner(dls, resnet26d, metrics=error_rate)
learn.fine_tune(10)

Error:

resnet26d is not define

I might be wrong on this, but fastai out of the box doesn’t provide a ton of models to be used. (This is at least a partial list, though I couldn’t find something like this in the docs, so maybe there are others.)

For using lots of different models, your best bet is to use timm in conjunction with fastai, described in the docs. Maybe resnet26d is in there? This explains how to list the available models.

I’d also recommend you check out this notebook which will give you some intuition for what you might consider using as alternatives to resnet. For example, it seems that the convnext family do pretty well for image classification.

3 Likes

Thank You very much!
It has helped me a lot

1 Like

The reason why you get an error when you use resnet26d instead of resnet18 in Jeremy’s notebook is because resnet26d is not defined in the notebook.

The resnet26d model is from the PyTorch library, but it is not imported by default in the fastai library. To use the resnet26d model, you need to import it from PyTorch explicitly.

Here is an example of how to import the resnet26d model and use it in the fastai library:

import torch
from fastai import vision

# Import the resnet26d model from PyTorch
resnet26d = torch.hub.load('pytorch/vision:v0.10.0', 'resnet26d', pretrained=True)

# Create a fastai learner using the resnet26d model
learn = vision_learner(dls, resnet26d, metrics=error_rate)

# Fine-tune the learner for 10 epochs
learn.fine_tune(10)

Once you have imported the resnet26d model, you can use it in any fastai notebook or project.

1 Like