Checking the quality of manufactured goods — on cAInvas

Use deep learning to identify the defective goods in the manufacturing line.

Checking the quality of manufactured goods — on cAInvas
Photo by Yulia Yu on Dribbble

Production of goods is a highly automated process. The goods produced in bulk are not immune to defects and identifying defective products is a crucial part of the manufacturing process to maintain the reputation of the product in the market as well as for safety concerns in some cases.

How does deep learning help?

Manual filtering is time consuming, tedious, and inefficient. It is a waste of labor hours and energy.

Deep learning models can be trained to pick out defective products with high efficiency and in almost no time. The output of the model can be used to trigger a movement to separate them from the production belt.

This article differentiates between defective and non-defective casting products.

Casting defects

A casting defect is an undesired irregularity in a metal casting process.

There are many types of defects in casting like blow holes, pinholes, burr, shrinkage defects, mold material defects, pouring metal defects, metallurgical defects, etc.

Link to the cAInvas notebook implementation of the concept — here

The dataset

The dataset zip file given in the notebook has two folders — train and test, each with subfolders — def_front (defective) and ok_front (non-defective).

The train and test datasets are created using the image_data_from_directory function of the Keras preprocessing library. Each subfolder is taken as a separate class.

The train folder had 6377 images in total and the test folder has 715.

The images are of size 256×256. Here are a few samples-


Some of the defects are evident to us from the images.

Input to the model

The image data is normalized for faster convergence of the model using the rescaling function of the Keras library.

The model

We use a sequential model with CNN layers followed by Dense layers.

The model uses an Adam optimizer with a learning rate of 0.01.

The sparse categorical cross-entropy loss is used as the class labels are given as integers.

The model’s accuracy is tracked to evaluate its performance.

Training and prediction

The model achieves 99.6% accuracy on the test set after training for 8 epochs.

Model evaluation
Model evaluation

The metrics

Training accuracy plot
Training accuracy plot

Training loss plot
Training loss plot

Let’s visualize the test image while seeing the model’s prediction —

Example prediction
Example prediction


deepC library, compiler, and inference framework are designed to enable and perform deep learning neural networks by focussing on features of small form-factor devices like micro-controllers, eFPGAs, CPUs, and other embedded devices like raspberry-pi, odroid, Arduino, SparkFun Edge, RISC-V, mobile phones, x86 and arm laptops among others.

deepC compilation
deepC compilation

Head over to the cAInvas platform and check out the predictions by the generated .exe file.

Credit: Ayisha D

Also Read: Human Activity Recognition App using deepC and cAInvas