-
Notifications
You must be signed in to change notification settings - Fork 17
Loading image classification model for inference
In the previous tutorial, we trained a network that could identify between 2 different kids of cars. Here, we will use that model for inference.
Start by downloading a picture that is of one of the 2 cars. Here is an example.
First create a new Python script called image_classification_cars_prediction.py
. Make sure the image you downloaded is in the same folder as this new file. Open up that file and start by importing the ImageClassificationPredictor
class from quickai:
from quickai import ImageClassificationPredictor
Once you have imported that class, lets call it to make our prediction:
predictions = ImageClassificationPredictor(
"cars", 224, "00198.jpg", [
'Acura Integra Type R 2001', 'Acura RL Sedan 2012'])
print(predictions)
In the above line of code we call the ImageClassificationPredictor
with cars
as the save
, 224
as dims
, 00198.jpg
as path, and [ 'Acura Integra Type R 2001', 'Acura RL Sedan 2012']
as classes
. save
is the parameter that specifies the name of the model to load, dims
is the dimensions the model needs for prediction(224 in the case of VGG16), path
is the path of the image to use for prediction, and classes
is a list of our classes.
Now, go ahead and run image_classification_cars_prediction.py
. After a few seconds you will see the predictions printed to the console!
View package on PyPi