Effect of Environmental Factors on the Accuracy of a Quality Inspection System Based on Transfer Learning

In this research, a study is introduced on the effect of several environmental factors on the performance of an already constructed quality inspection system, which was designed using a transfer learning approach based on convolutional neural networks. The system comprised two sets of layers, transferred layers set from an already trained model (DenseNet121) and a custom classification layers set. It was designed to discriminate between damaged and undamaged helical gears according to the configuration of the gear regardless to its dimensions, and the model showed good performance discriminating between the two products at ideal conditions of high-resolution images. So, this study aimed at testing the system performance at poor settings of lighting, background, distance and camera resolution. Experimental results implied that the system was able to show high accuracies above 90% at very bad settings and around 99% at good settings, which assures that an inspection system with good performance can be built at low costs.


Introduction
Automated quality inspection systems based on computer vision (CV) and deep learning (DL), can push the manufacturing facilities a step forward, with more accurate, reliable and cost-effective architectures. DL is considered as an advanced data analysis technique and this characteristic places it in a position to be one of the building blocks of smart manufacturing [1]. The importance of using DL with CV on the other hand, has arisen due to several qualities possessed by DL, in which it upscaled traditional CV systems and made it more sophisticated and easier to implement and design. Machine vision with deep learning have been used for: defects detection in products [2], inspection of sugarcane varieties [3], process monitoring and quality control [4], welding inspection [5] optical laser welding inspection [6], laser welding defects detection [7] and gear faults diagnosis with convolutional neural networks (CNNs) [8]. As DL depends on deep neural networks to extract the necessary features from the data automatically, in contrast with traditional CV techniques where manual features extraction is mandatory [9]. Some of the previous researches that relied on traditional CV methods include: inspection of spur gears parameters with the algorithms of CV and image processing [10], measuring gears dimensions with machine vision algorithm [11], detecting defects in welds using CV and machine learning algorithms [12], measuring automobile parts dimensions with machine vision [13], O-rings inspection with CV algorithm [14], aerospace components inspection using CV [15] and anomaly detection in additive manufacturing with CV [16].
Unlike conventional manual inspection systems, automated platforms have the advantage of being unaffected by psychological factors and fatigue, which normally occurs with human beings [17]. This characteristic improves the production efficiency and eliminates costs, as continuous operations are performed without being affected by those factors. Although, other factors that are not associated with humans emotions like environmental factors, can have major or minor impacts on the system performance depending on the strength of the designed architecture and the training data. So, providing the necessary tools to build a system can help with making it more tolerable to environmental factors.
In this paper, a study is conducted regarding the effects of four environmental factors on the performance of a helical gears inspection system that is designed using transfer learning. A number of combined conditions has been used to test and evaluate the system. The remainder of this paper is organized in the following matter, in section two we briefly introduce transfer learning and the built inspection system, in sections three and four; the experimental data and the evaluation results are shown, respectively. Finally, we close with section five and six with the conclusions and future work.

Transfer Learning
To improve learning within new tasks, knowledge can be transferred from a task that is already learned and related to the new one [18]. That is how transfer learning generally functions. DL and CNNs require a massive amount of information about the target task before being able to perform adequately [19]. But, sometimes there are not enough data resources to cover the necessary amount of training data, which results in inaccurate performance by the model, overfitting (high performance on the training data but low on the validation data) [20] and eventually failing to accomplish the target task. So, using a technique like transfer learning can help with eliminating those problems and reducing the amount of requested information. Giving a remarkable performance with small datasets and can be compared with custom CNNs [21] [22]. A previously trained model can be thought of as two sets of tools, one that extracts features and one that classifies the objects according to those features [9]. When transferring layers from one network to another, a new classification layer must be added to classify the new target objects, taking into consideration that the transferred classification layer must be muted.

Inspection System
Using transfer learning, a model was designed to detect and classify the helical gears according to their shape condition, DenseNet121 model was used as the transferred model as can be seen in Table 1. The model (Fig. 1) was deployed and evaluated on a set of random unseen images with random conditions. Evaluation results yielded high classification accuracy, which proved that using CNNs with CV was superior to classical methods, as it was easier to implement with automatic features extraction and transfer learning.

