Learn practical skills, build real-world projects, and advance your career

Computer vision classification

"""
fastai's applications all use the same basic steps and code:
1. Create appropriate DataLoaders
2. Create a Learner
3. Call a fit method
4. Make predictions or view results.
"""
from fastai.vision.all import *

path = untar_data(URLs.PETS)/'images'
path
Path('/home/ahmad/.fastai/data/oxford-iiit-pet/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))
# Using a pretrained model that has already been trained on 1.3 million images Resnet34
learn = cnn_learner(dls, resnet34, metrics=error_rate)
# The pretrained model will be fine-tuned using the latest advances in transfer learning
learn.fine_tune(1)