9December 2022The key is to categorize defects and prepare sufficient defect sample for each defect and create a dataset20% of samples shall be marked as testing dataset which shall not be used to train the AI model. Tagging your datasetThere can be a set of defect categories for your design or product, and a name shall be given to each category. Usually, a rectangular box shall be assigned to each defect region on the sample image as a result of specifying two coordinates on the given image. Multiple defects of same or different categories of defects can be marked simultaneously. We call this process as "boxing" to define the region and "tagging" to assign the defect category. With this information ready, the dataset is ready to train the AI model.Train your modelIn June 2020, YOLOv5 was released, and this CNN-based model is fast and easy to use. It is based on the PyTorch framework, detecting objects in real-time with great accuracy. This approach uses a single neural network to process the entire picture, then separates it into parts and predicts bounding boxes and probabilities for each component. Let the jargons fly, and what we need to do is to do is coding in a Python notebook on Google Colab or AWS Sagemaker to train this pre-defined model with your dataset, the 50 to 200 sample photos with tagging the defective region and defect categories. These cloud tools are free of charge and free your time and efforts in any installation in your local computer which may run even slower than in the cloud. A code segment critical to enable training is shown below and if you need the full reference codes, please contact me further.Evaluating your modelGiven the YOLOv5 model, the trained model shall basically function to a pretty performance. Basically, we set the metric before training and a basic approach will include:· Accuracy· Precision· Recall· SpecificityFor specific quality gating and defect detection, I recommend setting metric for accuracy and recall rate to be high, for example, over 95%. A high accuracy demands an overall accuracy to acquire correct prediction while a high recall minimize the missing rate of true positive (defective in this application).Good precision and recall rate actually depend on how precise the images in dataset are tagged and boxed. Here is my example application showing four categories of issues or defects:· Welding issue· Scratch and debris· FoggyThe evaluation result showing confidence level once the defect is being identified and classified. Below are a few images after prediction is done over the dataset. Inferencing, the other name of prediction, can be done instantly within few mini seconds basing on the YOLO model being used.Adapting to your productFor your own product and defect classifications, you shall pre-define visual defects that shall be tracked over volume production. Imagine you are using a thermal camera or a X-ray machine, you can capture more meaningful information with respect to your product and the defect you want to track. The application can be extended further to suit special needs in different workplaces where pure reliance on human workforce is not appropriate and tight measures on reliability and consistency are required. The usual inferencing rate can be 500 to 1000 in an hour, talking about few mini seconds per sample inspection over image.Migrating from Cloud to EdgeWhile deploying the AI model in cloud will certainly incurring costs, Google and AWS will charge basing on the compute resources, storage resources or no. of images being processed for classification of defects. Hence moving out of cloud back will be the next step. The first choice is the hybrid approach. By purchasing and deploying a special edge device like AWS Deeplens, we can directly put the trained AI model in production mode and execute it locally in the ATOM-enabled embedded system within Deeplens to ride on OPEX-free operation in defect inferencing while you can deploy immediately any trained models from your AWS cloud. The other choice is third party embedded system. I suggest Nuovoton embedded system NUC980 which runs on embedded Linux O/S and can deploy any trained models from AWS as well. At last we can also choose to setup a local computer without GPU for inferencing operation. This can be a generic setup under Window O/S or Linux O/S but there will be more installation of software to support the goal, including Anaconda3 for python notebook emulation. < Page 8 | Page 10 >