Automatically detect various types and sizes of surface defects on a small metal part (a component of motorcycle motors) and measure them when found.

Starting point

Quality control was being carried out through traditional computer vision systems that were inadequate at managing the variability linked to the components being analyzed. The parts inspected were often dirty or had hard-to-manage stains or other markings, leading to the need for complete inspections by specialized operators.

This activity is absolutely critical both because of the time investment required and the ergonomics of the job of the operator, who was completing the task with the help of magnification systems, indispensable to finding such minute defects.

Solution implemented

The first phase of the project was a data acquisition campaign and the segmentation of the various defects. To complete this task, an annotation tool was developed for the client, quickly making it possible to identify and pinpoint the defects in every image, dividing them into different categories. Using datasets created in this way, we developed two AI algorithms: the first analyses the image of the piece in its entirety to identify large defects, while the second analyzes close-ups (patches) cut out from the larger image and identifies the pinpointed defects.

A limit can be set to discriminate between defects that merit discarding the piece and defects that are considered acceptable. More specifically, parts with a pinpointed defect greater than 0.2 mm will be discarded.  Dirt or stains, however, do not trigger the scrapping of pieces, even if identified by the software.
The models were validated in the field, through the installation of a system that automates the acquisition of images, the launch of algorithms and the display of outputs. The user interface allows expert operators to view the defects identified by the AI system, distinguishing between those that are to be discarded and those that do not require operator involvement.
Expert operators then have the option to validate or reject the system’s assessment.


The testing of the system was carried out by double-checking 10,000 pieces that had been previously marked as scrap by operators. Among them, the AI system confirmed 1,800, while 8,000 were deemed to be acceptable by both the algorithm and a second inspection by operators.

The sale of those pieces paid for the entire project.
Only 5 pieces were deemed acceptable by the system and discarded by operators, though they were borderline examples even for the experts. It can therefore be concluded that there were no cases in which the system missed large, glaring defects.

Current developments

We are working to get the client’s supply chain involved through the creation of heatmaps that identify the points where defects most often occur, so that the supplier can implement the necessary corrections and prevent the issue that is generating the defect.