Methodology
Classical analysis methods rely on descriptive type of analysis, which always include hypotheses assembled from the process information patterns, with a comparison between the model results and the genuine results for hypotheses verification [23]. However, models that rely on this method are unsafe, in which some variables might be left unmodeled due to misinterpretation of the issue by the engineers or lack of information [24]. Notwithstanding, predictive analysis, takes a phenomenon, unfold the underlying rules and construct a predictive model that takes all the variables into account and restricts errors between the predicted and the desired outcomes [23].
Since DL models rely on predictive models, CNNs granted an advantage over traditional CV methods as high accuracies for image classification can be guaranteed with automatic feature extraction, where classic CV applications depend on tedious manual features extraction. Nevertheless, every model requires some preprocessing steps before performing the target task. So, to conduct the research and study the effects of the previously mentioned factors, few earlier steps were taken to satisfy the prerequisites of the analysis process, which will be briefly discussed in the following subsections.

Data Preparation
Prior to the evaluation process, imagery data of different gears with and without shape damages had to be collected to be classified into two classes, but due to lack of data resources, only two gears were used as the test samples, in which one was used as the healthy class and the other one as the unhealthy (damaged) class. The images for the damaged one were taken at several stages, in which it started with simple damages (surface damage like scratches were not targeted in this research) and then more impairments were added using an electric cutter, as shown in Fig. 2. Two phone cameras (24 and 8 mega-pixels) were used to capture the test images, moreover, a microcomputer called Raspberry Pi 3 was also used to collect images by employing an attached camera board with 5 mega-pixels resolution without using any additional lenses, as shown in Fig. 3.

Fig. 3. Raspberry Pi 3 microcomputer (left) and the camera board (right).
Jupyter Notebook, an open-source development environment, provides the tools to develop deep neural networks and perform the necessary processing operations and data manipulation. So, to study the proposed factors, Python's application programming interface (API) was used within the environment, to build the evaluation code, upload the network and initiate the prediction process. Prior to the test, a function was built to convert the inserted images by modifying the dimensions, to meet the DenseNet121 [25] standard image dimensions of (224 × 224) pixels that it was trained on in the ImageNet challenge [26]. Then by employing the model as the tool that can classify the images, the accuracy was predicted, and according to the cost function that is used in the model, which is binary cross-entropy function, the loss was also estimated.

2. Experimental Work
The used model was tested with random environmental factors, so, to make sure that the model is fully functional and can be used in real practical applications and industrial facilities, environmental factors must be taken into consideration. Factors that were studied within this research are: the intensity of light, the type of background, the resolution of the camera and the distance between the camera and the inspected object. Those factors are important to study to select the appropriate settings for the system. As can be seen in Fig. 4, a light-box with three 12Watts LEDs was used to take images with different settings of the factors to point out the model capabilities. Several images (Fig. 5) were captured at different conditions to evaluate the performance of the system.

Experimental Results
The effect of the distance factor along with other factors on the system performance is shown in Table 2: As it can be seen in Table 2, the model showed a good performance discriminating between damaged and undamaged gears. Despite the lowresolution cameras that were used like the 5 megapixels camera. Different image backgrounds were used during training, consequently; the model classified the object at a high level of certainty despite the different backgrounds, indicating even lesser effect than the camera resolution to no effect at all on the system classification capability. Image lighting showed some noticeable effect on the system accuracy with low-resolution images, in contrast to the high resolution images, where lighting showed less effect on the classification accuracy. The distance between the object and the camera was the last studied factor, in which the position of the image capturing device with respect to the position of the inspected object, affects the model accuracy to identify and distinguish between the objects.
In essence, the model classification accuracy is proportional to the camera resolution, lighting intensity and the distance, with zero effect from any used background. Compared to the lighting, the distance had more effect on the accuracy measures. Terms like good lighting and poor lighting refers to the intensity of the light source illumination and how much the object was obvious to the camera, as the better lighting provided the more certain the model would be. Good lighting (used lighting) was a minimum of 6.6Watt and poor lighting was below that minimum value.
Briefly stated, the table shows the system performance at its best at each resolution and at the farthest point.

Conclusions
In this paper, a transfer learning-based quality inspection system that was designed to inspect helical gears for faults, was evaluated under the effect of several environmental factors. Three cameras with differing resolutions were used to gather the evaluation data, which consisted of ten images at distances of 15cm and 10cm, different backgrounds and poor and good lighting intensities. The system showed good performance adapting to the different conditions, which conveyed the flexibility of the system and the power of CNNs. Also, this study implies the ability to build a quality inspection system at low costs as cheap setups can be sufficient to fulfil the system requirements.

Future Work
This work can be further expanded by studying the effect of the previously mentioned conditions on other gear sizes, evaluating the system on lower resolutions to test its limits, involving more environmental factors and study the model detection speed when deployed onto low-end devices. Moreover, the same study can be performed on the model when implemented on those devices.