
## π¬ pip install inference
[Roboflow](https://roboflow.com) Inference is the easiest way to use and deploy computer vision models.
Inference supports running object detection, classification, instance segmentation, and even foundation models (like CLIP and SAM).
You can [train and deploy your own custom model](https://github.com/roboflow/notebooks) or use one of the 50,000+
[fine-tuned models shared by the community](https://universe.roboflow.com).
There are three primary `inference` interfaces:
* A Python-native package (`pip install inference`)
* A self-hosted inference server (`inference server start`)
* A [fully-managed, auto-scaling API](https://docs.roboflow.com).
## π Getting Started
Get up and running with `inference` on your local machine in 3 minutes.
```sh
pip install inference # or inference-gpu if you have CUDA
```
Setup [your Roboflow Private API Key](https://app.roboflow.com/settings/api)
by exporting a `ROBOFLOW_API_KEY` environment variable or
adding it to a `.env` file.
```sh
export ROBOFLOW_API_KEY=your_key_here
```
Run [an open-source Rock, Paper, Scissors model](https://universe.roboflow.com/roboflow-58fyf/rock-paper-scissors-sxsw)
on your webcam stream:
```python
import inference
inference.Stream(
source="webcam", # or rtsp stream or camera id
model="rock-paper-scissors-sxsw/11", # from Universe
on_prediction=lambda predictions, image: (
print(predictions) # now hold up your hand: πͺ¨ π βοΈ
)
)
```
> [!NOTE]
> Currently, the stream interface only supports object detection
Now let's extend the example to use [Supervision](https://roboflow.com/supervision)
to visualize the predictions and display them on screen with OpenCV:
```python
import cv2
import inference
import supervision as sv
annotator = sv.BoxAnnotator()
inference.Stream(
source="webcam", # or rtsp stream or camera id
model="rock-paper-scissors-sxsw/11", # from Universe
output_channel_order="BGR",
use_main_thread=True, # for opencv display
on_prediction=lambda predictions, image: (
print(predictions), # now hold up your hand: πͺ¨ π βοΈ
cv2.imshow(
"Prediction",
annotator.annotate(
scene=image,
detections=sv.Detections.from_roboflow(predictions)
)
),
cv2.waitKey(1)
)
)
```
## π©βπ« More Examples
The [`/examples`](https://github.com/roboflow/inference/tree/main/examples/) directory contains code samples for working with and extending `inference` including using foundation models like CLIP, HTTP and UDP clients, and an insights dashboard, along with community examples (PRs welcome)!
## π₯ Inference in action
Check out Inference running on a video of a football game:
https://github.com/roboflow/inference/assets/37276661/121ab5f4-5970-4e78-8052-4b40f2eec173
## π» Why Inference?
Inference provides a scalable method through which you can manage inferences for your vision projects.
Inference is composed of:
- Thousands of [pre-trained community models](https://universe.roboflow.com) that you can use as a starting point.
- Foundation models like CLIP, SAM, and OCR.
- A tight integration with [Supervision](https://roboflow.com/supervision).
- An HTTP server, so you donβt have to reimplement things like image processing and prediction visualization on every project and you can scale your GPU infrastructure independently of your application code, and access your model from whatever language your app is written in.
- Standardized APIs for computer vision tasks, so switching out the model weights and architecture can be done independently of your application code.
- A model registry, so your code can be independent from your model weights & you don't have to re-build and re-deploy every time you want to iterate on your model weights.
- Active Learning integrations, so you can collect more images of edge cases to improve your dataset & model the more it sees in the wild.
- Seamless interoperability with [Roboflow](https://roboflow.com) for creating datasets, training & deploying custom models.
And more!
### π Use the Inference Server
You can learn more about Roboflow Inference Docker Image build, pull and run in our [documentation](https://inference.roboflow.com/quickstart/docker/).
- Run on x86 CPU:
```bash
docker run --net=host roboflow/roboflow-inference-server-cpu:latest
```
- Run on NVIDIA GPU:
```bash
docker run --network=host --gpus=all roboflow/roboflow-inference-server-gpu:latest
```
π more docker run options
- Run on arm64 CPU:
```bash
docker run -p 9001:9001 roboflow/roboflow-inference-server-arm-cpu:latest
```
- Run on NVIDIA GPU with TensorRT Runtime:
```bash
docker run --network=host --gpus=all roboflow/roboflow-inference-server-trt:latest
```
- Run on NVIDIA Jetson with JetPack `4.x`:
```bash
docker run --privileged --net=host --runtime=nvidia roboflow/roboflow-inference-server-jetson:latest
```
- Run on NVIDIA Jetson with JetPack `5.x`:
```bash
docker run --privileged --net=host --runtime=nvidia roboflow/roboflow-inference-server-jetson-5.1.1:latest
```
## β
Supported Models
### Load from Roboflow
You can use models hosted on Roboflow with the following architectures through Inference:
- YOLOv5 Object Detection
- YOLOv5 Instance Segmentation
- YOLOv8 Object Detection
- YOLOv8 Classification
- YOLOv8 Segmentation
- YOLACT Segmentation
- ViT Classification
### Core Models
Core Models are foundation models and models that have not been fine-tuned on a specific dataset.
The following core models are supported:
1. CLIP
2. L2CS (Gaze Detection)
3. Segment Anything (SAM)
## π License
The Roboflow Inference code is distributed under an [Apache 2.0 license](https://github.com/roboflow/inference/blob/master/LICENSE.md). The models supported by Roboflow Inference have their own licenses. View the licenses for supported models below.
| model | license |
| :------------------------ | :-----------------------------------------------------------------------------------------------------------------------------------: |
| `inference/models/clip` | [MIT](https://github.com/openai/CLIP/blob/main/LICENSE) |
| `inference/models/gaze` | [MIT](https://github.com/Ahmednull/L2CS-Net/blob/main/LICENSE), [Apache 2.0](https://github.com/google/mediapipe/blob/master/LICENSE) |
| `inference/models/sam` | [Apache 2.0](https://github.com/facebookresearch/segment-anything/blob/main/LICENSE) |
| `inference/models/vit` | [Apache 2.0](https://github.com/roboflow/inference/main/inference/models/vit/LICENSE) |
| `inference/models/yolact` | [MIT](https://github.com/dbolya/yolact/blob/master/README.md) |
| `inference/models/yolov5` | [AGPL-3.0](https://github.com/ultralytics/yolov5/blob/master/LICENSE) |
| `inference/models/yolov7` | [GPL-3.0](https://github.com/WongKinYiu/yolov7/blob/main/README.md) |
| `inference/models/yolov8` | [AGPL-3.0](https://github.com/ultralytics/ultralytics/blob/master/LICENSE) |
## Inference CLI
We've created a CLI tool with useful commands to make the `inference` usage easier. Check out [docs](./inference_cli/README.md).
## π Enterprise
With a Roboflow Inference Enterprise License, you can access additional Inference features, including:
- Server cluster deployment
- Device management
- Active learning
- YOLOv5 and YOLOv8 commercial license
To learn more, [contact the Roboflow team](https://roboflow.com/sales).
## π documentation
Visit our [documentation](https://inference.roboflow.com) for usage examples and reference for Roboflow Inference.
## π contribution
We would love your input to improve Roboflow Inference! Please see our [contributing guide](https://github.com/roboflow/inference/blob/master/CONTRIBUTING.md) to get started. Thank you to all of our contributors! π
## π» explore more Roboflow open source projects
| Project | Description |
| :---------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [supervision](https://roboflow.com/supervision) | General-purpose utilities for use in computer vision projects, from predictions filtering and display to object tracking to model evaluation. |
| [Autodistill](https://github.com/autodistill/autodistill) | Automatically label images for use in training computer vision models. |
| [Inference](https://github.com/roboflow/inference) (this project) | An easy-to-use, production-ready inference server for computer vision supporting deployment of many popular model architectures and fine-tuned models. |
| [Notebooks](https://roboflow.com/notebooks) | Tutorials for computer vision tasks, from training state-of-the-art models to tracking objects to counting objects in a zone. |
| [Collect](https://github.com/roboflow/roboflow-collect) | Automated, intelligent data collection powered by CLIP. |