Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
FastAI Lesson 1
Reference links:
- FastAI Book Chapter 1: https://github.com/fastai/fastbook/blob/master/01_intro.ipynb
- FastAI v2 library docs: https://dev.fast.ai/
- FastAI paper: https://arxiv.org/abs/2002.04688
Deep Learning is for everyone
Areas of Application
- Natural Language Processing
- Computer Vision
- Medicine
- Biology
- Image Generation
- Recommendation systems
- Playing games
- Robots
- Other Applications
History of Neural Networks
- Warren McCulloch - 1943
- Rosenblatt - Artificial Neuron
- Marvin Minsky - Limitations of Perceptrons
- Parallel Distributed Processing (PDP) - MIT Press 1986
Your First Deep Learning Model
- Dataset: Oxford-IIIT Pets Dataset
- Objective: Recognize cats and dogs
- Model: A pretrained model already trained on 1.3 million images will be fine-tuned using transfer learning
# Install the fastai library
!pip install fastai2 --quiet
# Import the library
from fastai2.vision.all import *
# Download the dataset
path = untar_data(URLs.PETS)/'images'
# Helper function to get cat/dog from filename
def is_cat(x): return x[0].isupper()
# Load data into fastai
dls = ImageDataLoaders.from_name_func( # Structure of dataset
path, # Working directory
get_image_files(path), # List of files
valid_pct=0.2, # Size of validation set
seed=42, # Random number seed
label_func=is_cat, # Helper function for labels
item_tfms=Resize(224)) # Data transformations
# Create a fastai "learner"
learn = cnn_learner(
dls, # Previously created dataloaders
resnet34, # Pretrained model architecture
metrics=error_rate) # Additional metrics to track
# Train the model (fine-tuning)
learn.fine_tune(1)
Downloading: "https://download.pytorch.org/models/resnet34-333f7ec4.pth" to /root/.cache/torch/checkpoints/resnet34-333f7ec4.pth
HBox(children=(FloatProgress(value=0.0, max=87306240.0), HTML(value='')))
Making predictions using the model
from ipywidgets import widgets
uploader1 = widgets.FileUpload()
uploader1
FileUpload(value={}, description='Upload')