Flawless Defect Detection with Edge Impulse and BrainChip

In manufacturing environments, automated defect detection has become a key component in ensuring product quality, efficiency, and customer satisfaction. Detecting defects is crucial for several reasons. Firstly, it safeguards the reputation of the manufacturer by ensuring that only products meeting the highest standards reach the market, minimizing the risk of recalls or customer dissatisfaction. Secondly, it enhances operational efficiency by reducing waste, rework, and the overall cost of production. Finally, in industries where safety is a key consideration, such as in the automotive or aerospace sectors, defect detection can literally be a matter of life and death.

Automation of the process is increasingly preferred over manual inspections because it eliminates human error and subjectivity, resulting in more consistent and reliable inspections. Moreover, it significantly increases inspection speed and throughput, allowing for higher volumes of products to be inspected in shorter time frames. Automation also enables the integration of advanced technologies such as machine learning and computer vision, which can detect defects with higher accuracy and even anticipate potential issues before they occur.

Recent technological advances have enabled the development of many highly accurate and efficient inspection systems; however, these existing systems can be very expensive and complicated. Equipment costs, installations, and training can stretch the budgets of even large organizations, and necessary calibration procedures and other maintenance can lead to significant downtime. At best, these factors will cause manufacturers to take a hit to the bottom line. And in the worst case, smaller organizations may find themselves priced out of the automated inspection market completely, having to forego the myriad benefits.

BrainChip Akida Development Kit

But the march of technological progress continues on, and as it does, technologies become available to wider audiences. Engineer Peter Ing recognized that recent advances in machine learning algorithms and edge computing platforms, in particular, could be leveraged to perform automated defect detection in a simple and cost-effective manner. To prove this point, Ing built a prototype detection system with a hand from Edge Impulse and BrainChip.

Smart detection

In a manufacturing environment, products are generally inspected as they zip by on a production line, commonly on a conveyor belt. As they do, each individual item must first be located, and once found, it must be determined if it looks as it should, or if there is something abnormal about it. This is a challenging thing to do in real-time, especially on a budget, because the algorithms required for these tasks can be very computationally expensive.

Ing took a two-pronged approach to deal with these challenges. On the software side, he used Edge Impulse to design and optimize an object detection algorithm for locating each individual item, and to act as a classification algorithm for spotting any defects. This took most of the complexity out of the development process, and also made it possible to gear these algorithms towards running on edge hardware platforms. On the hardware end of the equation, Ing chose to use a development kit with a BrainChip Akida neuromorphic processor. The Akida processors are hard to beat when it comes to the balance between performance and energy efficiency.

Automatically labeled training data

Specifically, Ing used an Akida Development Kit centered around a Raspberry Pi Compute Module 4 in this project. This gives the versatility of an Arm-based Linux system for general-purpose development, with an Akida AKD1000 neuromorphic processor to make short work of machine learning workloads. He paired this with a USB webcam to capture images of products as they pass by during production.

After setting up the hardware, Ing’s next step involved capturing images to train the pair of machine learning models needed by the inspection device. To prove the concept, he collected images of gears — some normal and others defective in one way or another — and uploaded them to two separate Edge Impulse projects.

A pre-trained model from the Akida Model Zoo can be fine-tuned with Edge Impulse

Objects, defects, and deployment

The first project focuses on object detection, leveraging Edge Impulse’s own innovative FOMO algorithm. FOMO is ideal for use on resource-constrained edge devices, as it has been demonstrated to consume just 1/30 the computing power and memory of competing object-detection models like MobileNet SSD and YOLOv5. To prepare the training data for this pipeline, Ing utilized the Auto Labeler tool. With just a few clicks, this utility will identify all objects of interest in the uploaded images and draw bounding boxes around them. Without this AI-powered boost, labeling can be a very time-consuming and tedious process.

Ing’s second project leverages a neural network classifier to identify defects in detected objects. Edge Impulse’s extensive support for BrainChip devices enabled Ing to select a pre-trained model from the Akida Model Zoo. These pre-trained models already contain a lot of knowledge about the world, which means smaller datasets can be used to fine-tune them for a particular use case. In addition to saving time, this results in the generation of more accurate models.

With the impulses built and trained, Ing utilized the Deployment tool to export the models in BrainChip MetaTF Model format. This tool handles quantization of the model weights and converting the classifier to a spiking neural network for use with the Akida processor, which could otherwise be a daunting process.

Ing’s web application performs real-time defect detection

Ing also developed a custom Python script to handle model inferences, and designed a simple web-based interface that shows images of gears as they roll by on a conveyor system in real-time. Annotations show if the gears look good as they pass by, or if the system finds a defect. It also gives options to swap out the object detection and classification models on the fly or adjust model settings — no need for downtime on the production line!

In addition to his detailed project write-up, Ing has also made the Edge Impulse object detection and classification projects public. Whatever items you need an automated inspection system for, this information will give you a running start. You could have a better quality control process roughed out after a day’s work. And feel free to clone Ing’s projects — we call it sharing, not cheating.

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter