Skip to content

Instantly share code, notes, and snippets.

@danielcwq
Created November 14, 2021 12:49
Show Gist options
  • Save danielcwq/465fc654a5d8fd14cf4c3c7ef8f377f1 to your computer and use it in GitHub Desktop.
Save danielcwq/465fc654a5d8fd14cf4c3c7ef8f377f1 to your computer and use it in GitHub Desktop.
First model to differentiate between cats and dogs.
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(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment