> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/reference/inference/inference-cli/infer.md).

# Make Predictions

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.

{% hint style="success" %}
To see the details of the command, run:

```bash
inference infer --help
```

{% endhint %}

## Command 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.

{% hint style="info" %}
If you are using a local Inference Server, make sure the command `inference server start` was used first.
{% endhint %}

{% hint style="success" %}
Your Roboflow API key can be provided via the `ROBOFLOW_API_KEY` environment variable.
{% endhint %}

## 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.

```bash
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.

```bash
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

```bash
inference infer -i https://[YOUR_HOSTED_IMAGE_URL] -m {your_project}/{version} --api-key {YOUR_API_KEY}
```

### Using the hosted API

```bash
inference infer -i ./image.jpg -m {your_project}/{version} --api-key {YOUR_API_KEY} -h https://serverless.roboflow.com
```

### Predict from a local directory

```bash
inference infer -i {your_directory_with_images} -m {your_project}/{version} -o {path_to_your_output_directory} --api-key {YOUR_API_KEY}
```

### Predict on a video file

```bash
inference infer -i {path_to_your_video_file} -m {your_project}/{version} -o {path_to_your_output_directory} --api-key {YOUR_API_KEY}
```

### 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` - with `BoxAnnotator` and `LabelAnnotator` annotators
* `bounding_boxes_tracing` - with `ByteTracker` and annotators (`BoxAnnotator`, `LabelAnnotator`)
* `masks` - with `MaskAnnotator` and `LabelAnnotator` annotators
* `polygons` - with `PolygonAnnotator` and `LabelAnnotator` annotators

A custom configuration can be created following this schema:

```yaml
annotators:
  - type: "bounding_box"
    params:
      thickness: 2
  - type: "label"
    params:
      text_scale: 0.5
      text_thickness: 2
      text_padding: 5
  - type: "trace"
    params:
      trace_length: 60
      thickness: 2
tracking:
  track_activation_threshold: 0.25
  lost_track_buffer: 30
  minimum_matching_threshold: 0.8
  frame_rate: 30
```

The `annotators` field is a list of dictionaries with two keys: `type` and `param`. `type` points to the name of an annotator class:

```python
from supervision import *
ANNOTATOR_TYPE2CLASS = {
    "bounding_box": BoxAnnotator,
    "box": BoxAnnotator,
    "mask": MaskAnnotator,
    "polygon": PolygonAnnotator,
    "color": ColorAnnotator,
    "halo": HaloAnnotator,
    "ellipse": EllipseAnnotator,
    "box_corner": BoxCornerAnnotator,
    "circle": CircleAnnotator,
    "dot": DotAnnotator,
    "label": LabelAnnotator,
    "blur": BlurAnnotator,
    "trace": TraceAnnotator,
    "heat_map": HeatMapAnnotator,
    "pixelate": PixelateAnnotator,
    "triangle": TriangleAnnotator,
}
```

`param` is a dictionary of annotator constructor parameters (check them in the [`supervision`](https://github.com/roboflow/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](/reference/inference/inference-sdk/configuration.md) to discover which options can be configured via the `*.yml` file. Configuration keys must match the names of fields in the `InferenceConfiguration` object.
