Make Predictions
Run predictions on images, image URLs, directories, and video files from the command line with inference infer.
The inference infer command offers an easy way to make predictions from your model based on your input images or video files, sending requests to an Inference Server.
inference infer --helpCommand details
inference infer takes an input path or URL and a model version to produce predictions (and optionally makes a visualisation using supervision). You can also specify a host to run inference on the Roboflow hosted inference server.
Examples
Predict on a local image
This command makes a prediction from a local image using the selected model and prints the prediction on the console.
inference infer -i ./image.jpg -m {your_project}/{version} --api-key {YOUR_API_KEY}To display the visualised prediction, use the -D option. To save the prediction and visualisation in a local directory, use the -o {path_to_your_directory} option. These options also work in the other modes.
inference infer -i ./image.jpg -m {your_project}/{version} --api-key {YOUR_API_KEY} -D -o {path_to_your_output_directory}Predict on an image URL
Using the hosted API
Predict from a local directory
Predict on a video file
Configure the visualization
The -c option can be provided with a path to a *.yml file configuring supervision visualisation. There are a few pre-defined configs:
bounding_boxes- withBoxAnnotatorandLabelAnnotatorannotatorsbounding_boxes_tracing- withByteTrackerand annotators (BoxAnnotator,LabelAnnotator)masks- withMaskAnnotatorandLabelAnnotatorannotatorspolygons- withPolygonAnnotatorandLabelAnnotatorannotators
A custom configuration can be created following this schema:
The annotators field is a list of dictionaries with two keys: type and param. type points to the name of an annotator class:
param is a dictionary of annotator constructor parameters (check them in the supervision docs; you can only use primitive values, since classes and enums defined in constructors may not be resolvable from a YAML config).
tracking is an optional key that holds a dictionary with constructor parameters for ByteTrack.
Provide inference hyperparameters
The -mc parameter can be provided with a path to a *.yml file that specifies the model configuration (such as confidence threshold or IoU threshold). If given, the configuration is used to initialise an InferenceConfiguration object from the inference_sdk library. See the Inference SDK configuration reference to discover which options can be configured via the *.yml file. Configuration keys must match the names of fields in the InferenceConfiguration object.
Last updated
Was this helpful?