Step 3 - Classify an Image
Now that the data is uploaded and you created a model, you’re ready to use the model to make predictions.
You send an image to the model, and for each object the model identifies, the model returns a label, a probability, and the coordinates for a bounding box around the object. The probability value is the prediction that the model makes for whether the identified object matches the label. The higher the value, the higher the probability.
You can classify an image in these ways.
- Reference the file by a URL
- Upload the file by its path
For this example, you’ll reference this picture by the file URL.
- In the following command, replace:
<TOKEN>
with your JWT token<YOUR_MODEL_ID>
with the ID of the model that you created when you trained the dataset
Then run the command from the command line.
The model returns results similar to the following.
The model predicts that there are four objects in the image: one box of oat cereal, one box of corn flakes, and two boxes of bran cereal. For each object, the model returns a high probability that the object matches the label returned.
The model also returns the x and y coordinates for each object identified in the image. This is what the image sent in for prediction looks like with bounding boxes created from the coordinates in the response.
You can also classify a local image by uploading the image. To upload a local image, instead of the sampleLocation
parameter, pass in the sampleContent
parameter, which contains the image file location of the file to upload.