HTML tags are preserved.
High-resolution Imagery and Defect Detection
High-resolution imagery is widely used today, with applications ranging from satellite imagery to drones and DSLR cameras. This type of imagery allows us to capture various types of damage and defects, such as those caused by natural disasters or manufacturing anomalies. However, building anomaly detection models using high-resolution imagery can be challenging due to the need to resize images to lower resolutions for training and inference. This reduction in resolution can result in the loss or degradation of important visual information.
One approach to overcome these challenges is to use a two-stage model. In this approach, the first stage of the model detects a region of interest, while the second stage focuses on detecting defects within the cropped region of interest. By using this two-stage approach, we can maintain sufficient resolution for detecting small defects.
In this post, we will discuss how to build an effective two-stage defect detection system using Amazon Rekognition Custom Labels. We will also compare the results of this approach with one-stage models that are commonly used. It is important to note that some one-stage models are effective even at lower resolutions, while others can handle large images in smaller batches.
Solution Overview
For our specific use case, we will be using a dataset of images of printed circuit boards (PCBs) with synthetically generated missing hole pins. The goal is to detect these missing hole defects using our models. The training process for the Rekognition Custom Labels model consists of several steps:
- The image data is stored in Amazon Simple Storage Service (Amazon S3).
- The data is ingested into Amazon Sagemaker Jupyter notebooks, where data scientists inspect and preprocess the images.
- The data is split into training and test sets, and Amazon SageMaker Ground Truth labeling jobs are used to label the images.
- The labeled data is used to train the Rekognition Custom Labels model.
One-stage Model Approach
In the first approach, we train an object detection model to identify the missing hole defects on the PCBs. However, the results of this model show subpar detection performance, with high precision but low recall. This means that while the model correctly identifies the regions with missing holes most of the time, it misses a significant number of actual missing holes on the PCBs.
To improve the model’s performance, we explore splitting the image into multiple crops and labeling both healthy pins and missing holes. By training the model with zoomed-in cropped images and a reference to the model for healthy pins, we are able to significantly improve both precision and recall. However, recall is still not perfect, with a small percentage of missing holes being missed by the model.
Two-stage Model Approach
In the two-stage model approach, we train two separate models: one for detecting pins and another for detecting if a pin has a missing hole. The first model successfully detects the pins, while the second model accurately classifies the cropped images to identify pins with missing holes. By combining these two models, we can build a defect detection system that outperforms any single-stage model.
Inference Pipeline
To deploy the models described in this post, we can use an inference pipeline with the following components:
- For one-stage models, an input image is sent to an API Gateway endpoint, processed by a Lambda function for image preprocessing, and then routed to the Rekognition Custom Labels trained model endpoint.
- For two-stage models, the image is also sent to an API Gateway endpoint and processed by a Lambda function acting as an orchestrator. The function first calls the object detection model to generate the region of interest, crops the original image, and then sends each cropped image to another Rekognition Custom Labels model for defect detection.
Conclusion
In this post, we have explored the use of one- and two-stage models for defect detection in PCBs using Amazon Rekognition Custom Labels. Our experiments showed that the two-stage models outperformed other variants, achieving perfect precision and recall on synthetic datasets. This demonstrates the effectiveness of the two-stage approach in maintaining resolution and improving defect detection performance.