Skip to content

Instantly share code, notes, and snippets.

@riven314
Last active October 24, 2022 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riven314/92b768299dc27d7b19794ba979cba39e to your computer and use it in GitHub Desktop.
Save riven314/92b768299dc27d7b19794ba979cba39e to your computer and use it in GitHub Desktop.
sample run lesson1-pets.ipynb to test M1 mac
from fastai.vision.all import *
#from nbdev.showdoc import *
set_seed(2)
bs = 64
path = untar_data(URLs.PETS);
Path.BASE_PATH = path # display all paths relative to dataset root
path_anno = path/'annotations'
path_img = path/'images'
fnames = get_image_files(path_img)
dls = ImageDataLoaders.from_name_re(
path, fnames, pat=r'(.+)_\d+.jpg$', item_tfms=Resize(460), bs=bs,
batch_tfms=[*aug_transforms(size=224, min_scale=0.75), Normalize.from_stats(*imagenet_stats)])
print(dls.vocab)
learn = vision_learner(dls, resnet34, metrics=error_rate).to_fp16()
learn.fit_one_cycle(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment