You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-ai/ai/run-inference.md
+76-65Lines changed: 76 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,120 +15,129 @@ aliases:
15
15
- /ml/vision/segmentation/
16
16
- /ml/vision/
17
17
- /get-started/quickstarts/detect-people/
18
-
description: "Run inference on a model with a vision service or an SDK."
18
+
description: "Run machine learning inference locally on your robot or remotely in the cloud using vision services, ML model services, or SDKs."
19
+
date: "2025-09-12"
19
20
---
20
21
21
22
Inference is the process of generating output from a machine learning (ML) model.
22
-
With Viam, you can run inference to generate the following kinds of output:
23
23
24
-
- object detection (using bounding boxes)
25
-
- classification (using tags)
26
-
27
-
You can run inference locally on a Viam machine, or remotely in the Viam cloud.
24
+
You can run inference [locally on a Viam machine](#machine-inference), or [remotely in the Viam cloud](#cloud-inference).
28
25
29
26
## Machine inference
30
27
31
-
You can use `viam-server` to deploy and run ML models directly on your machines.
32
-
33
-
You can run inference on your machine in the following ways:
34
-
35
-
- with a vision service
36
-
- manually in application logic with an SDK
28
+
When you have [deployed an ML model](/data-ai/ai/deploy/) on your machine, you can run inference on your machine [directly with the ML model service](#using-an-ml-model-service-directly) or [using a vision service](#using-a-vision-service) that interprets the inferences.
37
29
38
30
Entry-level devices such as the Raspberry Pi 4 can run small ML models, such as TensorFlow Lite (TFLite).
39
-
More powerful hardware, including the Jetson Xavier or Raspberry Pi 5 with an AI HAT+, can process larger AI models, including TensorFlow and ONNX.
31
+
More powerful hardware, including the Jetson Xavier or Raspberry Pi 5 with an AI HAT+, can process larger models, including TensorFlow and ONNX.
32
+
If your hardware does not support the model you want to run, see [Cloud inference](#cloud-inference).
33
+
34
+
### Using an ML model service directly
40
35
41
36
{{< tabs >}}
42
-
{{% tab name="Vision service" %}}
37
+
{{% tab name="Web UI" %}}
43
38
44
-
Vision services apply an ML model to a stream of images from a camera to generate bounding boxes or classifications.
39
+
1. Visit your machine's **CONFIGURE** or **CONTROL** page.
40
+
1. Expand the **TEST** area of the ML model service panel to view the tensor output.
Vision services apply an ML model to a stream of images from a camera to:
47
64
48
-
{{% alert title="Tip" color="tip" %}}
49
-
Some vision services include their own ML models, and thus do not require a deployed ML model.
50
-
If your vision service does not include an ML model, you must [deploy an ML model to your machine](/data-ai/ai/deploy/) to use that service.
51
-
{{% /alert %}}
65
+
- detect objects (using bounding boxes)
66
+
- classify (using tags)
52
67
53
68
To use a vision service:
54
69
55
-
1.Visit your machine's **CONFIGURE** page.
70
+
1.Navigate to your machine's **CONFIGURE** page.
56
71
1. Click the **+** icon next to your main machine part and select **Component or service**.
57
-
1. Type in the name of the service and select a vision service.
58
-
1. If your vision service does not include an ML model, [deploy an ML model to your machine](/data-ai/ai/deploy/) to use that service.
59
-
1. Configure the service based on your use case.
60
-
1. To view the deployed vision service, use the live detection feed.
61
-
The feed shows an overlay of detected objects or classifications on top of a live camera feed.
62
-
On the **CONFIGURE** or **CONTROL** pages for your machine, expand the **Test** area of the service panel to view the feed.
72
+
1. Select a vision service.
73
+
1. Configure your vision service.
74
+
If your vision service does not include an ML model, you need to [deploy an ML model to your machine](/data-ai/ai/deploy/) and select it when configuring your vision service.
63
75
64
-
{{< imgproc src="/tutorials/data-management/blue-star.png" alt="Detected blue star" resize="x200" class="shadow" >}}
65
-
{{< imgproc src="/tutorials/filtered-camera-module/viam-figure-preview.png" alt="Detection of a viam figure with a confidence score of 0.97" resize="x200" class="shadow" >}}
76
+
{{% expand "Click to search available vision services" %}}
66
77
67
-
For instance, you could use [`viam:vision:mlmodel`](/operate/reference/services/vision/mlmodel/) with the `EfficientDet-COCO` ML model to detect a variety of objects, including people, bicycles, and apples, in a camera feed.
68
-
69
-
Alternatively, you could use [`viam-soleng:vision:openalpr`](https://app.viam.com/module/viam-soleng/viamalpr) to detect license plates in images.
70
-
Since this service includes its own ML model, there is no need to configure a separate ML model.
After adding a vision service, you can use a vision service API method with a classifier or a detector to get inferences programmatically.
73
-
For more information, see the APIs for [ML Model](/dev/reference/apis/services/ml/) and [Vision](/dev/reference/apis/services/vision/).
80
+
{{% /expand%}}
74
81
75
-
{{% /tab %}}
76
-
{{% tab name="SDK" %}}
82
+
{{% expand "Click to view example vision services" %}}
77
83
78
-
With the Viam SDK, you can pass image data to an ML model service, read the output annotations, and react to output in your own code.
79
-
Use the [`Infer`](/dev/reference/apis/services/ml/#infer) method of the ML Model API to make inferences.
84
+
<!-- prettier-ignore -->
85
+
| Example | Description |
86
+
| ------- | ----------- |
87
+
| Detect a variety of objects | Use the [`viam:vision:mlmodel`](/operate/reference/services/vision/mlmodel/) vision service with the `EfficientDet-COCO` ML model to detect a variety of objects, including people, bicycles, and apples, in a camera feed. |
88
+
| Detect license plates | Use the [`viam-soleng:vision:openalpr`](https://app.viam.com/module/viam-soleng/viamalpr) vision service to detect license plates in images. This service includes its own ML model. |
The feed shows an overlay of detected objects or classifications on top of a live camera feed.
99
+
100
+
{{< imgproc src="/tutorials/data-management/blue-star.png" alt="Detected blue star" resize="x200" class="shadow" >}}
101
+
{{< imgproc src="/tutorials/filtered-camera-module/viam-figure-preview.png" alt="Detection of a viam figure with a confidence score of 0.97" resize="x200" class="shadow" >}}
The following code passes an image from a camera to a vision service and uses the [`GetClassifications`](/dev/reference/apis/services/vision/#GetClassifications) method:
The following code passes an image from a camera to a vision service and uses the [`GetClassifications`](/dev/reference/apis/services/vision/#GetClassifications) method:
The following code passes an image from a camera to a vision service and uses the [`GetClassifications`](/dev/reference/apis/services/vision/#GetClassifications) method:
Cloud inference enables you to run machine learning models in the Viam cloud, instead of on a local machine.
119
-
Cloud inference often provides more computing power than edge devices, so you can benefit from:
130
+
Cloud inference provides more computing power than edge devices, enabling you to run more computationally-intensive models or achieve faster inference times.
120
131
121
-
- larger, more accurate models
122
-
- faster inference times
132
+
You can run cloud inference using any TensorFlow and TensorFlow Lite model in the Viam registry, including unlisted models owned by or shared with you.
123
133
124
-
You can run cloud inference using any TensorFlow and TensorFlow Lite model in the Viam registry, including private models owned by or shared with your organization.
125
-
126
-
To run cloud inference, you must pass
134
+
To run cloud inference, you must pass the following:
127
135
128
136
- the binary data ID and organization of the data you want to run inference on
129
137
- the name, version, and organization of the model you want to use for inference
130
138
131
-
The [`viam infer`](/dev/tools/cli/#infer) CLI command runs inference in the cloud on a piece of data using the specified ML model:
139
+
You can obtain the binary data ID from the [**DATA** tab](https://app.viam.com/data/view) and the organization ID by running the CLI command `viam org list`.
140
+
You can find the model information on the [**MODELS** tab](https://app.viam.com/models).
`infer` returns a list of detected classes or bounding boxes depending on the output of the ML model you specified, as well as a list of confidence values for those classes or boxes.
155
-
This method returns bounding box output using proportional coordinates between 0 and 1, with the origin `(0, 0)` in the top left of the image and `(1, 1)` in the bottom right.
163
+
The command returns a list of detected classes or bounding boxes depending on the output of the ML model you specified, as well as a list of confidence values for those classes or boxes.
164
+
The bounding box output uses proportional coordinates between 0 and 1, with the origin `(0, 0)` in the top left of the image and `(1, 1)` in the bottom right.
165
+
166
+
For more information, see [`viam infer`](/dev/tools/cli/#infer).
0 commit comments