Phase 9: Deploy the winning model
At the end of this phase, the winning model runs on your machine and draws a labeled box on each die in the live camera feed.
What deploying does
Until now, your models have lived in the Viam cloud. Training and evaluation both ran there, on images already saved in your datasets. Deploying puts the model on your machine, so it runs on live camera images as they come in, without sending them to the cloud.
In practice, deploying adds two services to your machine’s configuration.
When you save, viam-server downloads the model file and the module that runs it, and starts both services:
- The ML model service,
dice-model, loads the model file and runs it. It’s thetflite_cpuservice from the registry fordice-tflite, oronnx-cpufordice-yolo. It takes numbers in, the pixels of an image, and gives numbers back: box coordinates, label numbers and scores. It doesn’t know anything about cameras or dice. - The vision service,
dice-detector, is the part that understands images. It’s the built-inmlmodelvision service, which ships withviam-server. It gets a frame fromcamera, prepares it for the model, sends it todice-model, and turns the numbers that come back into detections: a box, a label and a confidence for each die. It also drops boxes below the confidence threshold you set.
The vision service is what your code talks to.
In Phase 10, your Yahtzee module asks dice-detector for the detections in the latest camera frame and gets back a list of dice, without handling the model at all.
Because the two services are separate, you could later swap in a retrained model, or the other one, without changing your code.
For more, see How a vision service works.
Deploy the model
- On the DATA tab, click MODELS and click the winning model,
dice-tfliteordice-yolo. - Click Deploy.
- Select the latest version, your location, your machine and its part, then click Continue.
- Name the ML model service
dice-model, then click Continue. - Name the vision service
dice-detector, and check that it usescamera. - Click Deploy.
The deploy dialog picks the ML model service that matches the model’s framework and installs its module on your machine.
Checkpoint
dice-model and dice-detector, and neither shows an error.
If the services don’t appear, check that you clicked Deploy at the end of the dialog.
If dice-model shows an error, wait a minute for its module to finish installing, then check the machine’s LOGS tab.Set the confidence threshold
- On the CONFIGURE tab, open the
dice-detectorcard. - Set Minimum confidence threshold to the threshold you picked in Phase 8.
- Click Save.
The vision service drops any box below this threshold. A YOLO model from the registry script always returns its 100 best guesses, most of them near zero confidence, so without a threshold the feed fills with stray boxes.
Checkpoint
dice-detector card shows your threshold, for example 0.5.
If the setting doesn’t save, check the LOGS tab for a configuration error.Check live detections
- Roll five dice onto the background.
- In the
dice-detectorcard, click Test and selectcamera.
Checkpoint
Troubleshooting
In the next phase, you write an inline module that reads a roll from dice-detector and scores it.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!