How to find classification of a single image instance? (fastai)

156 views Asked by At

The code below creates a classifier from MNIST data set for 3 and 7 image digits. Can you help me figure out how to use this learner to classify a new image?

!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

from fastai.vision.all import *
from fastbook import *

matplotlib.rc('image', cmap='Greys')
path = untar_data(URLs.MNIST_SAMPLE)
dls = ImageDataLoaders.from_folder(path)
learn=cnn_learner(dls,resnet18,pretrained=False,loss_func=F.cross_entropy,metrics = accuracy)
learn.fit_one_cycle(1,0.1)
1

There are 1 answers

7
Vidyadhar Rao On

Just use learn.predict('testImage.jpg')

For your reference, see the fastai docs vision tutorial