fastai
is a deep learning library that builds on top of PyTorch, adding a higher level of functionality.
[It] is organized around two main design goals: to be approachable and rapidly productive, while also being deeply hackable and configurable.
Manual
Tutorials
Peer-reviewed paper
Paperback version
Free MOOC version of part 1 of the book
Jupyter notebooks version of the book
Four domains available
Load only the one relevant to your model:
from fastai.vision.all import *
from fastai.text.all import *
from fastai.tabular.all import *
from fastai.collab import *
Note that import *
is not recommended in Python outside the context of fastai
Create iterators with the training and validation data
Train the model
Get predictions from our model
from fastai.vision.all import *
path = untar_data(URLs.PETS)/'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))
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
img = 'lion.jpg'
is_cat,_,probs = learn.predict(img)
print(f"Is this a cat?: {is_cat}.")
print(f"Probability it's a cat: {probs[1].item():.6f}")