Computer vision and AI detects defects in the blink of an eye

  • Anomaly detection

XXXXXXXXXXX was looking to improve the quality control of their production plant and both detect and grade their products into high grade, medium grade and unusable categories.

The Plant

The plant was semi automated, with several steps including the quality control being handled manually.

The Process

The process was both slow, creating a bottleneck before the packaging process, and prone to human errors.

The problem

Batches of products being returned due to failure in meeting quality standards.

Batches where high grade products were sold in medium or low grade pricing due to incorrect classification.


Revenue loss was estimated due to these issues

To improve this process, it was decided to use computer vision with an AI model to automate the quality control system.

Our objectives

Process more products per hour using a much smaller workforce

Produce more accurate results to reduce product return and incorrect pricing

Our approach

We determined that the objectives could be achieved by performing the following operations:

Anomaly detection

An anomaly detection would be necessary to detect foreign objects or aspects of the production which needs to be completely avoided

Outlier detection

An outlier detection would be necessary to help in grading, and detect a degree of presence or absence of features that are more, or less desired within the final product.

Anomaly localization

It was needed to point out the location of the defect for possible human verification and as a way to detect problems in accuracy with the detection mechanism to facilitate retraining and improvement.

Using robotics

A robotic loading/ offloading and conveyor belt mechanism connected with the detection system would speed up the process.

Obstacles to the solution

While in the implementation phase, we encountered some practical issues that required resolution.

Due to the factory setting, the image capturing mechanism is not ideal, and there is limited scope for improvement.

Sometimes defects or anomalies are camouflaged within the products themselves, as they are multi coloured.

Sometimes ‘fake’ defects or anomalies are recorded within the products due to reflections from surroundings and lighting conditions.

Overall the dataset was quite diverse, and there were relatively small margins between the grading of “great”,”usable” and “faulty”.

Tackling the problem from several angles

We introduced an enclosed ‘light box’ structure within the production pipeline where the images would be captured within an enclosed area whose ambient color can be controlled by using white-lined bulbs and software controlled RGB LED lights.

This allowed the system to protect the product from artificial artifacts or anomalies being registered due to lighting or reflections.

The system also allowed us to work with multiple images taken in different ambient colors, which solved the defect camouflage problem by giving our product outline detection, separation and defect outline detection algorithms multiple sets of data whose results could be cross referenced and used for better accuracy.

Hybrid approach

Preprocessing the images and removing the background using HSV color model and applying gaussian blur for removal of insignificant pixel level artifacts or noise which are not of significant size

f-AnoGAN with structural similarity index measure (SSIM) for anomaly localization


accuray was achieved initially


accuracy was achieved after phase 2 of encoder training.

Result in statistics

10X Speed increase

Speed of workflow was increased by 10x, from one product being inspected in 5 mins, to one product being accurately inspected in 30 seconds.

80% HR cost decrease

Product Rejection rate dropped from 25% to 10% and instances of improper grading was reduced to 15%.

Technologies Used

icon Python
icon OpenCV
icon PyTorch
icon Scikit-Learn
icon TensorFlow
icon Keras

we’re here to discuss your