CoolFace
Apppublic

xav-b/pet-classifier

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
App README

Guide

Generating and saving the model

py
from fastai.vision.all import *

print("downliading", URLs.PETS)
path = untar_data(URLs.PETS)/'images'
print('path:', path)

# it just happens that this aprticular dataset has this property
def is_cat(x): return x[0].isupper()

# initialise data
dls = ImageDataLoaders.from_name_func(
  '.',
  get_image_files(path),
  valid_pct=0.2,
  seed=42,
  label_func=is_cat,
  item_tfms=Resize(192),
)

# train and ine tune model
learn = vision_learner(dls, resnet18, metrics=error_rate)
learn.fine_tune(3)

# export the data
learn.export('model.pkl')

Resources

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference