Skip to content

Instantly share code, notes, and snippets.

@anand086
Created July 6, 2021 06:31
Show Gist options
  • Save anand086/5aead6f9fd682b112c53ef5facceb480 to your computer and use it in GitHub Desktop.
Save anand086/5aead6f9fd682b112c53ef5facceb480 to your computer and use it in GitHub Desktop.
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()
from fastai.vision.all import *
path = untar_data(URLs.PETS)/'images'
def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path,
get_image_files(path),
valid_pct=0.2,
seed=42,
label_func=is_cat,
item_tfms=Resize(224)
)
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment