Electronic component classification method, device, and storage medium
By using multiple neural network models and dynamic adjustment methods, the problem of insufficient data filtering capability in electronic component classification was solved, the model's ability to distinguish between good and defective products was improved, and the classification accuracy and efficiency were enhanced.
Patent Information
- Application Number
- CN202410242631.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-04
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-03-04
AI Technical Summary
Existing active learning data filtering methods have limited filtering capabilities in electronic component classification, resulting in poor model classification performance, especially in distinguishing between good and defective products. Furthermore, existing strategies fail to effectively optimize the characteristics of good and defective electronic components, leading to data class imbalance and poor performance of the model after training.
The main model and the sub-model are trained using various neural network models with different architectures (such as convolutional neural networks and Transformer neural networks). The sample sets are selected by the main model and the sub-model respectively, and the classification accuracy is improved by dynamically adjusting the model. The sample set is adjusted by combining the equilibrium value to ensure that the training set data is balanced.
The electronic component classification model has improved its ability to distinguish between good products and different types of defective products, thus increasing the accuracy of identification, reducing the recall rate of defective products and the false positive rate of good products, and achieving a more efficient classification effect.
Smart Images

Figure CN118115795B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing technology, and in particular relates to methods, equipment and storage media for classifying electronic components. Background Technology
[0002] In the specific task of detecting appearance defects in electronic components, data can be divided into two main categories: good products and defective products. The process of labeling data involves tagging the massive amount of unlabeled data from the production line as either good or defective products. This labeled data is then added to the model's training set. The training set is continuously expanded until the model is trained to the desired metrics. The model's metrics primarily consist of three aspects: the accuracy rate for all products, the recall rate for defective products, and the false positive rate for good products. This process is time-consuming, and the quality of the labeled data is highly unpredictable. Many low-value, similar data points are labeled and added to the training set, while the very few high-value data points are difficult to filter out.
[0003] Currently, some active learning data filtering methods can reduce manual costs in data labeling, such as minimum confidence-based filtering strategies and maximum entropy-based filtering strategies. However, these methods have limited filtering capabilities, and the overall performance of the model in classifying electronic components is poor. This results in insufficient ability and poor performance when the model classifies electronic components, and may even lead to errors. Summary of the Invention
[0004] This application provides a method, apparatus, and storage medium for classifying electronic components to improve the ability to comprehensively distinguish between good products and different types of defective products.
[0005] This application is achieved through the following technical solution:
[0006] In a first aspect, embodiments of this application provide a method for classifying electronic components, including:
[0007] Obtain images of electronic components with labeled categories and images of electronic components without labeled categories, and divide the labeled electronic component images into training set and test set.
[0008] Multiple different types of neural network models were trained based on the training set and the test set to obtain multiple electronic component classification models, which were then divided into main models and sub-models.
[0009] In the images of electronic components without labeled categories, a first preset number of samples are selected using the main model to obtain a first sample set; in the images of electronic components without labeled categories, a second preset number of samples are selected using the secondary model to obtain a second sample set; the samples in the first sample set and the samples in the second sample set are combined to obtain the target sample set.
[0010] Add the target sample set to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, classify the electronic components using the retrained main model; if the preset conditions are not met, return to the step of screening the first sample set.
[0011] In conjunction with the first aspect, in some possible implementations, the target sample set is added to the training set, the main model is retrained, and the classification accuracy of each category of the retrained main model is checked to see if it meets the preset conditions. If the preset conditions are met, the electronic components are classified using the retrained main model; if the preset conditions are not met, the process returns to the step of selecting the first sample set, including:
[0012] For each sample in the target sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0013] The number of samples in each category in the target sample set is counted, as well as the classification accuracy of the main model for each category.
[0014] The equilibrium value for each class is obtained by multiplying the number of samples in each class in the target sample set by the classification accuracy of the main model for each class.
[0015] Based on the equilibrium value of each category, supplement the target sample set with additional samples to obtain the target sample set after supplementation.
[0016] Add the target sample set after supplementing the samples to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, classify the electronic components using the retrained main model; if the preset conditions are not met, return to the step of screening the first sample set.
[0017] In conjunction with the first aspect, in some possible implementations, samples are supplemented into the target sample set based on the equilibrium value of each category to obtain a supplemented target sample set, including:
[0018] Find the maximum and minimum equilibrium values among all categories.
[0019] If the ratio of the minimum value to the maximum value is not a preset ratio, then samples of the same category as the minimum value will be added to the target sample set.
[0020] Calculate the product of the classification accuracy of the class corresponding to the minimum value of the main model and the number of samples of the class corresponding to the minimum value in the target sample set at this time. This yields a new equilibrium value for the class corresponding to the minimum value. The ratio of the new equilibrium value of the class corresponding to the minimum value to the maximum value is a preset ratio. The maximum value of the preset ratio is 1.
[0021] Jump to the step of finding the maximum and minimum equilibrium values of all categories, and repeat this step and subsequent steps until the ratio of the minimum to the maximum equilibrium values of all categories is a preset ratio, thus obtaining the target sample set after supplementing the samples.
[0022] In conjunction with the first aspect, in some possible implementations, the preset ratio is any ratio between 0.98 and 1.
[0023] In conjunction with the first aspect, in some possible implementations, a first sample set is obtained by selecting a first preset number of samples from unlabeled electronic component images using a primary model; and a second sample set is obtained by selecting a second preset number of samples from unlabeled electronic component images using a secondary model, including:
[0024] Obtain images of good products from the images of electronic components that have been categorized.
[0025] Input the good product image into the main model, query the feature vector of the good product image in the main model to obtain the first good product feature vector; input the good product image into the sub-model, query the feature vector of the good product image in the sub-model to obtain the second good product feature vector.
[0026] All images of electronic components without labeled categories are input into the main model. The feature vectors of each unlabeled electronic component image in the main model are queried to obtain multiple first feature vectors. All images of electronic components without labeled categories are input into the sub-model. The feature vectors of each unlabeled electronic component image in the sub-model are queried to obtain multiple second feature vectors.
[0027] Calculate the distance values between multiple first feature vectors and the first good product feature vector respectively to obtain multiple first distances; calculate the distance values between multiple second feature vectors and the second good product feature vector respectively to obtain multiple second distances.
[0028] Based on the magnitude of each first distance, the images of unlabeled electronic components are sorted in descending order, and the first preset number of images at the top of the sort are selected to obtain the first sample set.
[0029] Based on the magnitude of each second distance, the images of unlabeled electronic components are sorted in descending order, and the first few images in the sorted order are selected to obtain the second sample set.
[0030] In conjunction with the first aspect, some possible implementations include supplementing the target sample set with samples of the same class as the minimum equilibrium value of each class, including:
[0031] The images in the first and second sample sets are removed from the images of electronic components that have not been categorized to obtain the third sample set.
[0032] For each sample in the third sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0033] Select samples from the third sample set that belong to the same category as the minimum equilibrium value of each category, and add them to the target sample set.
[0034] In conjunction with the first aspect, some possible implementations also include adding the target sample set after supplementing the samples to the test set.
[0035] In conjunction with the first aspect, among some possible implementations, several neural network models include: convolutional neural networks and Transformer neural networks.
[0036] The main model is an electronic component classification model obtained by training a lightweight or medium-to-large-sized model in a convolutional neural network or a Transformer neural network based on the training and test sets.
[0037] The secondary model is a medium-to-large-sized model in a convolutional neural network or a Transformer neural network, which is trained based on the training set and the test set to obtain an electronic component classification model.
[0038] In a second aspect, embodiments of this application provide an electronic device, including: a processor and a memory, the memory being used to store a computer program, wherein the processor, when executing the computer program, implements the electronic component classification method as described in any of the first aspects.
[0039] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the electronic component classification method as described in any of the first aspects.
[0040] It is understood that the beneficial effects of the second and third aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.
[0041] The beneficial effects of the embodiments in this application compared with the prior art are:
[0042] The proposed solution uses multiple models with different architectures. A first sample set and a second sample set are selected through the main model and the sub-model, respectively. The first sample set and the second sample set are then combined to obtain the target sample set. The target sample set is added to the training set to update the main model and the sub-model. This process is repeated to train the main model until it meets the preset conditions. By using multiple models to identify the image category, the problem of poor category recognition ability of a single model is avoided, and the ability to comprehensively distinguish between good products and different types of defective products is improved.
[0043] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart illustrating an embodiment of the electronic component classification method provided in this application;
[0046] Figure 2 This is a flowchart of an electronic component classification method provided in another embodiment of this application;
[0047] Figure 3 This is a schematic diagram of the structure of an electronic component sorting device provided in an embodiment of this application;
[0048] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0050] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0051] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0052] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0053] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0054] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0055] Currently, there are some active learning data filtering methods that can reduce manual costs in data labeling, such as minimum confidence-based filtering strategies and maximum entropy-based filtering strategies. However, these methods have limited filtering capabilities, and the overall performance of the model in classifying electronic components is very poor.
[0056] Based on the above problems, the inventors considered the following issues: First, the current data screening strategies are fixed and rigid, unable to be dynamically adjusted according to the current screening results. Furthermore, existing mainstream strategies are based on the effectiveness verified by public datasets and do not optimize for the characteristics of good and defective electronic components. For example, in the production process of electronic components, the proportion of defective products is extremely low, and defective products are diverse, while good products are uniform. Existing strategies do not consider these characteristics, resulting in a severe imbalance in the data categories selected by existing strategies, leading to poor performance of the model after training. Second, existing screening strategies are basically based on features extracted from the data by a single model as important parameters for the screening strategy, but the capabilities of a single model are very limited. Considering the above two problems, this application provides an electronic component classification method. During the model training phase, a main model and a sub-model are trained separately. The main model and the sub-model simultaneously screen images to obtain the final result. In addition, the model itself is dynamically adjusted according to the current screening results to improve the model's ability to comprehensively distinguish between good products and different types of defective products. At the same time, the main model and the sub-model use different architectures, which avoids the shortcomings of a single-architecture model in extracting features from the data.
[0057] Figure 1 This is a schematic flowchart of an embodiment of the electronic component classification method provided in this application, with reference to... Figure 1 The detailed description of this electronic component classification method is as follows:
[0058] Step 101: Obtain images of electronic components with labeled categories and images of electronic components without labeled categories, and divide the images of electronic components with labeled categories into training set and test set.
[0059] Specifically, electronic components are categorized into several types, including good products, defective products with dimensional defects, defective products with roughness defects, and defective products with reflectivity defects. The category labeled on the image of an electronic component is the category of the electronic component in that image.
[0060] Specifically, the images of electronic components can be photographs taken on the production line using industrial cameras. The categorized images of electronic components can be a small set of data initially labeled after filtering using a clustering strategy.
[0061] Step 102: Train multiple different types of neural network models based on the training set and test set to obtain multiple electronic component classification models, and divide the multiple electronic component classification models into main models and sub-models.
[0062] For example, multiple neural network models may include convolutional neural networks and Transformer neural networks. The main model is an electronic component classification model obtained by training a lightweight or medium-to-large-sized model of a convolutional neural network or a Transformer neural network based on the training and test sets. The sub-model is an electronic component classification model obtained by training a medium-to-large-sized model of a convolutional neural network or a Transformer neural network based on the training and test sets.
[0063] Specifically, the main model can be: MobileNet (convolutional neural network architecture), EfficientNet (convolutional neural network architecture), ShuffleNet (convolutional neural network architecture), RepVGG (convolutional neural network architecture), or MobileViT (transformer neural network architecture). In practical applications, lightweight models of other convolutional neural network architectures or Transformer neural network architectures can also be used; there are no restrictions here.
[0064] The secondary models can specifically be: ResNet (convolutional neural network architecture), DenseNet (convolutional neural network architecture), ViT (Transformer neural network architecture), or Swin (Transformer neural network architecture). In practical applications, other medium-to-large-scale models using convolutional neural network architectures or Transformer neural network architectures can also be used; there are no restrictions here.
[0065] Specifically, the main model is set to a lightweight model to enable faster classification of electronic components and improve classification efficiency. However, in actual production applications, if efficiency is not a strict requirement, the main model can also be a medium to large model.
[0066] Specifically, in this scheme, there is one main model and multiple sub-models. When there are multiple sub-models, multiple second sample sets are obtained. The target sample set is then the union of the samples in the first sample set and the samples in the multiple second sample sets. The main model and sub-models use different architectures, avoiding the limitation of a single-architecture model having insufficient feature extraction capabilities.
[0067] Step 103: Select a first preset number of samples from the unlabeled electronic component images using the main model to obtain a first sample set; select a second preset number of samples from the unlabeled electronic component images using the secondary model to obtain a second sample set; and take the union of the samples in the first sample set and the samples in the second sample set to obtain the target sample set.
[0068] Specifically, the first preset number and the second preset number can be the same or different. In actual use, the first preset number and the second preset number are the same. There is no restriction on the value of the first preset number and the second preset number.
[0069] For example, a first preset number of samples are selected from images of electronic components without labeled categories using a primary model to obtain a first sample set; a second preset number of samples are selected from images of electronic components without labeled categories using a secondary model to obtain a second sample set.
[0070] Obtain images of good products from the images of electronic components that have been categorized.
[0071] The first good-quality product feature vector is obtained by inputting the good-quality product image into the main model and querying its feature vector within the main model. The second good-quality product feature vector is obtained by inputting the good-quality product image into the sub-model and querying its feature vector within the sub-model. The feature vector of the good-quality product image in the main model can be the embedding value in the main model after inputting the good-quality product image. The feature vector of the good-quality product image in the sub-model can be the embedding value in the sub-model after inputting the good-quality product image.
[0072] All images of unlabeled electronic components are input into the main model. The feature vectors of each unlabeled electronic component image in the main model are then retrieved, resulting in multiple first feature vectors. Similarly, all images of unlabeled electronic components are input into the sub-model. The feature vectors of each unlabeled electronic component image in the sub-model are then retrieved, resulting in multiple second feature vectors. The feature vectors of each unlabeled electronic component image in the main model can be considered as the corresponding embedding values in the main model after inputting the images into both the main and sub-models.
[0073] Calculate the distances between multiple first feature vectors and the first good product feature vector to obtain multiple first distances; calculate the distances between multiple second feature vectors and the second good product feature vector to obtain multiple second distances. The distances between the first feature vectors and the first good product feature vector can be either the Euclidean distance or the cosine similarity between the two feature vectors. Similarly, the distances between the second feature vectors and the second good product feature vector can be either the Euclidean distance or the cosine similarity between the two feature vectors.
[0074] Based on the magnitude of each first distance, the images of unlabeled electronic components are sorted in descending order, and the first preset number of images at the top of the sort are selected to obtain the first sample set.
[0075] Based on the magnitude of each second distance, the images of unlabeled electronic components are sorted in descending order, and the first few images in the sorted order are selected to obtain the second sample set.
[0076] Specifically, considering the limited sample data of defective products, which would lead to poor performance of the final model metrics (identification accuracy for all products, recall rate for defective products, and false positive rate for good products), a first distance and a second distance are calculated using the embedding values of samples in the main model and the sub-model. This allows for more targeted filtering of defective product sample data. The union of samples from the first and second sample sets is then used to obtain the target sample set. This target sample set is then added to the training set to appropriately increase the sample data of defective products, thereby improving the model's ability to filter various categories of electronic components and resulting in better model performance (higher identification accuracy, lower recall rate for defective products, and lower false positive rate for good products).
[0077] Step 104: Add the target sample set to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, the electronic components are classified by the retrained main model; if the preset conditions are not met, return to the step of screening the first sample set.
[0078] Specifically, verifying whether the classification accuracy of the main model for each category after retraining meets the preset condition means checking whether the classification accuracy of the main model for each category meets the preset condition. This preset condition can be whether the accuracy reaches 95%.
[0079] For example, step 104 may include:
[0080] For each sample in the target sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0081] The number of samples in each category in the target sample set is counted, as well as the classification accuracy of the main model for each category.
[0082] The equilibrium value for each class is obtained by multiplying the number of samples in each class in the target sample set by the classification accuracy of the main model for each class.
[0083] Based on the equilibrium value of each category, supplement the target sample set with additional samples to obtain the target sample set after supplementation.
[0084] Add the target sample set after supplementing the samples to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, classify the electronic components using the retrained main model; if the preset conditions are not met, return to the step of screening the first sample set.
[0085] Specifically, to facilitate understanding of this process, assume that the probability of sample a being inferred as category A by the main model is c1, the probability of sample a being inferred as category B by the main model is c2, and the probability of sample a being inferred as category C by the main model is c2; the probability of sample a being inferred as category A by the sub-model is c11, the probability of sample a being inferred as category B by the sub-model is c22, and the probability of sample a being inferred as category C by the sub-model is c33.
[0086] At this point, the sum of the probabilities of sample 'a' being inferred as class A by the main model and the sub-model is c1 + c11. Similarly, the sum of the probabilities of sample 'a' being inferred as class B by the main model and the sub-model is c2 + c22, and the sum of the probabilities of sample 'a' being inferred as class C by the main model and the sub-model is c3 + c33. Comparing c1 + c11, c2 + c22, and c3 + c33, if c1 + c11 is the largest, then sample 'a' is classified as class A. Following this logic, classifying all samples in the target sample set yields the number of samples in each class (n1, n2, and n3 for classes A, B, and C, respectively). Now, assuming the classification accuracy of the main model for each class is X1, X2, and X3, the equilibrium value for class A is X1*n1, for class B it is X2*n2, and for class C it is X3*n3. Then, samples are added to the target sample set based on the three equilibrium values.
[0087] Specifically, because this scheme supplements the target sample set with samples based on the equilibrium value, and the calculation of the equilibrium value incorporates the classification accuracy of each category of the main model, it allows for control over the number of samples in different categories. This avoids situations where one category has too many samples and another has too few, resulting in a more reasonable dataset. Consequently, the amount of data in each category in the training set is more balanced, preventing the main model from exhibiting severe skewness in its performance metrics. Severe skewness in the main model's performance metrics means that the main model has a high accuracy rate for one category but a low accuracy rate for another. Furthermore, in this process, the equilibrium value is obtained by multiplying the classification accuracy of each category of the main model by the number of samples in each category in the target sample set. This establishes a connection between the final recognition result of the main model and its own parameters, leading to better training of the main model and improved performance metrics (higher recognition accuracy, lower defective product recall rate, and lower good product false positive rate).
[0088] For example, based on the equilibrium value of each category, samples are added to the target sample set to obtain the target sample set after supplementation, including:
[0089] Find the maximum and minimum equilibrium values among all categories.
[0090] If the ratio of the minimum value to the maximum value is not a preset ratio, then samples of the same category as the minimum value will be added to the target sample set.
[0091] Calculate the product of the classification accuracy of the class corresponding to the minimum value of the main model and the number of samples of the class corresponding to the minimum value in the target sample set at this time. This yields a new equilibrium value for the class corresponding to the minimum value. The ratio of the new equilibrium value of the class corresponding to the minimum value to the maximum value is a preset ratio. The maximum value of the preset ratio is 1.
[0092] Jump to the step of finding the maximum and minimum equilibrium values of all categories, and repeat this step and subsequent steps until the ratio of the minimum to the maximum equilibrium values of all categories is a preset ratio, thus obtaining the target sample set after supplementing the samples.
[0093] For example, the preset ratio can be any ratio between 0.98 and 1.
[0094] Specifically, when the ratio between each equilibrium value is controlled between 0.98 and 1, the ratio of the number of data in each category in the training set can approach 1:1, thus constructing a more reasonable training set and improving the ability of the main model of this scheme to comprehensively distinguish between good products and different types of defective products.
[0095] Specifically, to facilitate understanding of the process of supplementing the target sample set with additional samples based on the equilibrium value of each category, and obtaining the target sample set after supplementation, let's refer to the example of calculating the equilibrium value above. Assume that the equilibrium value of category A (X1*n1 = 8.5, X1 = 85%, n1 = 10) is the smallest, the equilibrium value of category C is the largest (X3*n3 = 66.5, X3 = 95%, n3 = 70), and the equilibrium value of category B is X2*n2 = 18, X2 = 90%, n2 = 20. At this time, if we want the two equilibrium values to meet the preset ratio of 1, then we need to increase the value of n1. After calculation, the value of n1 after supplementation is 78.2. After rounding, n1 is 78. So, the number of category A samples that need to be supplemented is 68. After the supplementation, the equilibrium value for category A is 85% * 78 = 66.3. The minimum value at this point is the equilibrium value for category B. Similarly, the calculated value n² after supplementation is 74. Therefore, the number of category B samples that need to be supplemented is 54. When the ratios between all equilibrium values are within the preset proportions, the supplementation of samples in the target sample set is considered complete, resulting in the target sample set after supplementation.
[0096] Specifically, to improve the accuracy of the model's category recognition, after obtaining the target sample set with supplementary samples, the labeled categories of the samples can be re-determined through manual annotation. Then, the target sample set can be added to the training set to retrain the main model and the sub-model.
[0097] For example, supplementing the target sample set with samples of the same class as the minimum equilibrium value of each class includes:
[0098] The images in the first and second sample sets are removed from the images of electronic components that have not been categorized to obtain the third sample set.
[0099] For each sample in the third sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0100] Select samples from the third sample set that belong to the same category as the minimum equilibrium value of each category, and add them to the target sample set.
[0101] For example, the method may also include adding the target sample set after supplementing the samples to the test set.
[0102] Specifically, adding the target sample set after supplementing the samples to the test set can make the trained main model more accurate, make the main model more accurate in identifying the categories of electronic components, improve the category recognition accuracy of the main model, reduce the false positive rate of good products, and reduce the recall rate of defective products.
[0103] The above-mentioned electronic component classification method uses multiple models with different architectures. It selects a first sample set and a second sample set through a main model and a sub-model, respectively. The first sample set and the second sample set are then combined to obtain the target sample set. The target sample set is added to the training set to update the main model and the sub-model. This process is repeated to train the main model until it meets the preset conditions. By using multiple models to identify the image category, the method avoids the problem of poor category identification ability of a single model and improves the ability to comprehensively distinguish between good products and different types of defective products.
[0104] To facilitate understanding of the scheme in this application, combined with Figure 2 The specific implementation steps of this plan may include:
[0105] I. Images of electronic components captured by industrial cameras on the production line are labeled using clustering methods to obtain labeled electronic component images.
[0106] 2. Continuously collect images from subsequent industrial cameras to obtain a large number of unlabeled electronic component images (up to 100,000). Use the main model to filter these unlabeled electronic component images, obtaining the embedding value of the main model after inputting each category of unlabeled electronic component image into the main model. Simultaneously, obtain the embedding value of the main model after inputting the electronic component images labeled as "good" from step 1. For each category of unlabeled image, calculate the Euclidean distance or cosine similarity between the embedding value of the unlabeled image and the embedding value of the "good" image to obtain the first distance. Following the same logic, use the sub-model to calculate the Euclidean distance or cosine similarity between the embedding value of each category of unlabeled image and the embedding value of the "good" image to obtain the second distance. Then, based on the magnitude of multiple first distances, select a first sample set; based on the magnitude of multiple second distances, select a second sample set. Take the union of the first and second sample sets to obtain the target sample set, where the number of samples in the target sample set is set to 100. Then, the main model and the sub-model are used to reason about the samples in the target sample set to determine the category of each sample.
[0107] 3. Calculate the product of the number of samples in each category in the target sample set and the classification accuracy of each category in the main model to obtain the equilibrium value for each category.
[0108] Fourth, based on the equilibrium value calculated in step three, supplement the target sample set with additional samples to make the equilibrium value of each category in the target sample set approximately equal. In short, for categories with smaller equilibrium values, samples of the same category are inferred from unlabeled electronic component images (at this point, the unlabeled electronic component images no longer contain samples from the first sample set, nor from the second sample set) using the master model filter and added to the target sample set. The method for inferring sample categories here is consistent with the method in step two.
[0109] 5. To ensure the accuracy of sample labeling in the target sample set, professional personnel will manually label the samples before adding them to the training set. After the main model and sub-model are trained using the updated training set, check whether the main model's metrics meet the preset conditions. If not, repeat steps two through five until the main model's metrics meet the preset conditions. Then, use the main model with the preset conditions to classify the electronic components.
[0110] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0111] Corresponding to the electronic component classification method described in the above embodiments, Figure 3 A structural block diagram of the electronic component sorting device provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0112] See Figure 3 The electronic component classification device in this application embodiment may include: an acquisition module 201, a training module 202, a screening module 203, and a result output module 204.
[0113] The acquisition module 201 is used to acquire images of electronic components with labeled categories and images of electronic components without labeled categories, and to divide the images of electronic components with labeled categories into training set and test set.
[0114] Training module 202 is used to train multiple different types of neural network models based on training and test sets to obtain multiple electronic component classification models, and to divide the multiple electronic component classification models into main models and sub-models.
[0115] The filtering module 203 is used to filter out a first preset number of samples from unlabeled electronic component images using a main model to obtain a first sample set; to filter out a second preset number of samples from unlabeled electronic component images using a secondary model to obtain a second sample set; and to take the union of the samples in the first sample set and the samples in the second sample set to obtain a target sample set.
[0116] The result output module 204 is used to add the target sample set to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, the electronic components are classified by the retrained main model; if the preset conditions are not met, the process returns to the step of screening the first sample set.
[0117] The result output module 204 can also be used for:
[0118] For each sample in the target sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0119] The number of samples in each category in the target sample set is counted, as well as the classification accuracy of the main model for each category.
[0120] The equilibrium value for each class is obtained by multiplying the number of samples in each class in the target sample set by the classification accuracy of the main model for each class.
[0121] Based on the equilibrium value of each category, supplement the target sample set with additional samples to obtain the target sample set after supplementation.
[0122] Add the target sample set after supplementing the samples to the training set, retrain the main model and the sub-model, and check whether the classification accuracy of each category of the retrained main model meets the preset conditions. If the preset conditions are met, classify the electronic components using the retrained main model; if the preset conditions are not met, return to the step of screening the first sample set.
[0123] The result output module 204 can also be used for:
[0124] Find the maximum and minimum equilibrium values among all categories.
[0125] If the ratio of the minimum value to the maximum value is not a preset ratio, then samples of the same category as the minimum value will be added to the target sample set.
[0126] Calculate the product of the classification accuracy of the class corresponding to the minimum value of the main model and the number of samples of the class corresponding to the minimum value in the target sample set at this time. This yields a new equilibrium value for the class corresponding to the minimum value. The ratio of the new equilibrium value of the class corresponding to the minimum value to the maximum value is a preset ratio. The maximum value of the preset ratio is 1.
[0127] Jump to the step of finding the maximum and minimum equilibrium values of all categories, and repeat this step and subsequent steps until the ratio of the minimum to the maximum equilibrium values of all categories is a preset ratio, thus obtaining the target sample set after supplementing the samples.
[0128] For example, the preset ratio is any ratio between 0.98 and 1.
[0129] Filtering module 203 is also used for:
[0130] Obtain images of good products from the images of electronic components that have been categorized.
[0131] Input the good product image into the main model, query the feature vector of the good product image in the main model to obtain the first good product feature vector; input the good product image into the sub-model, query the feature vector of the good product image in the sub-model to obtain the second good product feature vector.
[0132] All images of electronic components without labeled categories are input into the main model. The feature vectors of each unlabeled electronic component image in the main model are queried to obtain multiple first feature vectors. All images of electronic components without labeled categories are input into the sub-model. The feature vectors of each unlabeled electronic component image in the sub-model are queried to obtain multiple second feature vectors.
[0133] Calculate the distance values between multiple first feature vectors and the first good product feature vector respectively to obtain multiple first distances; calculate the distance values between multiple second feature vectors and the second good product feature vector respectively to obtain multiple second distances.
[0134] Based on the magnitude of each first distance, the images of unlabeled electronic components are sorted in descending order, and the first preset number of images at the top of the sort are selected to obtain the first sample set.
[0135] Based on the magnitude of each second distance, the images of unlabeled electronic components are sorted in descending order, and the first few images in the sorted order are selected to obtain the second sample set.
[0136] The result output module 204 can also be used for:
[0137] The images in the first and second sample sets are removed from the images of electronic components that have not been categorized to obtain the third sample set.
[0138] For each sample in the third sample set, calculate the probability that the sample is inferred to be of each category by the main model, calculate the probability that the sample is inferred to be of each category by the sub-model, and for each category, calculate the sum of the probability that the sample is inferred to be of that category by the main model and the probability that the sample is inferred to be of that category by the sub-model to obtain the probability sum value for each category. The category corresponding to the maximum value among all probability sum values is taken as the category of the sample.
[0139] Select samples from the third sample set that belong to the same category as the minimum equilibrium value of each category, and add them to the target sample set.
[0140] The result output module 204 can also be used to add the target sample set after supplementing the samples to the test set.
[0141] Examples of neural network models include convolutional neural networks and Transformer neural networks.
[0142] The main model is an electronic component classification model obtained by training a lightweight or medium-to-large-sized model in a convolutional neural network or a Transformer neural network based on the training and test sets.
[0143] The secondary model is a medium-to-large-sized model in a convolutional neural network or a Transformer neural network, which is trained based on the training set and the test set to obtain an electronic component classification model.
[0144] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0145] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0146] This application also provides an electronic device, see [link to relevant documentation] Figure 4 The electronic device 300 may include at least one processor 310 and a memory 320, the memory 320 being used to store a computer program 321. The processor 310 is used to call and run the computer program 321 stored in the memory 320 to implement the steps in any of the above method embodiments, for example... Figure 1 Steps 101 to 104 in the illustrated embodiment. Alternatively, when the processor 310 executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 3 The functions of each module are shown.
[0147] For example, computer program 321 may be divided into one or more modules / units, one or more of which are stored in memory 320 and executed by processor 310 to complete this application. The one or more modules / units may be a series of computer program segments capable of performing specific functions, which describe the execution process of the computer program in electronic device 300.
[0148] Those skilled in the art will understand that Figure 4This is merely an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than shown, or combinations of certain components, or different components, such as input / output devices, network access devices, buses, etc.
[0149] The processor 310 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0150] The memory 320 can be an internal storage unit of the electronic device or an external storage device, such as a plug-in hard drive, a smart media card (SMC), a secure digital card (SD), or a flash card. The memory 320 is used to store the computer program and other programs and data required by the electronic device. The memory 320 can also be used to temporarily store data that has been output or will be output.
[0151] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0152] The electronic component classification method provided in this application can be applied to electronic devices such as computers, wearable devices, vehicle-mounted devices, tablet computers, laptop computers, and netbooks. This application does not impose any restrictions on the specific types of electronic devices.
[0153] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the various embodiments of the above-described electronic component classification method.
[0154] This application provides a computer program product that, when run on a mobile electronic device, enables the mobile electronic device to execute the steps described in the various embodiments of the electronic component classification method.
[0155] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-described embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a photographic device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0156] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0157] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0158] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0159] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0160] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for classifying electronic components, characterized in that, include: Obtain images of electronic components with labeled categories and images of electronic components without labeled categories, and divide the labeled electronic component images into training set and test set; Multiple neural network models of different types are trained based on the training set and the test set to obtain multiple electronic component classification models, and the multiple electronic component classification models are divided into main models and sub-models; From the images of electronic components without category labels, a first preset number of samples are selected using the main model to obtain a first sample set; From the images of electronic components without labeled categories, a second preset number of samples are selected using the sub-model to obtain a second sample set; the samples in the first sample set and the samples in the second sample set are combined to obtain the target sample set; The target sample set is added to the training set, the main model and the sub-model are retrained, and the classification accuracy of each category of the retrained main model is checked to see if it meets the preset conditions. If it meets the preset conditions, the electronic components are classified by the retrained main model. If it does not meet the preset conditions, the process returns to the step of filtering the first sample set. The steps of adding the target sample set to the training set, retraining the main model, and verifying whether the classification accuracy of each category of the retrained main model meets a preset condition are as follows: If the preset condition is met, the electronic components are classified using the retrained main model; if the preset condition is not met, the process returns to the step of filtering the first sample set. For each sample in the target sample set, calculate the probability that the sample is inferred to be a class by the main model, calculate the probability that the sample is inferred to be a class by the sub-model, and for each class, calculate the sum of the probability that the sample is inferred to be that class by the main model and the probability that the sample is inferred to be that class by the sub-model to obtain the probability and value corresponding to each class. The class corresponding to the maximum value among all probability and value is taken as the class of the sample. The number of samples in each category in the target sample set and the classification accuracy of the main model for each category are counted. The equilibrium value for each category is obtained by multiplying the number of samples in each category of the target sample set by the classification accuracy of each category of the main model. Based on the equilibrium value of each category, supplement the target sample set with additional samples to obtain the target sample set after supplementation. The target sample set after supplementing the samples is added to the training set, the main model and the sub-model are retrained, and the classification accuracy of each category of the retrained main model is checked to see if it meets the preset conditions. If it meets the preset conditions, the electronic components are classified by the retrained main model; if it does not meet the preset conditions, the process of filtering the first sample set is returned. Wherein, the supplementary target sample set obtained by adding samples based on the equilibrium value of each category to the target sample set includes: Find the maximum and minimum equilibrium values among all categories; If the ratio of the minimum value to the maximum value is not a preset ratio, then samples of the same category as the minimum value are added to the target sample set. The classification accuracy of the category corresponding to the minimum value of the main model is calculated by multiplying the number of samples of the category corresponding to the minimum value in the target sample set at this time, to obtain a new equilibrium value of the category corresponding to the minimum value, such that the ratio of the new equilibrium value of the category corresponding to the minimum value to the maximum value is the preset ratio; wherein, the maximum value of the preset ratio is 1; Jump to the step of finding the maximum and minimum equilibrium values among all categories, and repeat this step and subsequent steps until the ratio of the minimum to the maximum equilibrium values among all categories is the preset ratio, thus obtaining the target sample set after the supplementary samples.
2. The electronic component classification method as described in claim 1, characterized in that, The preset ratio is any ratio between 0.98 and 1.
3. The electronic component classification method as described in claim 1, characterized in that, The first sample set is obtained by filtering a first preset number of samples from the unlabeled electronic component images using the main model. From the images of unlabeled electronic components, a second preset number of samples are selected using the sub-model to obtain a second sample set, including: Obtain images of good products from the images of electronic components that have been labeled with their categories; The good product image is input into the main model, and the feature vector of the good product image in the main model is queried to obtain the first good product feature vector; the good product image is input into the sub-model, and the feature vector of the good product image in the sub-model is queried to obtain the second good product feature vector; All images of electronic components without labeled categories are input into the main model, and the feature vectors of each unlabeled electronic component image in the main model are queried to obtain multiple first feature vectors; all images of electronic components without labeled categories are input into the sub-model, and the feature vectors of each unlabeled electronic component image in the sub-model are queried to obtain multiple second feature vectors. Calculate the distance values between the plurality of first feature vectors and the first good product feature vector respectively to obtain a plurality of first distances; calculate the distance values between the plurality of second feature vectors and the second good product feature vector respectively to obtain a plurality of second distances; Based on the magnitude of each first distance, the images of the unlabeled electronic components are sorted in descending order, and the first preset number of images at the top of the sort are selected to obtain the first sample set. Based on the magnitude of each second distance, the images of the unlabeled electronic components are sorted in descending order, and the images with the highest sorting order are selected to obtain the second sample set.
4. The electronic component classification method as described in claim 3, characterized in that, The step of supplementing the target sample set with samples of the same category as the minimum value of the equilibrium value of each category includes: The images in the first and second sample sets are removed from the images of the unlabeled electronic components to obtain a third sample set; For each sample in the third sample set, calculate the probability that the sample is inferred to be a class by the main model, calculate the probability that the sample is inferred to be a class by the sub-model, and for each class, calculate the sum of the probability that the sample is inferred to be a class by the main model and the probability that the sample is inferred to be a class by the sub-model to obtain the probability and value corresponding to each class. The class corresponding to the maximum value among all probability and value is taken as the class of the sample. Select samples from the third sample set that belong to the same category as the minimum value of the equilibrium value of each category, and add them to the target sample set.
5. The electronic component classification method as described in claim 1, characterized in that, The method further includes: The target sample set after the supplementary samples are added to the test set.
6. The electronic component classification method as described in claim 1, characterized in that, The multiple neural network models include: convolutional neural networks and Transformer neural networks; The main model is an electronic component classification model obtained by training the convolutional neural network or a lightweight or medium-to-large model in the Transformer neural network based on the training set and the test set. The sub-model is an electronic component classification model obtained by training a medium-to-large-sized model in the convolutional neural network or the Transformer neural network based on the training set and the test set.
7. An electronic device, comprising: A processor and a memory, wherein the memory stores a computer program executable on the processor, characterized in that the processor, when executing the computer program, implements the electronic component classification method as described in any one of claims 1 to 6.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the electronic component classification method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Object surface pattern screening method based on artificial neural network
CN112683924A
