Training a machine learning model with supervised learning, the classic way of applying machine learning in vision systems requires a large dataset of annotated images.
However, the challenge is that this dataset can be difficult - and expensive - to create.
It requires large amounts of data to train a model to recognize a scratch, for example - a scratch can have many different appearances. Often, there will be several different types of defects present, which increases the need for training material even more.
The problem is that some defects are so rare that it is difficult to get enough training material to train a model to recognize the defects, and it can be a time-consuming and expensive process.
Anomaly detection as a valid alternative
This is why exploring alternative approaches makes sense; one option is to use anomaly detection.
Tobias Skov works as Computer Vision & Machine Learning Engineer at JLI vision, and he recently handed in his Master's thesis called “Quality inspection using visual anomaly detection” at the Technical University of Denmark (DTU) about the benefits and limitations of anomaly detection.
With anomaly detection, the challenge is turned upside down, so to speak. Instead of training a model to recognize errors, you train it to recognize good items. By learning what a given item needs to look like to pass the quality check, the model can identify the items that stand out from the norm.
Cheaper and easier to get started
According to Tobias Skov, there are several advantages to this approach.
"Firstly, it's easier for companies to create a dataset of good items, and secondly, fewer images are needed to train the model. So, it will often be cheaper and faster to get started with anomaly detection," he says.
However, anomaly detection also has its limitations, the most obvious being that the result will be binary. The model can recognize whether or not the item is sufficiently resemblant to a good item, but it can't classify any errors.
"One of my conclusions in the thesis was that anomaly detection in recent years has become so robust a technique that it can deliver very high accuracy. This has proven to be very useful, even in relation to aesthetic inspection of organic materials such as wood, which can otherwise be difficult to handle because the range of anomalies is so large," says Tobias Skov.
Different ways to use anomaly detection
The most optimal use of anomaly detection depends entirely on the use case at hand. Sometimes it can stand alone, and in other contexts, it can function as a kind of "first line of defense" that detects whether there are defects on a given item, after which a supervised model can be used to classify the defects.
In many cases, anomaly detection can also be used as an extra layer for so-called "freak detection", i.e. catching errors that are so rare that you haven't predicted them or have not had enough data to train a supervised model to recognize them.