| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Real-time visual anomaly detection for industrial quality inspection using Edge Impulse FOMO-AD, a Texas Instruments SK-TDA4VM edge AI board, a USB camera, and Python.
Visual Anomaly demonstrates how to build an edge-based visual inspection system that learns what a correctly assembled product looks like and detects deviations without requiring a training dataset containing every possible defect.
The reference implementation uses:
The example dataset consists of correctly assembled electrical components. Once trained, the model can identify unexpected visual differences and report not only that an anomaly exists, but also where it appears in the image.
USB camera
│
▼
┌────────────────────┐
│ Texas Instruments │
│ SK-TDA4VM │
│ │
│ Edge Impulse │
│ Linux Runner │
└─────────┬──────────┘
│
▼
FOMO-AD
│
▼
Anomaly grid + scores
│
▼
anomaly.py
│
▼
Terminal matrix
. . . . .
. . X X .
. . X X .
. . . . .
. . . . .
A conventional image classifier usually requires examples of every class it needs to recognize.
For manufacturing inspection, that can become difficult.
A product may fail in many different ways:
missing component
wrong component
misalignment
surface damage
incorrect assembly
foreign object
deformation
unexpected color
unknown future defect
Collecting representative images for every possible failure mode can be impractical.
Visual anomaly detection takes a different approach:
Many examples of GOOD products
│
▼
Learn normal state
│
▼
New camera image
│
▼
Compare against normality
│
┌─────┴─────┐
▼ ▼
Normal Anomaly
The model is trained to understand the distribution of normal visual features.
An image region that differs significantly from that learned distribution receives a higher anomaly score.
The project uses FOMO-AD — Faster Objects, More Objects: Anomaly Detection, developed by Edge Impulse.
FOMO-AD extends the FOMO architecture for visual anomaly detection and is designed specifically for deployment on edge hardware.
Unlike a conventional defect classifier, FOMO-AD can be trained primarily using:
normal
normal
normal
normal
normal
...
rather than requiring:
normal
broken connector
missing screw
cracked housing
incorrect label
bent terminal
wrong component
...
This makes it particularly useful when the space of possible defects is large or unknown.
FOMO-AD uses a Gaussian Mixture Model — GMM for anomaly scoring.
A GMM models the distribution of feature vectors produced by normal training images.
Conceptually:
Normal image
│
▼
Feature extractor
│
▼
Feature vectors
│
▼
Gaussian Mixture Model
│
▼
Probability distribution
During inference:
New image region
│
▼
Feature vector
│
▼
How probable is this feature
under the learned distribution?
│
┌───┴───┐
▼ ▼
High Low
│ │
Normal Anomaly
A low probability of belonging to the learned normal distribution results in a high anomaly score.
A major advantage of FOMO-AD is that it does not only return:
anomaly = yes
It can also locate the anomalous region.
The Edge Impulse Linux Runner returns cells containing information such as:
{
"height": 19,
"label": "anomaly",
"value": 3.5148870944976807,
"width": 19,
"x": 38,
"y": 0
}The fields describe:
| Field | Meaning |
|---|---|
| x | Horizontal position |
| y | Vertical position |
| width | Width of the anomaly cell |
| height | Height of the anomaly cell |
| label | Cell classification |
| value | Anomaly score |
This allows downstream software to determine which area of the inspected product differs from the learned normal state.
The repository includes:
anomaly.py
The script parses the visual-anomaly output generated by the Edge Impulse Linux Runner.
Instead of displaying raw JSON, it converts anomaly locations into a simple text matrix.
Conceptually:
Runner JSON
│
▼
Parse cells
│
▼
Read x / y coordinates
│
▼
Build matrix
│
▼
X = anomaly
. = normal
Example:
. . . . .
. . . . .
. X X . .
. X X . .
. . . . .
This provides an immediate terminal representation of the location of a detected defect.
The reference implementation uses the:
Texas Instruments SK-TDA4VM
This development kit is designed for edge AI vision applications and is based on the TDA4VM Jacinto processor.
Relevant specifications include:
Official hardware page:
Processor:
The project uses a conventional USB webcam.
The original build was tested with cameras such as:
Logitech C270
Logitech C920
Logitech C922
Other Linux-compatible UVC cameras may also work.
A suitable camera should provide:
For anomaly detection, camera consistency is important because differences in lighting, focus, or perspective can themselves appear anomalous.
The reference project uses electrical components / circuit breakers as the inspected objects.
Approximately 100–120 images of correctly assembled products were used to demonstrate the workflow.
correct breaker
correct breaker
correct breaker
correct breaker
correct breaker
│
▼
Training
│
▼
Normal model
Then a modified or incorrectly assembled example can be presented to the camera:
expected product
vs.
unexpected visual difference
The same workflow can be adapted to many other objects by replacing the training dataset.
Examples:
The repository contains:
dataset/
with sample material associated with the project.
The important principle for training FOMO-AD is that the training set should primarily represent the correct product state.
Good training images should cover normal variations such as:
small position changes
minor lighting variation
normal manufacturing tolerances
small camera differences
acceptable surface variation
while excluding actual faults.
Visual anomaly detection depends heavily on dataset consistency.
Potential problems include:
A model may learn these variations as part of the normal distribution or mistakenly classify them as anomalies.
For production systems, the imaging setup should be mechanically controlled whenever possible.
The public Edge Impulse project is available at:
Visual Anomaly — Edge Impulse Studio
The reference workflow uses:
Image Data
│
▼
96 × 96
│
▼
Squash resize
│
▼
Image processing
│
▼
FOMO-AD
Upload approximately:
100+
images of correctly assembled products.
Use:
No Anomaly
as the normal-state label where required by the Edge Impulse workflow.
The training dataset should contain as few actual anomalies as possible.
Configure image input as:
Width: 96
Height: 96
Resize: Squash
Add:
Image
as the processing block.
Then select:
Visual Anomaly Detection / FOMO-AD
as the learning block.
Edge Impulse extracts visual features from the training images.
These features represent the visual structure of correctly assembled products.
The feature explorer can help identify:
FOMO-AD includes a configurable:
Capacity
parameter.
Higher capacity increases the number of Gaussian components used to model the normal feature distribution.
Conceptually:
Lower capacity
│
▼
simpler normal distribution
Higher capacity
│
▼
more detailed adaptation
to the training distribution
Too little capacity may underfit normal variation.
Too much capacity may make the model unnecessarily specific to the training data.
FOMO-AD uses an anomaly threshold to determine when a cell should be classified as anomalous.
anomaly score
│
▼
compare with threshold
│
┌───┴────┐
▼ ▼
below above
│ │
normal anomaly
Changing the threshold modifies sensitivity.
A lower threshold may increase detection sensitivity but also increase false positives.
A higher threshold may reduce false positives but miss subtle defects.
The threshold should therefore be validated using representative production examples.
After training, open:
Model Testing
in Edge Impulse.
Use:
Classify All
to evaluate test images.
For FOMO-AD, the visual interface displays a grid over the image.
Cells are represented using anomaly scores.
Regions exceeding the configured threshold indicate detected anomalies.
Anomaly-only training does not inherently provide the same accuracy metric as a conventional supervised classification dataset.
To evaluate the system more formally, a separate test set can contain labeled examples such as:
No Anomaly
Anomaly
This can then be used to calculate metrics such as:
precision
recall
F1 score
without contaminating the normal-only training data.
The original project used the Texas Instruments Linux SDK for the SK-TDA4VM.
Official download:
The historical project tutorial used:
08.06.00.11
because that image worked with the USB camera and Edge Impulse Linux Runner used during development.
Texas Instruments now publishes newer SDK releases, so current installations should also consult the current TI and Edge Impulse documentation.
Download the appropriate:
.wic.xz
image from Texas Instruments.
Flash it to a microSD card using a tool such as:
Insert the microSD card into the SK-TDA4VM and boot the board.
The reference setup uses Ethernet.
SK-TDA4VM
│
└── Ethernet
│
▼
Router
Determine the IP address assigned by the router.
The historical TI image used:
User: root
Password: empty
for SSH access.
Credentials and defaults can differ on current Processor SDK releases.
Connect the USB webcam before launching inference.
The Edge Impulse Linux tools can expose a camera preview stream.
In the original setup this could be viewed at:
http://<BOARD_IP>:4912
For example:
http://192.168.1.67:4912
Use the preview to check:
before collecting data or running inference.
The original setup updates Node.js with:
npm install -g n
n lts
n latest
n pruneThen installs Edge Impulse for Linux:
npm install -g --unsafe-perm edge-impulse-linuxVerify the tools are available before continuing.
On the SK-TDA4VM:
edge-impulse-linux-runnerLog in with your Edge Impulse credentials.
Select the Visual Anomaly project when prompted.
The Linux Runner downloads the model and starts inference using the attached camera.
If the Edge Impulse model or threshold has been changed, reset the runner's downloaded model:
edge-impulse-linux-runner --resetThen launch it again:
edge-impulse-linux-runnerClone the repository:
git clone https://github.com/ronibandini/visualAnomaly.git
cd visualAnomalyThe main parser is:
anomaly.py
The original deployment copied it to:
/opt/edge_ai_apps
Run:
python3 anomaly.pyThe script processes FOMO-AD results and prints the visual anomaly map to the terminal.
┌──────────────────┐
│ Normal products │
│ 100+ photographs │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Edge Impulse │
│ │
│ Image processing │
│ FOMO-AD │
└────────┬─────────┘
│
▼
Train / test
│
▼
┌──────────────────┐
│ Edge Impulse │
│ Linux Runner │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ SK-TDA4VM │
│ + USB camera │
└────────┬─────────┘
│
▼
anomaly scores
│
▼
anomaly.py
│
▼
terminal matrix
visualAnomaly/
├── dataset/
├── README.md
└── anomaly.py
Python parser for Edge Impulse visual-anomaly inference output.
It converts anomaly coordinates into a simplified terminal visualization.
Sample project data associated with the visual anomaly experiment.
Original project notes and links.
Inference is performed on the local hardware.
The production path is:
camera
│
▼
TDA4VM
│
▼
Edge Impulse model
│
▼
anomaly score
The camera frames do not need to be uploaded to a remote inference server.
Advantages include:
The architecture can be adapted to quality-control tasks such as:
missing components
incorrect connectors
damaged PCB sections
wrong component placement
assembly errors
missing screws
surface damage
deformation
incorrect machining
assembly differences
missing labels
damaged boxes
incorrect closures
missing contents
wrong printing
incorrect shape
surface damage
foreign material
packaging anomalies
missing elements
The model must be retrained with normal examples from the specific object and production environment.
High image noise can make convolutional feature extraction less reliable.
Use:
An anomaly larger than the effective receptive field of the model may not be represented optimally by a single FOMO-AD configuration.
For some applications, multiple models operating at different scales can provide additional confidence.
The model can only learn the normal variations represented in its training data.
If legitimate production variation is missing from the dataset, it may be classified as anomalous.
There is no universal anomaly threshold.
The correct value depends on:
The project demonstrates the Machine Learning core of a visual inspection system.
A production implementation may additionally require:
camera trigger
industrial lighting
PLC integration
conveyor synchronization
product tracking
reject mechanism
database
traceability
statistics
operator UI
alerts
multiple cameras
redundant inspection
📊 Store anomaly scores over time — save coordinates, scores, product IDs and timestamps to a database for quality trends and process analysis.
🦾 Automatic reject mechanism — integrate the validated anomaly result with a PLC, servo or pneumatic mechanism to divert defective parts from a production line.
📷 Multi-camera inspection — combine several synchronized views to detect defects that cannot be reliably observed from a single camera angle.
Edge Impulse published a dedicated feature about this project on June 26, 2024.
The article covers:
Building an Automated Manufacturing Inspection System with FOMO-AD — Edge Impulse
The complete technical tutorial is part of the Edge Impulse Expert Network.
It documents:
Visual Anomaly Detection with FOMO-AD — Edge Impulse Documentation
The model can be inspected in Edge Impulse Studio:
Visual Anomaly — Edge Impulse Studio
Spanish-language article explaining:
Edge Impulse also featured the project through its official LinkedIn account:
Building an Automated Manufacturing Inspection System with FOMO-AD — Edge Impulse on LinkedIn
The repository includes a YouTube demonstration of the running visual anomaly system:
More projects, technical experiments and context around unconventional hardware, artificial intelligence, Machine Learning and electronic prototyping are collected in:
Other projects by Roni Bandini involving anomaly detection, industrial inspection and Edge Impulse.
A low-cost standalone visual anomaly detector using the Seeed Studio Grove Vision AI Module V2 and Edge Impulse FOMO-AD.
This project takes the same anomaly-detection concept to a much smaller and less expensive vision module.
github.com/ronibandini/visualAnomalyGroveV2
Visual anomaly detection with Edge Impulse on the RUBIK Pi 3, connected to n8n for data aggregation, charts and email reports.
It extends the original visualAnomaly model into a reporting and workflow-automation architecture.
github.com/ronibandini/rubikpi3-anomaly-detection
Offline TinyML experiment using voltage, temperature and recent voltage behavior to detect conditions associated with power outages.
Another anomaly-oriented Machine Learning project focused on detecting deviations from normal operating conditions.
github.com/ronibandini/EdenOff
Roni Bandini
Maker, AI developer, electronic artist and writer.
Buenos Aires, Argentina.
| Back | FazBrowse Home | New Git URL |