Visual Anomaly Detection
Visual anomaly workflow
Every step of a visual anomaly project in Studio, from photos of good parts to a model that flags defects on a device.
Try it in StudioOn this page
- 1Data acquisitionPhotos of good parts, a few defects
- 2Data labelingName normal and defect classes
- 3Create impulseImage block + Visual Anomaly Detection
- 4Image blockSave parameters, generate features
- 5TrainingChoose normal classes and train
- 6EvaluationAUROC, threshold, testing, live
- 7DeploymentBuild a package
A visual anomaly project is an Image project whose learning block is Visual Anomaly Detection instead of Object Detection. The model learns what normal looks like and flags anything that looks different. You do not draw boxes, and you do not need photos of every kind of defect.
Each heading below matches an item in Studio's left menu.
1. Data acquisition
Upload photos with Choose files or Upload folder, the same way as for any Image project.
- Put photos of good parts in the training set. Aim for at least 30, taken with the camera and lighting you will use on the line.
- If you have photos of defects, put them in the testing set. They are used only to measure the model and to suggest a threshold, never to train.
More: Collecting image data.
2. Data labeling
Give every image a label that says what it shows, for example good for normal parts and scratch or dent for defects. Boxes are optional: if you draw a box around the defect on anomalous test images, the Evaluation page can also report whether the model found the right spot.
More: Labeling images.
3. Create impulse
- Set Width, Height and Resize mode on the Image data input. Sides must be a multiple of 16; 96 to 224 pixels works best.
- Add a processing block: choose Image.
- Add a learning block: choose Visual Anomaly Detection.
- Select Save Impulse.
4. Image block
Open Image in the left menu, check the parameters, select Save parameters, then Generate Features.
More: Image block.
5. Training
Open Visual Anomaly Detection in the left menu:
- Keep the GMM scoring function, or select Change to pick PatchCore.
- Under Normal classes, tick the labels that show good parts.
- Select Start Training, then read the Anomaly explorer when it finishes.
More: Training a visual anomaly model.
6. Evaluation
- Evaluation shows AUROC, the ROC and precision-recall curves, the confusion matrix and the suggested thresholds.
- Model testing scores every image in your testing set and marks each one pass, fail or uncertain.
- Live classification scores an uploaded image, a test sample, your webcam or a connected device, with a heatmap of where the anomaly is.
Visual anomaly projects have no Post-processing page: the threshold is set on the training and evaluation pages instead.
More: Evaluating a visual anomaly model.
7. Deployment
Open Deployment, choose a supported target and the precision, and select Build Deployment Package. The saved threshold is written into the package.
More: Deploying a visual anomaly model.