Abstract
To solve the problem that the presence of foreign matters in cosmetics will affect the safety and health of consumers and is not conducive to the development of the cosmetics industry, an intelligent identification system for foreign matters in cosmetics is established using the improved BP algorithm. Scan cosmetic samples to identify foreign matters and extract foreign matter features, so as to achieve non-destructive detection of foreign matters in cosmetics. Comparing the traditional BP algorithm, Faster R-CNN algorithm and the improved BP algorithm, the results show that the convergence time of the improved BP algorithm is 60 s and 30 s earlier than that of the traditional BP algorithm and Faster R-CNN algorithm respectively; Whether there is noise or not, the recognition rate of the improved BP algorithm is always higher than that of the traditional BP algorithm and Faster R-CNN algorithm. The accuracy rate of the improved BP algorithm is between 0.88 and 0.96, the accuracy rate of the traditional BP algorithm is between 0.57 and 0.75, and the accuracy rate of the Faster R-CNN algorithm is between 0.76 and 0.81. This shows that the improved BP algorithm can realize the nondestructive detection of foreign matters in cosmetics, ensure a high accuracy and fast speed, and provide consumers with a sense of safe use of cosmetics, it can also improve consumers’ satisfaction with the use of cosmetic products.
Keywords
Introduction
With the rapid development of social economy and the improvement of national living standards, cosmetics are used by more and more people and scenarios, and the functional requirements and quality requirements of cosmetics are also getting higher and higher [1]. However, foreign objects still exist in some cosmetic products, which is not only detrimental to the health of consumers, but also has a bad impact on the reputation of cosmetic companies, and thus is detrimental to the long-term development of the cosmetic industry, so identifying foreign objects in cosmetic products has become an urgent problem to be solved. Object recognition generally involves two main elements: extraction of features and recognition, where BP neural networks take a non-linear computational approach to object recognition, and the former process of extracting features is relatively much simpler compared to traditional recognition models [2]. BP algorithm can solve many problems existing in neural networks, improve the recognition rate and convergence speed, which is of great help to intelligent object recognition and nondestructive testing, and has been widely used in the field of object recognition [3]. Therefore, the intelligent recognition of cosmetic foreign objects will be studied on the basis of the improved BP algorithm to achieve nondestructive detection of cosmetics, with a view to improving consumer satisfaction in the use of cosmetic products and providing consumers with more safe cosmetics.
Related works
The BP algorithm calculates the network weights through the reactive transfer of errors, which makes the BP neural network have a good recognition rate and fast convergence speed, and can achieve nondestructive detection. Therefore, the algorithm and neural network are widely used in many intelligent recognition fields. Many scholars combine BP algorithm and neural network to discuss the relevant content of intelligent recognition, and have made many research achievements.
Wei and Wang [4] proposed an improved BP neural network for robot target detection and recognition in order to improve the accuracy and effectiveness of robot target detection and recognition, and the experimental results showed that the improved algorithm has a high recognition rate and accuracy in a noisy environment. The experimental results show that the improved neural network has a high accuracy and stability, and can effectively detect the abnormalities in the rotary table of the roadheader, which has high application value [5]. Zhang et al. [6] constructed an improved BP neural network in order to solve the problem of timely recognition of current sea conditions. In order to solve the problem of timely recognition of current sea state to ensure navigation safety, a data-driven model optimized using genetic algorithm was constructed, and the experimental results showed that the intelligent sea state recognition model could accurately recognize real-time sea state. Liu [7] proposed an improved BP neural network algorithm for the current problem of poor recognition and analysis processing of motion brain computer signals, and combined with particle swarm filtering algorithm for intelligent training, and the experimental results showed that the proposed algorithm improved the accuracy of motor imagery EEG signal recognition. Hu [8] designed an improved BP neural network-based recognition algorithm to improve the accuracy of banknote recognition, denoising and graying the banknote image, and locating characters and extracting features, and experimental results showed that the improved algorithm had higher accuracy in data acquisition and recognition.
Wang et al. [9] designed a wavelet transform-based recognition algorithm and combined it with an improved BP neural network for character recognition to address the problem of low recognition rate and accuracy of traditional license plate recognition methods, and the experimental results showed that the combination of the two algorithms could greatly improve the accuracy of license plate recognition. The experimental results showed that the neural network has higher accuracy and better stability in load recognition [10]. Problem, designed a neural network-based CAPTCHA recognition algorithm, and the experimental results showed that the algorithm could improve the recognition accuracy of individual letters [11]. Zhang et al. [12] designed a data measurement and classification model based on information entropy and BP neural network in order to solve the privacy protection problem of data in the power IoT, and the experimental results showed that the model can accurately measure and classify data. Zhu et al. [13] designed a machine vision image acquisition system in order to identify the gender of eggs at the early stage of hatching, and combined genetic algorithm to optimise the initial values in the inverse direction propagation neural network in the implicit layer, and the experimental results showed that the system can improve the recognition accuracy.
Shi et al. [14] proposed a new method of signal reconstruction and combined with BP neural network for lung sound recognition in order to improve the efficiency and accuracy of lung sound feature extraction and recognition, and the experimental results showed that the new method could improve the accuracy of recognition. Cui et al. [15] established a mathematical model to evaluate the uncertainty of simultaneous determination of lead, cadmium and arsenic in cosmetics by microwave elimination inductively coupled plasma mass spectrometry, and evaluated the sources and components of the uncertainty. The experimental results showed that the main factors affecting the evaluation results were the quality of stone standard, calibration curve, recovery rate and measurement repeatability. In order to discuss the safety of cosmetics, Jiang [16] conducted research from three stages of cosmetics research and development, production and sales to promote cosmetics safety and risk management. Zhang et al. [17] compared the new and old rules and regulations on cosmetics, summarized the main changes in cosmetics safety supervision, and obtained important laws and regulations on cosmetics safety and risk assessment and new in vitro testing methods.
The above is a study on the intelligent recognition of foreign bodies by scholars from different fields combined with BP neural networks, and it can be seen that BP neural networks have a good accuracy rate for the intelligent recognition of foreign bodies. In view of the fact that the presence of foreign bodies in cosmetic products can cause great harm, this study will carry out non-destructive testing for the intelligent identification of foreign bodies in cosmetic products to improve the safety of cosmetic products.
BP algorithm-based intelligent recognition model for cosmetic foreign objects
Optimal design of the BP algorithm
The BP algorithm (Back-propagation Algorithm) uses several learning rules to adapt the connection weights between neurons, which is characterized by clear reasoning, rigorous structure, stable operating conditions, and ease of use, and can solve a large number of problems faced by many neural networks and is expected to be widely used in the field of object recognition [18]. The BP network is a one-way transfer and multilayer forward neural network designed on the basis of BP algorithm, which has the advantages of simple structure, advanced algorithm and intensive optimization, etc. The use of BP neural network for object recognition has high application value. Its model is shown in Fig. 1.
BP neural network model.
From Fig. 1, it can be seen that the BP network has a three-layer structure of input layer, implicit layer and output layer, which has an extremely strong non-linear mapping capability and a flexible network structure. The information in this network structure is transmitted in a forward mode and the errors are backward propagated, and after several cycles, the input gradually approaches the expected result and the learning operation is completed [19]. The most significant elements of the learning operation include long-phase transfer and back propagation, and result in a minimum value of the mean square of the error between the expected result and the actual output. There is no designated connection between any layer of neurons, but the upper and lower layers can be seamlessly connected, and once a pair of learning test bodies is entered into the network, the command to activate the neuron is passed from the output layer to the output layer, and in the process the input response to that network is obtained. The reversal then corrects the connection weights from the output layer, passing them layer by layer to the input layer, and is able to reduce the actual error. The continuous correction of the inverse transmission of errors results in an increasing accuracy of the network response to the input pattern [20]. Assume that an arbitrary network has
In Eq. (1),
In Eq. (2),
Equation (3),
If
If
The above formula enables to obtain:
When the BP network has
In Eq. (8),
BP algorithm flow chart.
Figure 2 shows the flowchart of the BP algorithm. From the figure, it can be seen that the expected output value is first formulated, then the input and expected output are initialised, after which all the weight coefficients and thresholds are top set; subsequently, the actual output value of each layer of nodes is calculated and the error between the actual output value and the expected output value is solved. If the error obtained from the solution meets the accuracy requirements, the algorithm can be ended; if not, the weight coefficients need to be adjusted, the actual output is calculated again and the error value is solved until the error meets the accuracy requirements.
The BP algorithm converges slowly and tends to fall into local minima. To improve these problems, the BP algorithm is improved by first adding a momentum term after any of the weight adjustment quantities
As a result, it is possible to reduce the tendency of oscillations in the learning operation and allows for an optimisation of convergence. Secondly, the correction of the weights using the conjugate gradient method does not require the calculation of the second order gradient, but has the advantage of its faster convergence [21]. The error function was then corrected using the regularisation method, where the original error function is shown in Eq. (10):
In Eq. (10),
In Eq. (11),
The above equation shows that the use of the new performance indicator function ensures that the network training process has fewer effective weights, i.e. it reduces the size of the network. Subsequently increasing the resilience of the BP algorithm, when
In Eq. (13), the product of the two bias error derivatives before and after is expressed as:
Thus, enabling the calculation of the weighting correction values.
In this way, it is possible to calculate the correction weights.
When the weights in the BP network have oscillatory behaviour, the change of their weights will decrease. If the direction of change of the weights is the same in several successive iterations, the change of the weights will become faster and therefore its convergence speed is faster. At the same time, the learning rate can be adjusted appropriately to improve the speed of convergence on the flat and undulating parts of the error surface.
Considering that many characteristic parameters of known foreign object categories can be obtained through samples, the neural network trained with parameters can achieve the purpose of intelligent classification, an artificial neural network model is built by applying a multilayer feedforward network in BP networks and using a supervised model for foreign object recognition [23]. The cosmetic foreign body classifier uses a multi-output type three-layer network structure, that is, an input layer, an implicit layer and an output layer. The input layer contains the features of cosmetic foreign objects and the output layer contains the classification of cosmetic foreign objects, so the number of nodes in the input and output layers can be determined easily and quickly by the actual problem. Since the number of nodes in the implicit layer depends on the performance of the whole neural network, the number of nodes in the implicit layer needs to be calculated using the empirical formula.
In Eq. (17),
System function module composition diagram.
As can be seen from Fig. 3, the system mainly consists of three parts: image pre-processing, target image feature processing, and intelligent recognition of foreign object types. Firstly, the cosmetic sample is scanned, and the scanned sample image is enhanced, then the row grey scale curve is processed, as well as the boundary of the cosmetic sample is extracted to complete the image pre-processing operation. Based on the row grey scale curve, if the curve has a large undulation, then the features can be extracted directly; if the curve has a small undulation, then the edges of the foreign object need to be detected again first, and then the features can be extracted after the region has grown, thus completing the feature processing of the target image and obtaining the judgement result of the cosmetic foreign object. Combined with the feature vector of the cosmetic sample, the intelligent recognition of the cosmetic foreign body can be completed. Subsequently, a deeper operation is required to determine the specific location of the cosmetic foreign body and its characteristics. The non-destructive detection process of the cosmetic foreign body intelligent identification system is shown in Fig. 4.
Flow chart of intelligent detection of foreign bodies in cosmetics.
As can be seen from Fig. 4, the intelligent recognition system extracts the content including the cosmetic boundary, the edge of the foreign body and the features of the foreign body, which in turn enables the accurate recognition of the foreign body type. When the row grey curve is undulating, it can determine that the cosmetic contains foreign objects and extract the features of foreign objects; when the row grey curve is smooth, the edges of foreign objects need to be extracted, if the edges of foreign objects can be extracted, the features of foreign objects can be further extracted, if the edges of foreign objects are not extracted, it means that the cosmetic does not contain foreign objects [24]. Where feature extraction refers to the elimination of invalid information from the original data input based on the features of the sample and the compression of valid information, and finally the optimized classifier is obtained. Among them, image features are manifested as obvious changes in grey-scale values, and having features indicates that there is more information content in the local area, so extracting image features means the extraction of valid information. At the same time, in order to be able to conduct a comprehensive inspection of the inspected cosmetics, it should be ensured that the outer size of the inspected cosmetics is smaller than the size of the detector, in this process, the cosmetic boundary needs to be extracted using the grey-scale threshold segmentation method to ensure the accuracy of the boundary [25]. Since the grey-scale histogram of the image has many variations in shape, the maximum variance automatic thresholding method is generally used for the selection of the thresholds.
The BP algorithm and its neural network are used to establish a simulation model for intelligent recognition of foreign bodies in cosmetics, and the results of non-destructive testing are obtained. In order to compare the results of intelligent recognition of foreign bodies in cosmetics by the proposed algorithm, Faster R-CNN algorithm is added in the experiment process, which also has good performance in feature extraction. And compared with the traditional BP algorithm and the improved BP algorithm. The parameter settings of the simulation model are shown in Table 1.
System parameter
System parameter
Table 1 shows that the memory is 512 Mb, the operating system is Windows XP, the programming tool is Python, the working voltage is 220 V, and the maximum inspection size is 500 mm
Line gray curve.
In Fig. 5, subfigure (a) and subfigure (c) represent the row grey scale curves without and with foreign matter respectively, subfigure (b) and subfigure (d) represent the enlarged part of the black box area in the curves of subfigure (a) and subfigure (c) respectively. When there is a large float in the row grey scale curve, it generally indicates that a denser foreign body is present at the float. The left and right sides of the black boxed area in subplots (a) and (c) are the blank space between the test bench and the cosmetic being examined, rather than the undulation caused by the presence of the foreign body; and the cosmetic in subplot (c) also has multiple rows of undulation. (d) shows a large undulation in the grey curve of the rows of the cosmetic, indicating the presence of a foreign body in subfigure (c).
In order to save experimental time and cost, the adaptive learning rate momentum gradient descent back propagation method is used in the experiment process, and the traditional BP algorithm, Faster R-CNN algorithm and the improved BP algorithm are respectively used to monitor the cosmetic foreign matters, and the training error curves of the two algorithms are obtained, as shown in Fig. 6.
Error curve obtained by three algorithms.
In Fig. 6, the green curve represents the error curve obtained from traditional BP algorithm training, the orange curve represents the error curve obtained from Faster R-CNN algorithm training, the red curve represents the error curve obtained from improved BP algorithm training, and the blue line represents the target curve. It can be seen from the figure that the error curves obtained by the three algorithms gradually converge to the target curve. The traditional BP algorithm converges in 100 s, the Faster R-CNN algorithm converges in 70 s, and the improved BP algorithm converges in 40 s. That is, compared with the traditional BP algorithm, the convergence time of the improved BP algorithm is 60 s earlier and the convergence rate is 150% higher. Compared with Faster R-CNN algorithm, the improved BP algorithm has a convergence time of 30 s and a convergence rate of 75%. It shows that the improved BP algorithm effectively improves the convergence speed of the neural network, and also shortens the running time of the neural network. It shows that the improved BP algorithm has a very effective effect in the identification of foreign objects in cosmetics.
Since there is noise in the foreign object intelligent recognition process, which in turn has an impact on the recognition rate of the algorithm, the intelligent recognition rate of the cosmetic foreign objects of the two algorithms in noisy and noiseless environments will be compared. Firstly, all factors that may be noisy in the intelligent recognition process are eliminated, so that the whole system is kept quiet and the recognition rates of the three algorithms in a noise-free environment are obtained as shown in Fig. 7.
Recognition rate of three algorithms in noiseless environment.
In Fig. 7, the orange column represents the recognition rate of foreign matters in cosmetics by traditional BP algorithm, the purple column represents the recognition rate of foreign matters in cosmetics by Faster R-CNN algorithm, and the green column represents the recognition rate of foreign matters in cosmetics by improved BP algorithm. It can be seen from Fig. 7 that in a noiseless environment, the improved BP algorithm has a higher recognition rate of foreign bodies in cosmetics than 96%, the traditional BP algorithm has a higher recognition rate of foreign bodies in cosmetics than 86%, and the Faster R-CNN algorithm has a higher recognition rate of foreign bodies in cosmetics than 92%, indicating that the three algorithms have higher recognition rates of foreign bodies in cosmetics in a noiseless environment. However, the recognition rate of the improved BP algorithm for cosmetics is significantly higher than that of the traditional BP algorithm and Faster R-CNN algorithm for cosmetics. At the same time, the standard deviation of the three algorithms is less than 3%, indicating that the recognition rate of the system has a certain accuracy. Take a cosmetic sample as an example, add Gaussian noise to it and extract it as object features. The parameters of the three algorithms and the experimental environment conditions are consistent. The recognition rates of the three algorithms under different noise variances are shown in Fig. 8.
Recognition rate of three algorithms in noisy environment.
In Fig. 8, the orange column represents the recognition rate of foreign matters in cosmetics by traditional BP algorithm, the purple column represents the recognition rate of foreign matters in cosmetics by Faster R-CNN algorithm, and the green column represents the recognition rate of foreign matters in cosmetics by improved BP algorithm. It can be seen from Fig. 8 that the recognition rate of the three algorithms for foreign objects in cosmetics decreases with the increase of noise; When the noise variance is 4, the recognition rate of the improved BP algorithm is 9.9% higher than that of the traditional BP algorithm, and the recognition rate of the improved BP algorithm is 5.1% higher than that of the Faster R-CNN algorithm; When the noise variance is 16, the recognition rate of the improved BP algorithm is 9.8% higher than that of the traditional BP algorithm, and the recognition rate of the improved BP algorithm is 7.8% higher than that of the Faster R-CNN algorithm; When the noise variance is 64, the recognition rate of the improved BP algorithm is 9.7% higher than that of the traditional BP algorithm, and the recognition rate of the improved BP algorithm is 4.8% higher than that of the Faster R-CNN algorithm. It shows that under the noise environment, the recognition rate of the improved BP algorithm for foreign matters in cosmetics is always higher than that of the traditional BP algorithm and Faster R-CNN algorithm. And the standard deviation of the recognition rate of the algorithm in the three noise environments is within 3%, which further shows that the recognition rate of the system is highly referential. At the same time, it can be seen that whether there is noise or not, the recognition rate of the improved BP algorithm for foreign objects in cosmetics is always higher than that of the traditional BP algorithm and Faster R-CNN algorithm.
A high recognition rate is only one indication of the effectiveness of the system, but the accuracy rate of foreign body recognition also needs to be verified to ensure the value of the intelligent recognition system. The accuracy rates of the three algorithms during the recognition of cosmetic foreign objects were collected and listed for five cosmetic samples, the results of which are shown in Fig. 9.
Accuracy of two algorithms for foreign object recognition.
In Fig. 9, the green line represents the accuracy of the traditional BP algorithm for foreign object recognition, the orange line represents the accuracy of Faster R-CNN algorithm for foreign object recognition, and the blue line represents the accuracy of the improved BP algorithm for foreign object recognition. It can be seen from Fig. 9 that for five cosmetics samples, the accuracy of the traditional BP algorithm is between 0.57 and 0.75, the accuracy of the Faster R-CNN algorithm is between 0.76 and 0.81, and the accuracy of the improved BP algorithm is between 0.88 and 0.96, that is, the accuracy of the improved BP algorithm is significantly higher than that of the traditional BP algorithm and the Faster R-CNN algorithm. It shows that the improved BP algorithm can accurately and quickly identify foreign matters in cosmetics.
In recent years, people’s living standards have improved significantly, and people’s consumption type has gradually changed to enjoyment consumption. At the same time, with more and more types of cosmetics, people pay more and more attention to the use safety of cosmetics. The presence of foreign matters will greatly affect the use safety of cosmetics, so detecting and identifying foreign matters in cosmetics has become an important task. This research combined with the improved BP algorithm to build an intelligent recognition system for foreign objects in cosmetics, which can detect foreign objects according to the line gray curve and extract effective information. The experimental results show that the traditional BP algorithm, Faster R-CNN algorithm and the improved BP algorithm can converge in a fast time. Compared with the traditional BP algorithm and Faster R-CNN algorithm, the improved BP algorithm has a convergence rate of 150% and 75% respectively. The recognition rate of the three algorithms decreases with the increase of noise; In the presence or absence of noise, the recognition rate of the improved BP algorithm for foreign objects in cosmetics is always higher than that of the traditional BP algorithm and Faster R-CNN algorithm. At the same time, the accuracy of the improved BP algorithm is also significantly higher than that of the traditional BP algorithm and Faster R-CNN algorithm. It shows that the cosmetic foreign body intelligent recognition system based on the improved BP algorithm can realize the non-destructive detection of foreign bodies in cosmetics, and at the same time ensure a high accuracy, providing a certain reference value for foreign body detection in the cosmetics industry.
