A Fast Introduction to FastAI — My Experience | by Yash Prakash | Dec, 2020


Let me tell you about how I built an image classifier model in less than an hour!

Yash Prakash
Photo by Dhru J on Unsplash

The steps to get started

from fastai.vision.all import *
DATASET_PATH = Path('RockPaperScissors/data')
DATASET_PATH.ls()'''Output: [Path('RockPaperScissors/data/valid'),Path('RockPaperScissors/data/.DS_Store'),Path('RockPaperScissors/data/Rock-Paper-Scissors'),Path('RockPaperScissors/data/train'),Path('RockPaperScissors/data/test2')]'''
rps_datablock = DataBlock(
blocks = (ImageBlock, CategoryBlock),
get_items = get_image_files,
splitter = GrandparentSplitter(),
get_y = parent_label,
batch_tfms=aug_transforms(size=128, min_scale=0.75)
folder structure
learn = cnn_learner(dls, resnet34, metrics=accuracy)
(0): Sequential(
(0): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace=True)
(3): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
... and so on.
# 2 being the number of epochs
learning with transfer learning
interpret = ClassificationInterpretation.from_learner(learn)
rock paper scissors prediction confusion matrix


Read More …


Write a comment