Scroll Top
Industry

Industrial manufacturing, pharmaceuticals, FMCG

Technologies

Edge AI, computer vision, autoencoder, Jetson Nano, Python

Project type

Demo / proof of concept

A model that detects defects usually needs hundreds of images of damaged units. On a production line those images rarely exist, and waiting for them can add months to a project. Here is an approach where the system learns from correct products alone, and still points to the flaw in the ones that are not.

Challenge: the model needs defect images that take months to collect

Traditional quality control on a production line relies on an operator who checks every unit coming off the conveyor against the specification. Automating that job is a field of its own within computer vision, known as Quality Control, and it is usually approached through classification: the model is shown images of good and faulty products, learns to tell them apart, and then alerts the operator.

The trouble starts with the data. Training a classifier requires a comparable number of images from both classes, in practice at least several hundred faulty products and just as many correct ones. Correct units are on the conveyor all day long, so collecting them is a formality. Defects are an entirely different story.

A defect is anything that departs from the reference. A crack, a missing element, discolouration, a crushed corner, a scratch nobody has seen before. There is no way to assemble a set covering every possible type of damage, let alone supply it in the volume a model needs to learn what counts as a fault. Teams get stuck here for months and often end up with a dataset that turns out to be insufficient anyway.

Solution: anomaly detection instead of classification

We changed the question. The model no longer answers “is this product faulty”, but “how far does this product differ from what I know as normal”. For that, it only needs to be shown images of correct products, and those are never in short supply on a line.

Recognising normality is the job of an autoencoder, a model built from two parts. The encoder learns the features of an image, much as a conventional classifier does. The decoder has to rebuild the picture from those learned features, so that the output resembles the input as closely as possible.

The more faithful the reconstruction, the more confident the model is that it is looking at a standard sample. When a faulty product arrives at the input, the decoder still tries to rebuild the image, but it encounters a feature it was never trained on. The reconstruction drifts, and the gap between input and output grows.

Anomaly maps: the model shows you where the problem is

We calculate that gap for every smallest fragment of the image, which produces an anomaly map. The higher the value at a given point, the stronger the anomaly, and the warmer the colour in the visualisation.

Anomaly map of a defect-free blister pack - cool colours across the surface
No defect

Map stays cold throughout

Anomaly map of a blister pack with a cut-off corner - warm area in the upper-left corner
Defect

Cut-off corner

Anomaly map of a blister pack with a damaged tablet
Defect

Damaged tablet

Anomaly map of a blister pack containing foreign tablets
Defect

Foreign tablets

The same scale applies to all four samples. Cool colours mean the product matches the learned reference, warm ones mark the spot where the model saw something unexpected.

The defect that was never on the list

During testing, the model marked the middle of a blister described as correct with a warm band. The tablets were not the issue: it was a damaged blister seal, a defect nobody had put on the list of faults to look for. A classifier trained on a catalogue of known damage would have let that unit through, because it would have had no class to assign it to.

Anomaly map of a blister pack with a damaged seal - warm band along the middle of the pack
Defect

Damaged blister seal

How it works in practice: Jetson Nano, a camera and an alarm threshold

We trained the autoencoder exclusively on images of undamaged blister packs and deployed it on our Edge AI device. For rapid prototyping we chose a Jetson Nano, a single-board Linux computer, and connected an ordinary RGB webcam to it.

The simulation of automated Quality Control verification was wrapped in a simple web application. The operator sets a threshold value there, above which the system marks a product as non-compliant and raises an alert that visual verification has failed. The dashboard shows the live view from the conveyor, a PASS or FAIL verdict, and the anomaly map of the most recent unit.

Operator application dashboard - FAIL verdict, threshold of 0.50 exceeded, anomaly map with warm areas
FAIL

Threshold of 0.50 exceeded

Operator application dashboard - PASS verdict, product matches the reference, anomaly map without warm areas
PASS

Product matches the reference

The operator's application. The slider at the top sets the alarm threshold, the camera view shows the detected product, and the anomaly map of the last unit appears below.

The whole thing runs in real time. Even on the fastest production lines, the model has time to check every product passing the camera several times over.

Benefits of anomaly detection on the production line

Four advantages that make this approach worth considering over classification:

  • Start without collecting defects. Images of normal samples are enough, so the project does not spend months waiting for a damage dataset that often turns out incomplete anyway.
  • You immediately know where. A classifier only answers “ok” or “not ok”. Here you get a visual indication of the flaw’s location, which shortens the operator’s reaction time and helps trace the cause back to the process.
  • Defects that were never on the list. The model reacts to anything departing from the reference, so it also catches faults nobody anticipated when the inspection was defined.
  • Versatility. The example concerns blister packs, but the method is not tied to a product. Wherever a repeatable visual reference exists, an autoencoder can learn it.

Applications in other industries

Pharmaceuticals is a natural example given the quality standards involved, but the same mechanism works for inspecting packaging and labels, mouldings and castings, electronic components, welds and joints, as well as for checking that kits are complete. Every time, the starting point is the same question: can you collect a few hundred images of the product looking the way it should. If you can, the project can begin straight away.

Empower your project

Unlock the full potential of your technical aspirations!

Contact our experts to explore the possibilities and drive your projects to a new level.

Empower your project

Discover the full potential of technology with experienced engineers.

< title="detectingwatercontamination">detectingwatercontamination

Aqua Insights by Aqua Alarm AS – Smart Water Contamination Detection System

A network of IoT sensors and artificial intelligence that detect drinking water contamination in real time – designed for the Norwegian company Aqua Alarm. The system is already live with one of Europe’s largest water utility operators.

Read more
< title="termowizja-krowy-pastwisko">termowizja-krowy-pastwisko

Smart Livestock Hall Cooling with Edge AI and Thermovision

Thermal imaging cameras and Edge AI that detect animals across hall zones in real time and dynamically control cooling. Designed for a livestock farm. The solution reduced energy consumption and improved animal welfare.

Read more
< title="Interaktywna papuga ai rapidlab case study">Interaktywna papuga ai rapidlab case study

Interactive AI Parrot

A talking parrot powered by Raspberry Pi that uses Edge AI to detect a wake-up word and holds real-time conversations via the ElevenLabs API – housed in a weather-resistant, 3D-printed casing.

Read more