Visual Anomaly Detection
Deploying a visual anomaly model
Build a package for a supported device, choose Float32 or INT8, and read the result the device sends back.
Try it in StudioOn this page
Goal
By the end of this page you will have a visual anomaly model running on a device, and know how to read its output.
Check the model summary
Open Deployment. The model summary shows what will be built, for example Visual anomaly · GMM, Output: anomaly map 12×12 + score and Threshold: 1.00.
The threshold saved on the training or evaluation page is written into the package. If you change it later, build the package again.
Choose a target
| Target | GMM | PatchCore |
|---|---|---|
TFLite (generic .pe package) | Supported | Supported |
| Raspberry Pi | Supported | Supported |
UNO Q (.pe package) | Supported | Supported (the memory bank is capped to bound latency) |
| PXE | Supported | Supported |
| Arduino, ESP32, C++ library | Not supported | Not supported |
Arduino, ESP32 and the C++ library are shown as disabled, with the reason. Their generators only handle a single classification output, not an anomaly map, and PatchCore's memory bank does not fit a microcontroller.
More: Deployment targets and Supported devices.
Choose the precision
- Float32 is always available.
- INT8 is offered for GMM only, and only when it passes an accuracy check during training: its AUROC must be within 0.02 of the Float32 model. The training log says whether it passed, for example INT8 is not offered.
When INT8 is unavailable, the precision picker shows it disabled with the reason. PatchCore always stays Float32.
More: Choosing Float32 or INT8.
Build and run the package
- Select Build Deployment Package and wait for the build to finish.
- Download the package and install it on your device as described for that device, for example Raspberry Pi or Arduino UNO Q.
- With the device connected, open Live classification and choose the Device source to watch its results in Studio.
More: Deploying an Image model for the build steps shared with object detection.
Read the result on the device
Each frame returns the decision, the image score, the threshold and the cells of the anomaly map that reached it:
| Field | Meaning |
|---|---|
label, is_anomaly | The decision: anomaly or no anomaly. |
anomaly | The image score, on the same scale as the threshold. |
visual_anomaly_threshold | The threshold the device used. |
visual_anomaly_grid | Only the flagged cells, each with its score and position in input pixels. |
timing | Milliseconds spent preparing the image, running the model and building the map. |
The full example and every field are in The result on the device.