Skip to content

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 Studio
On 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

TargetGMMPatchCore
TFLite (generic .pe package)SupportedSupported
Raspberry PiSupportedSupported
UNO Q (.pe package)SupportedSupported (the memory bank is capped to bound latency)
PXESupportedSupported
Arduino, ESP32, C++ libraryNot supportedNot 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

  1. Select Build Deployment Package and wait for the build to finish.
  2. Download the package and install it on your device as described for that device, for example Raspberry Pi or Arduino UNO Q.
  3. 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:

FieldMeaning
label, is_anomalyThe decision: anomaly or no anomaly.
anomalyThe image score, on the same scale as the threshold.
visual_anomaly_thresholdThe threshold the device used.
visual_anomaly_gridOnly the flagged cells, each with its score and position in input pixels.
timingMilliseconds spent preparing the image, running the model and building the map.

The full example and every field are in The result on the device.

What next?