Unknown element detection method and device, electronic equipment and storage medium
By combining iterative training of known and unknown class image features, automated unknown component detection is achieved, solving the problems of low unknown component detection efficiency and poor accuracy in the existing technology, and improving product quality and detection accuracy.
Patent Information
- Application Number
- CN202410487651.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2024-08-23
AI Technical Summary
Existing target detection and classification algorithms cannot effectively detect targets of unknown categories outside the training set, causing unknown components to be mistaken for background or given a very low confidence level, resulting in product quality hazards, and the manually driven process is inefficient and biased.
By obtaining the image to be detected, the component detection model is input to screen candidate components, and the image of the target component is input into the classification model for classification. During the training process, the image features of known classes and unknown classes are combined, and the classification model is iteratively updated to detect known classes and Unknown class component.
Automatic and accurate detection of unknown components is achieved, reducing manual intervention, improving product quality and detection accuracy, and reducing the detection complexity of the production line.
Smart Images

Figure CN118537529A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to a method, device, electronic device and storage medium for detecting unknown components. Background Art
[0002] Existing target detection and classification algorithms are usually unable to effectively detect unknown category targets outside the training set, and will treat them as background or give extremely low confidence output. When the production line changes, the traditional practice is to rely on manual identification and collection of component image samples of unknown categories, and then the algorithm personnel will retrain the model based on these new data. This manually driven process is not only inefficient and time-consuming, but also has deviations between manual judgment and algorithm judgment. For example, due to a partial change in the product structure caused by a material change, the worker will know that this belongs to a known component due to prior knowledge, but the algorithm will regard it as a new category.
[0003] In the production process, if unknown components are ignored by the current algorithm, related defects will be missed, which will cause hidden dangers to product quality. Therefore, it is crucial to automatically identify unknown components, quickly collect data and update algorithm models to ensure product quality. In summary, there is an urgent need for a technical solution that can automatically and accurately detect unknown components. Summary of the invention
[0004] The present application provides a method, device, electronic device and storage medium for detecting unknown components, so as to provide a technical solution for automatically and accurately detecting unknown components.
[0005] In a first aspect, the present application provides a method for detecting an unknown component, the method comprising:
[0006] Acquire a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out a target component according to the detection confidence of each candidate component;
[0007] Inputting the second image corresponding to the target component into a component classification model, and determining a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category;
[0008] The training process of the component classification model includes:
[0009] During the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the current training is completed, the unknown class image features are generated according to the first sample component image; and the next component classification model training is performed based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0010] In a second aspect, the present application provides an unknown component detection device, the device comprising:
[0011] A screening module, used for acquiring a first image to be detected, inputting the first image into a component detection model, detecting each candidate component in the first image based on the component detection model, and screening out a target component according to the detection confidence of each candidate component;
[0012] A determination module, configured to input the second image corresponding to the target component into a component classification model, and determine a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category;
[0013] The training module is used to input the first sample component image of the labeled category in the training set into the component classification model to be trained at that time during each iterative training process; after the training is completed at that time, generate unknown class image features according to the first sample component image; and perform the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0014] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0015] Memory, used to store computer programs;
[0016] The processor is used to implement the method steps when executing the program stored in the memory.
[0017] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described are implemented.
[0018] The present application provides a method, device, electronic device and storage medium for detecting unknown components. The method comprises: acquiring a first image to be detected, inputting the first image into a component detection model, detecting each candidate component in the first image based on the component detection model, and screening out a target component according to the detection confidence of each candidate component; inputting a second image corresponding to the target component into a component classification model, and determining a target category of the target component based on the component classification model; wherein the target category comprises a labeled category or an unlabeled category; wherein the training process of the component classification model comprises: in an iterative training process, inputting a first sample component image of a labeled category in a training set into the component classification model to be trained at that time; after the training is completed at that time, generating an unknown class image feature according to the first sample component image; and performing the next component classification model training based on the known class image feature corresponding to the first sample component image and the generated unknown class image feature.
[0019] The above technical solution has the following advantages or beneficial effects:
[0020] In the present application, firstly, based on the component detection model, each candidate component in the first image to be detected is detected, and the detection confidence of each candidate component is detected according to the component detection model, and the target component is screened out. Then, based on the component classification model, the target category of the target component is determined, wherein the target category includes a labeled category or an unlabeled category. When training the component classification model, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time, and the component classification model of that time is trained. After the training is completed at that time, the unknown class image feature is generated according to the first sample component image; and the next component classification model training is performed based on the known class image feature corresponding to the first sample component image and the generated unknown class image feature. In this way, in the subsequent iteration process, the component classification model is trained based on the known class image feature and the generated unknown class image feature. Since the known class image feature and the generated unknown class image feature are combined in the training component classification model, the component classification model finally trained has the ability to detect known class components and unknown class components, so the target category of the target component is determined based on the component classification model. Thereby, automatic and accurate detection of unknown components is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1A schematic diagram of the unknown component detection process provided for this application;
[0023] Figure 2 A schematic diagram of the unknown component detection process provided for this application;
[0024] Figure 3 A schematic diagram of the unknown component detection process provided for this application;
[0025] Figure 4 A schematic diagram of the training process of the component classification model provided in this application;
[0026] Figure 5 A schematic diagram of the training process of the component classification model provided in this application;
[0027] Figure 6 A schematic diagram of the training process of the component classification model provided in this application;
[0028] Figure 7 Schematic diagram of the standard images provided for this application;
[0029] Figure 8 Schematic diagram of the measured images provided for this application;
[0030] Fig. 9 The unknown component detection architecture diagram provided for this application;
[0031] Fig.10 The overall flow chart of unknown component detection provided by this application;
[0032] Fig.11 Schematic diagram of the resnet34 network structure provided for this application;
[0033] Fig.12 Schematic diagram of high-dimensional hidden layers provided for this application;
[0034] Fig.13 Decision diagram of the classifier provided for this application;
[0035] Fig.14 A schematic diagram of the structure of the unknown component detection device provided in this application;
[0036] Fig.15 This is a schematic diagram of the electronic device structure provided in this application. DETAILED DESCRIPTION
[0037] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0038] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0039] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0040] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0041] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0042] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0043] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
[0044] Figure 1 A schematic diagram of the unknown component detection process provided in this application, the process includes the following steps:
[0045] S101: During the iterative training process, a first sample component image of a labeled category in a training set is input into a component classification model to be trained at that time; after the training is completed, an unknown class image feature is generated according to the first sample component image; and the next component classification model training is performed based on the known class image feature corresponding to the first sample component image and the generated unknown class image feature.
[0046] S102: Acquire a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out target components according to the detection confidence of each candidate component.
[0047] S103: Inputting the second image corresponding to the target component into a component classification model, and determining a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category.
[0048] The unknown component detection method provided in the present application is applied to an electronic device, which may be a PC, a tablet computer, or a server.
[0049] A trained component detection model is deployed in the electronic device, and the component detection model is used to detect each component in the image. After the image containing the component is input into the component detection model, the component detection model outputs the detection confidence corresponding to each component in the image. The training process of the component detection model can be: inputting the sample image containing the component and the corresponding component annotation information into the component detection model to be trained, the component annotation information includes the category information and position information of the component; the component detection model to be trained outputs the predicted category information and predicted position information of the component in the sample image, and the loss value is calculated based on the predicted category information and predicted position information, as well as the annotated category information and position information, and the parameters of the component detection model to be trained are trained based on the loss value.
[0050] The electronic device obtains the first image to be detected. The first image can be a standard image on a PCBA board (short for Printed Circuit Board + Assembly, also called a circuit board) or a measured image on a PCBA board. In the preparation stage for production change, employees will intervene in the AOI equipment (short for Automatic Optic Inspection, automatic optical inspection equipment) to set some parameters related to the new production, and use a high-precision industrial scanning camera to collect an image on a normal PCBA board as a standard image. In the actual production process, the measured image on the produced PCBA board is collected in real time. The standard image and the measured image are traversed in a sliding window manner to obtain a partial image pair. By comparing the partial image with the standard image, it is determined whether there are ten major types of defects such as missing parts, offset, missed detection, and polar reversal on the measured image.
[0051] After the electronic device acquires the first image, the first image is input into the trained component detection model, and the detection confidence of each candidate component in the first image is determined based on the component detection model, and the target component is screened out according to the detection confidence of each candidate component. Optionally, the candidate component with a detection confidence in the interval [0.01, 0.25] is selected as the target component.
[0052] The electronic device is deployed with a trained component classification model, which is used to determine the target category of the target component. The target category includes a labeled category or an unlabeled category, and the component of the unlabeled category is an unknown component. The training process of the component classification model includes: in the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the training is completed, the unknown class image feature is generated according to the first sample component image; and the next component classification model training is performed based on the known class image feature corresponding to the first sample component image and the generated unknown class image feature.
[0053] During the first training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; the component classification model to be trained at that time extracts features of the first sample component image to obtain known class image features, and determines the predicted category of the first sample component image based on the known class image features; the loss value is determined based on the predicted category and the labeled category, and the parameters of the component classification model to be trained at that time are updated based on the loss value. Based on the model after the first training is completed, the unknown class image features are generated according to the first sample component image.
[0054] During the second training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; the component classification model to be trained at that time performs feature extraction on the first sample component image to obtain known class image features; and the prediction categories corresponding to the known class image features and the unknown class image features generated after the first training are respectively determined according to the component classification model to be trained at that time. According to the prediction categories corresponding to the known class image features and the unknown class image features generated after the first training are completed, and the labeled categories corresponding to the known class image features and the unknown class image features generated after the first training are completed, the loss value is determined, and the parameters of the component classification model to be trained at that time are updated according to the loss value. Based on the model after the second training is completed, the unknown class image features are generated according to the first sample component image. The labeled categories corresponding to the known class image features and the unknown class image features generated after the first training can be: the labeled category information corresponding to the known class image features is: the probability of the real known category is 1, the probability of the non-real known category is 0, and the probability of the unknown category is between 0 and 1; the labeled category information corresponding to the unknown class image features is: the probability of the unknown category is 1, and the probability of the known category is 0.
[0055] During the third training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; the component classification model to be trained at that time performs feature extraction on the first sample component image to obtain known class image features; and the prediction categories corresponding to the known class image features and the unknown class image features generated after the second training are determined according to the component classification model to be trained at that time. According to the prediction categories corresponding to the known class image features and the unknown class image features generated after the second training, and the labeled categories corresponding to the known class image features and the unknown class image features generated after the second training, the loss value is determined, and the parameters of the component classification model to be trained at that time are updated according to the loss value. Based on the model after the third training, the unknown class image features are generated according to the first sample component image. In this way, the component classification model is iteratively trained until the loss value meets the requirements or the number of iterations reaches the threshold, and the model training is completed.
[0056] After the component classification model is trained, the second image corresponding to the target component is obtained, wherein the center point of the image corresponding to the target component can be kept unchanged, and the length and width can be expanded outward by 10% to obtain the second image corresponding to the target component. The second image corresponding to the target component is input into the component classification model, and the target category of the target component is determined based on the component classification model.
[0057] In the present application, firstly, based on the component detection model, each candidate component in the first image to be detected is detected, and the detection confidence of each candidate component is detected according to the component detection model, and the target component is screened out. Then, based on the component classification model, the target category of the target component is determined, wherein the target category includes a labeled category or an unlabeled category. When training the component classification model, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time, and the component classification model of that time is trained. After the training is completed at that time, the unknown class image feature is generated according to the first sample component image; and the next component classification model training is performed based on the known class image feature corresponding to the first sample component image and the generated unknown class image feature. In this way, in the subsequent iteration process, the component classification model is trained based on the known class image feature and the generated unknown class image feature. Since the known class image feature and the generated unknown class image feature are combined in the training component classification model, the component classification model finally trained has the ability to detect known class components and unknown class components, so the target category of the target component is determined based on the component classification model. Thereby, automatic and accurate detection of unknown components is achieved.
[0058] This application belongs to the field of computer vision in trusted AI, and specifically relates to a detection and algorithm update solution for newly emerging unknown components. The present invention proposes an algorithm to establish a known category library of the current algorithm, and automatically identify the unknown component categories caused by frequent production changes through a self-developed algorithm. It can automatically collect new component image samples that have not been seen by the current AI model without affecting the normal operation of the AOI system. Timely data collection optimizes the algorithm to help the production line complete rapid iteration and update of the algorithm.
[0059] Trustworthy features:
[0060] Real-time: This application makes subsequent logical judgments based on the inference results of the deep learning model. Each model can process the images to be inferred from the AOI device to the algorithm within a given time period, which meets the real-time characteristics of the trustworthy feature.
[0061] Reproducibility: The same image can be transmitted multiple times to the same batch of models for inference. The same results can be obtained by inference multiple times in different operating environments (different platforms, different inference times, and different times), which meets the reproducibility feature of the trustworthiness feature.
[0062] Controllability: This application can be turned on or off by the user at any time during use. The importance of the inference results and the degree of adoption can be intervened by the user, which conforms to the controllability feature of the trustworthy characteristic.
[0063] This application proposes an algorithm to establish a library of known categories of the current algorithm, and automatically identify unknown component categories caused by frequent production changes through self-developed algorithms. It can automatically collect new component image samples that have not been seen by the current AI model without affecting the normal operation of the AOI system. These new images will be transmitted to the algorithm training platform through the data interface, so that algorithm personnel can incorporate new categories into the existing model to achieve fine-tuning and iterative updates of the algorithm model. This method realizes the online update of the algorithm model, effectively solves the detection and identification problems when new targets appear on the production line, improves the detection accuracy and scope of application of the AOI system, reduces manual intervention, and improves the intelligence level of the production line.
[0064] After the current training is completed, generating unknown class image features according to the first sample component image includes:
[0065] After the training is completed, the second sample component image of the labeled category in the verification set is input into the component classification model obtained after the training is completed to obtain the recognition accuracy of each labeled category, and the category to be selected is determined based on the recognition accuracy; and the unknown class image features are generated based on the first sample component image of the category to be selected.
[0066] Optionally, after the first training is completed. Input the second sample component image of the labeled category in the verification set into the model after the first training is completed, and obtain the recognition accuracy of each labeled category based on the model after the first training is completed. Then determine the category to be selected based on the recognition accuracy. Considering that the generated unknown class image features are surrounded by the category with lower accuracy in the high-dimensional space, it is helpful for the category with lower accuracy to establish a more compact decision boundary based on the feature data of each category, and better distinguish between the data belonging to the respective category and the data not belonging to the respective category, thereby improving the accuracy of these categories. Therefore, the category with lower recognition accuracy can be selected as the category to be selected. Then generate the unknown class image features based on the first sample component image of the category to be selected.
[0067] After the second training is completed, the second sample component image of the labeled category in the verification set is input into the model after the second training is completed. Based on the model after the second training is completed, the recognition accuracy of each labeled category is obtained. Then, according to the recognition accuracy, the category to be selected is determined. The category with a lower recognition accuracy can be selected as the category to be selected. Then, the unknown class image feature is generated according to the first sample component image of the category to be selected. This is analogous to the subsequent training process and will not be described in detail.
[0068] Figure 2 A schematic diagram of the unknown component detection process provided in this application, the process includes the following steps:
[0069] S201: Acquire a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out a target component according to the detection confidence of each candidate component;
[0070] S202: Inputting the second image corresponding to the target component into the component classification model, and determining the target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category; wherein the training process of the component classification model includes: in an iterative training process, inputting the first sample component image of the labeled category in the training set into the component classification model to be trained at that time; after the training at that time is completed, inputting the second sample component image of the labeled category in the verification set into the component classification model obtained after the training at that time is completed, obtaining the recognition accuracy of each labeled category, and determining the category to be selected according to the recognition accuracy; generating unknown class image features according to the first sample component image of the category to be selected; and performing the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0071] In this application, according to the recognition accuracy, the categories to be selected include:
[0072] Determine the marked categories whose recognition accuracy is less than a preset accuracy threshold as the categories to be selected; or
[0073] According to the order of recognition accuracy from small to large, a preset number of labeled categories are selected as the categories to be selected.
[0074] The present application provides two methods for determining the categories to be selected based on the recognition accuracy. Method 1: The number of categories to be selected is not limited, but a preset accuracy threshold is set. After determining the recognition accuracy of each category, the marked categories whose recognition accuracy is less than the preset accuracy threshold are determined as the categories to be selected. The preset accuracy threshold is, for example, 0.4, 0.3, etc. Method 2: Limit the number of categories to be selected. Sort the determined recognition accuracy of each category from small to large, and select a preset number of marked categories from small to large to determine them as the categories to be selected. The preset number is, for example, 2, 3, etc.
[0075] Figure 3 A schematic diagram of the unknown component detection process provided in this application, the process includes the following steps:
[0076] S301: Acquire a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out a target component according to the detection confidence of each candidate component;
[0077] S302: Input the second image corresponding to the target component into the component classification model, and determine the target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category; wherein the training process of the component classification model includes: in the iterative training process, input the first sample component image of the labeled category in the training set into the component classification model to be trained at that time; after the training is completed at that time, input the second sample component image of the labeled category in the verification set into the component classification model obtained after the training is completed at that time, and obtain the recognition accuracy of each labeled category; determine the labeled category with a recognition accuracy less than a preset accuracy threshold as the category to be selected; or select a preset number of labeled categories in order of recognition accuracy from small to large to determine as the category to be selected; generate unknown class image features according to the first sample component image of the category to be selected; and perform the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0078] In the present application, generating unknown class image features according to the first sample component image includes:
[0079] Generate an unknown class sample component image according to the first sample component image, input the unknown class sample component image into the component classification model obtained after the training is completed, and determine the unknown class image feature corresponding to the unknown class sample component image based on the component classification model; or
[0080] Determine the known class image features corresponding to the first sample component image based on the component classification model obtained after the training is completed; and generate the unknown class image features according to the known class image features.
[0081] The present application provides two methods for generating unknown class image features based on the first sample component images. Method 1: First, generate unknown class sample component images based on each first sample component image, and then extract features of the unknown class sample component images based on the component classification model obtained after the training is completed to obtain unknown class image features. Optionally, based on each first sample component image, after image fusion processing, obtain unknown class sample component images. Then, the unknown class sample component images are input into the component classification model obtained after the training is completed, and the unknown class image features corresponding to the unknown class sample component images are determined based on the component classification model. Method 2: According to the known class image features corresponding to each first sample component image, the unknown class image features are fused and generated. Optionally, based on the component classification model obtained after the training is completed, the known class image features corresponding to each first sample component image can be determined, and then the corresponding known class image features are fused to obtain unknown class image features.
[0082] Optionally, if the annotated categories whose recognition accuracy is less than a preset accuracy threshold are determined as the categories to be selected; or a preset number of annotated categories are selected in order of recognition accuracy from small to large to be determined as the categories to be selected. When generating unknown class image features according to the first sample component image of the category to be selected, method one: according to the first sample component images of each category to be selected, after image fusion processing, obtain the unknown class sample component image. Then the unknown class sample component image is input into the component classification model obtained after the training is completed, and the unknown class image features corresponding to the unknown class sample component image are determined based on the component classification model. Method two: according to the known class image features corresponding to each of the first sample component images of each category to be selected, the unknown class image features are fused and generated. Optionally, based on the component classification model obtained after the training is completed, the known class image features corresponding to each of the first sample component images of each category to be selected can be determined, and then the corresponding known class image features are fused to obtain the unknown class image features.
[0083] Figure 4 A schematic diagram of the training process of the component classification model provided in this application, the process includes the following steps:
[0084] S401: In the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the training is completed at that time, the second sample component image of the labeled category in the verification set is input into the component classification model obtained after the training is completed at that time, and the recognition accuracy of each labeled category is obtained;
[0085] S402: Determine the marked categories whose recognition accuracy is less than a preset accuracy threshold as the categories to be selected; or select a preset number of marked categories in ascending order of recognition accuracy to determine as the categories to be selected;
[0086] S403: Generate a sample component image of an unknown category based on the first sample component image of the category to be selected, input the sample component image of the unknown category into the component classification model obtained after the training is completed, and determine the unknown category image features corresponding to the sample component image of the unknown category based on the component classification model; or determine the known category image features corresponding to the first sample component image of the category to be selected based on the component classification model obtained after the training is completed; generate the unknown category image features based on the known category image features;
[0087] S404: generating unknown class image features according to the first sample component image of the to-be-selected category; and performing next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0088] In the present application, generating the unknown class image feature according to the known class image feature includes:
[0089] Determine the feature fusion weight corresponding to each of the labeled categories according to the recognition accuracy of each of the labeled categories, wherein the lower the recognition accuracy, the higher the corresponding feature fusion weight;
[0090] According to the feature fusion weights corresponding to the respective labeled categories, feature fusion processing is performed on the known class image features of the respective labeled categories to generate the unknown class image features.
[0091] In order to further establish a more compact decision boundary, better distinguish data belonging to respective categories from data not belonging to respective categories, thereby improving the accuracy of the component classification model. In the present application, when generating unknown class image features, after determining the recognition accuracy of each labeled category, the feature fusion weights corresponding to each labeled category are determined according to the recognition accuracy of each labeled category, wherein the lower the recognition accuracy, the higher the corresponding feature fusion weight. Then, according to the feature fusion weights corresponding to each labeled category, feature fusion processing is performed on the known class image features of each labeled category to generate the unknown class image features. Thereby further establishing a more compact decision boundary, better distinguishing data belonging to respective categories from data not belonging to respective categories, and improving the accuracy of the component classification model.
[0092] Figure 5 A schematic diagram of the training process of the component classification model provided in this application, the process includes the following steps:
[0093] S501: In the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the training is completed at that time, the second sample component image of the labeled category in the verification set is input into the component classification model obtained after the training is completed at that time, and the recognition accuracy of each labeled category is obtained;
[0094] S502: Determine the marked categories whose recognition accuracy is less than a preset accuracy threshold as the categories to be selected; or select a preset number of marked categories in ascending order of recognition accuracy to determine as the categories to be selected;
[0095] S503: Generate a sample component image of an unknown category according to the first sample component image of the category to be selected, input the sample component image of the unknown category into the component classification model obtained after the training is completed, and determine the unknown category image features corresponding to the sample component image of the unknown category based on the component classification model; or determine the known category image features corresponding to the first sample component image of the category to be selected based on the component classification model obtained after the training is completed; determine the feature fusion weights corresponding to each of the labeled categories according to the recognition accuracy rates of each of the labeled categories, wherein the lower the recognition accuracy rate, the higher the corresponding feature fusion weight; perform feature fusion processing on the known category image features of each of the labeled categories according to the feature fusion weights corresponding to each of the labeled categories to generate the unknown category image features;
[0096] S504: generating unknown class image features according to the first sample component image of the to-be-selected category; and performing next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0097] In the present application, the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features includes:
[0098] Based on the component classification model, the predicted categories corresponding to the known class image features corresponding to the first sample component image and the generated unknown class image features are determined; the loss value is determined according to the corresponding predicted category information and labeled category information; the component classification model is trained according to the loss value; wherein the labeled category information corresponding to the known class image features is: the probability of a real known category is 1, the probability of a non-real known category is 0, and the probability of an unknown category is between 0 and 1; the labeled category information corresponding to the unknown class image features is: the probability of an unknown category is 1, and the probability of a known category is 0.
[0099] The labeled category information corresponding to the known class image features is: the probability of the real known class is 1, the probability of the unreal known class is 0, and the probability of the unknown class is between 0 and 1. This design is to more accurately map the known class data to the correct known class. The labeled category information corresponding to the unknown class image features is: the probability of the unknown class is 1, and the probability of the known class is 0. This design is to more accurately map the unknown class data to the unknown class.
[0100] Figure 6 A schematic diagram of the training process of the component classification model provided in this application, the process includes the following steps:
[0101] S601: In the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the training is completed at that time, the second sample component image of the labeled category in the verification set is input into the component classification model obtained after the training is completed at that time, and the recognition accuracy of each labeled category is obtained;
[0102] S602: Determine the marked categories whose recognition accuracy is less than a preset accuracy threshold as the categories to be selected; or select a preset number of marked categories in ascending order of recognition accuracy to determine as the categories to be selected;
[0103] S603: Generate a sample component image of an unknown category based on the first sample component image of the category to be selected, input the sample component image of the unknown category into the component classification model obtained after the training is completed, and determine the unknown category image features corresponding to the sample component image of the unknown category based on the component classification model; or determine the known category image features corresponding to the first sample component image of the category to be selected based on the component classification model obtained after the training is completed; determine the feature fusion weights corresponding to each of the labeled categories according to the recognition accuracy rates of each of the labeled categories, wherein the lower the recognition accuracy rate, the higher the corresponding feature fusion weight; perform feature fusion processing on the known category image features of each of the labeled categories according to the feature fusion weights corresponding to each of the labeled categories to generate the unknown category image features.
[0104] S604: Determine the prediction categories corresponding to the known class image features corresponding to the first sample component image and the generated unknown class image features based on the component classification model; determine the loss value according to the corresponding prediction category information and labeled category information; train the component classification model according to the loss value; wherein the labeled category information corresponding to the known class image features is: the probability of a real known category is 1, the probability of a non-real known category is 0, and the probability of an unknown category is between 0 and 1; the labeled category information corresponding to the unknown class image features is: the probability of an unknown category is 1, and the probability of a known category is 0.
[0105] In this application, the method further includes:
[0106] If the target category of the target component includes an unlabeled category, the unlabeled category in the first image is labeled, and the component detection model is trained based on the labeled first image.
[0107] After the electronic device detects that the target category of the target component includes an unlabeled category, the unknown category is labeled as a new known category, and then the component detection model is trained based on the labeled first image. In this way, when the candidate component is subsequently detected based on the component detection model, the component of the unknown category will be determined as a known category component with a higher confidence, avoiding the need to detect the unknown category component again.
[0108] The unknown component detection process provided by the present application is described in detail below with reference to the accompanying drawings.
[0109] Figure 7 The standard image diagram provided for this application, Figure 8 Schematic diagram of the measured image provided for this application. During the preparation stage for production change, the AOI equipment will be intervened by employees to set some parameters related to the new production, and use a high-precision industrial scanning camera to capture an image of a normal PCBA board as a standard image. In the actual production process, the measured image of the produced PCBA board is collected in real time. The standard image and the measured image are traversed in a sliding window manner to obtain a partial image pair. By comparing with the partial image of the standard image, it is determined whether there are ten major types of defects such as missing parts, offset, missed detection, and polar reversal on the measured image.
[0110] Fig. 9 This is the unknown component detection architecture diagram provided by this application. Fig. 9 As shown in the figure, in the preparation stage for production change, the AOI equipment collects standard images, and the component detection model is started at this time. The component detection model can be a rotating target detection model, and the component detection model detects whether unknown components appear in the standard image (confidence is less than the threshold). If no unknown components are found in the standard image, the component detection model does not need to be started in the measured images of the batch production link; if unknown components are detected in the standard image, the component detection model is continued to be used to detect the measured image in the subsequent production link of the batch, and the unknown component thumbnails (second images) and the measured images where the unknown components are located are collected in this process. The above-mentioned collected images are transmitted to the algorithm training platform, and two things are done on the algorithm training platform. First, the unknown component thumbnails are added as new categories to the iterative optimization of the component classification model, and the trained component classification model is pushed to the production line reasoning platform for real-time algorithm update. On the measured image where the unknown component is located, the result of algorithm reasoning is retained, and the annotator re-judges the inferred detection frame, corrects the annotation result, and iteratively trains the component detection model of the production line. After the algorithm model training is completed, it is pushed to the production line reasoning platform for real-time algorithm update.
[0111] This application involves two models, one is the component detection algorithm (rotating target detection algorithm) currently used in the production line, which is used to detect more than 30 kinds of components commonly used on PCBA boards. The other algorithm is a component classification model used to classify known and unknown components.
[0112] Fig.10 The overall flow chart of unknown component detection provided in this application, the overall workflow is as follows: first, the local image (in the production change stage, this is a local image of the standard image, in the production stage, this is a local image of the measured image) is transmitted to the component detection model, the component detection model is, for example, the YOLOv-OBB model, to detect the component type on the local image, and then save the detection information of all detection targets in the current screen with a lower confidence level (for example, 0.01). Take the target with a confidence level in the interval [0.01, 0.25], keep the center point of the target's detection frame unchanged, expand the length and width outward by 10%, and crop it out. Send it to the component classification model. Use the component classification model to classify known components and unknown components.
[0113] The backbone network of the component classification model can use the resnet34 network structure. Fig.11 Schematic diagram of the resnet34 network structure provided for this application. The original network is after the avgpool (average pooling layer), using the flatten function to flatten the features to one dimension, followed by a linear mapping to the dimension of the known number of categories used for classification, and finally using the cross entropy loss function to calculate the error between the predicted category and the actual category.
[0114] This application makes the following improvements to the resnet34 network:
[0115] (1) At the position of the last layer of residual network, that is, Fig.11The dotted box position simulates the generation of unknown category data during the training process, that is, generates data that does not belong to any known category. The data is not input in the form of unknown category pictures, but is generated by combining high-dimensional features of multiple known categories during the training process. Specifically, in the process of model feature extraction, the present application selects one of the neural network layers and finds the hidden layer between this layer of neural network and the next layer. Fit a higher dimensional hidden layer between two layers of neural networks. The meaning of the hidden layer is to abstract the features of the input data to another dimensional space (generally higher dimensional) to show its more abstract features, which can be better linearly divided. Then select the data of two classes in this layer from different classes, and mix them in a certain proportion in the hidden layer to obtain new data in the hidden layer, and then map it to the next layer of the neural network, as the simulated new data in this layer of information forward propagation. Considering that the interpolation between two different classes is usually an area of low confidence prediction, that is, the location of the non-target class. Therefore, we can train it as a new class. In this way, the embedding of known classes will be tighter, leaving more space for new classes.
[0116] Fig.12 A schematic diagram of the high-dimensional hidden layer provided for this application, Fig.12 The n+1th layer of the neural network in can be Fig.11 The neural network in the dotted box, the nth layer of the neural network can be Fig.11 The previous layer of neural network is in the dashed box.
[0117] Assume that X is the feature of the nth layer of the neural network. In the related art, φ(X) is used to map the feature X of the nth layer to the n+1th layer. However, the present application introduces a higher-dimensional hidden layer between the nth layer and the n+1th layer. The significance of the hidden layer is to abstract the features of the input data to another dimensional space (generally higher dimensional) to show its more abstract features. φ1 maps the features of the nth layer to the high-dimensional hidden layer, and φ2 maps from the hidden layer to the n+1th layer. φ1 is the model parameter of the neural network of the nth layer, and φ2 is the model parameter of the neural network of the n+1th layer. The calculation method is:
[0118] φ(X)=φ2(φ1(X)).
[0119] Then I select two or more classes of data in this layer from different classes, and mix them in a certain proportion in the hidden layer to get new data in this hidden layer. Set a classification accuracy threshold a, and the known categories with accuracy less than a participate in generating unknown category features, or select several known categories with low accuracy to generate unknown category features. Calculate the classification accuracy of each known category, and calculate the number of categories with single-category classification accuracy lower than the threshold. If the number is greater than 2, take the hidden layer features of all categories with accuracy lower than threshold a to participate in the generation process of the above new category data, and help each known category to establish a tight decision boundary as soon as possible. If the number is less than or equal to 2, including the case where the accuracy of all categories is higher than threshold a, then take the two categories with the lowest accuracy to participate in the generation of new category data. In this way, the generated new category data will appear near the two categories with the lowest accuracy in high-dimensional space, which will help the two categories with the lowest accuracy to establish a more compact decision boundary based on the data features of their respective categories, thereby improving the accuracy of these two categories. The data of new categories (unknown categories) generated in the above way accompany the entire cycle of model training.
[0120] (a) For the high-dimensional features of two known classes, the calculation method is:
[0121] Where i and j are two different known categories.
[0122] (b) For the high-dimensional features of k known classes, the calculation method is:
[0123]
[0124] n m The ranking of all categories is sorted from high to low by accuracy. The lower the ranking, the higher the accuracy. m The larger the value, the m The larger the value, the more λ m The sum is 1. The lower the accuracy of a category, the greater its weight. This is done to make the generated new category data surround the category with lower accuracy in the high-dimensional space. It helps the categories with lower accuracy to establish a more compact decision boundary based on their feature data, better distinguish between data belonging to their respective categories and data not belonging to their respective categories, thereby improving the accuracy of these categories.
[0125] Then use φ2 to map the new data generated by the mixture to the n+1th layer. That is:
[0126]
[0127] The data generated in this way There are several advantages: (a) Feature data that does not belong to any known category belongs to the unknown class. (b) It contains a certain proportion of features in the known categories, which is closer to the decision boundary between the known categories, and can urge each known category to establish a tighter feature boundary. (c) Data generation is fast, and only the intermediate data needs to be saved and the data needs to be fused during the training of the known categories, without the need for retraining to increase a lot of additional calculations. Through the forward propagation learning of the newly generated unknown class, the embedding of the known class will be tighter, leaving more optional space for the new class.
[0128] (2) This application sets up two classifiers and improves the loss function. The first classifier is used to classify known categories, and the other classifier is used to classify known and unknown categories. Specifically, an additional linear layer is added to the first classifier, and then the combined result is passed through the softmax layer to generate the posterior probability. The final loss function of the two classifiers is defined as:
[0129]
[0130] Among them, L is the cross entropy loss function or other loss function, is the predicted category, y is the actual category, is the category with the second highest confidence, and N+1 is the category to which the newly generated data in the training process belongs or the category of the unknown class in the testing process.
[0131] The term on the left of the plus sign constrains the first classifier to correctly classify the known categories and the known N categories. The term on the right of the plus sign trains the second classifier to correctly classify the known and unknown categories, and forces the second classifier to output the newly generated category during the training process as the second most likely. "\" means to remove, that is, during the training process, for the data in the known category, if the real category to which the data belongs is removed, the probability of the data being classified into the "reserved category" is the largest (the N+1th category); the reserved category refers to the unknown category. Fig.13 Decision diagram of the classifier provided for this application.
[0132] like Fig.13As shown in the figure, assuming there are three known classes, the first classifier is used to classify the three known classes. For each known class, the goal of training and optimization is to make the confidence of being classified into the current class the highest, and the probability of being classified into the reserved class the second. The first classifier is optimized with the above strategy, so that the second classifier is placed between the known class and the unknown class, and the known and unknown classes are classified. During the training process, it learns to locate between the known and unknown classes. When faced with a new class, since all known classes are non-target classes, the prediction of the "reserved class" (unknown class) will be the highest, in this way, the second classifier achieves the binary classification of known and unknown classes.
[0133] Specifically:
[0134] In the training phase, the probability of data of known categories being classified into their respective categories is the first, and the probability of data of reserved categories is the second; the jointly generated data The probability of being assigned to the reserved category is the highest.
[0135] During the test, if a data belongs to a known category, the probability of it belonging to its original category is the first, and the probability of it belonging to the reserved category is the second. Therefore, based on the principle of taking the category with the highest probability as the predicted category, the data can be correctly classified into the known category. If a data is unknown data, it does not belong to any known category. Therefore, when extracting model features, the data will deviate from the decision boundary of any known category and does not belong to any known category. Therefore, the confidence that it will be classified into the "reserved category" (unknown category) is the highest.
[0136] Fig.14 The schematic diagram of the unknown component detection device provided for this application includes:
[0137] A screening module 141 is used to obtain a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out a target component according to the detection confidence of each candidate component;
[0138] A determination module 142 is used to input the second image corresponding to the target component into a component classification model, and determine a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category;
[0139] The training module 143 is used to input the first sample component image of the labeled category in the training set into the component classification model to be trained at the time during the iterative training process; after the current training is completed, generate unknown class image features according to the first sample component image; and perform the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
[0140] The training module 143 is used to input the second sample component image of the labeled category in the verification set into the component classification model obtained after the current training is completed, to obtain the recognition accuracy of each labeled category, and determine the category to be selected based on the recognition accuracy; and to generate unknown class image features based on the first sample component image of the category to be selected.
[0141] The training module 143 is used to determine the marked categories with recognition accuracy less than a preset accuracy threshold as the categories to be selected; or select a preset number of marked categories in order of recognition accuracy from small to large to determine them as the categories to be selected.
[0142] The training module 143 is used to generate an unknown category sample component image based on the first sample component image, input the unknown category sample component image into the component classification model obtained after the training is completed, and determine the unknown category image features corresponding to the unknown category sample component image based on the component classification model; or determine the known category image features corresponding to the first sample component image based on the component classification model obtained after the training is completed; and generate the unknown category image features based on the known category image features.
[0143] The training module 143 is used to determine the feature fusion weights corresponding to each labeled category according to the recognition accuracy of each labeled category, wherein the lower the recognition accuracy, the higher the corresponding feature fusion weight; according to the feature fusion weights corresponding to each labeled category, feature fusion processing is performed on the known class image features of each labeled category to generate the unknown class image features.
[0144] The training module 143 is used to determine the predicted categories corresponding to the known class image features corresponding to the first sample component image and the generated unknown class image features based on the component classification model; determine the loss value according to the respectively corresponding predicted category information and labeled category information; and train the component classification model according to the loss value; wherein the labeled category information corresponding to the known class image features is: the probability of a real known category is 1, the probability of a non-real known category is 0, and the probability of an unknown category is between 0 and 1; the labeled category information corresponding to the unknown class image features is: the probability of an unknown category is 1, and the probability of a known category is 0.
[0145] The training module 143 is configured to label the unlabeled category in the first image if the target category of the target component includes an unlabeled category, and train the component detection model based on the labeled first image.
[0146] The present application also provides an electronic device, such as Fig.15 As shown, it includes: a processor 151, a communication interface 152, a memory 153 and a communication bus 154, wherein the processor 151, the communication interface 152, and the memory 153 communicate with each other through the communication bus 154;
[0147] The memory 153 stores a computer program, and when the program is executed by the processor 151, the processor 151 executes any one of the above method steps.
[0148] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0149] The communication interface 152 is used for communication between the above electronic device and other devices.
[0150] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0151] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0152] The present application also provides a computer storage readable storage medium, wherein the computer readable storage medium stores a computer program executable by an electronic device, and when the program runs on the electronic device, the electronic device implements any of the above method steps when executing.
[0153] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0154] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for detecting unknown components, characterized in that: The method comprises: Acquire a first image to be detected, input the first image into a component detection model, detect each candidate component in the first image based on the component detection model, and screen out a target component according to the detection confidence of each candidate component; Inputting the second image corresponding to the target component into a component classification model, and determining a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category; The training process of the component classification model includes: During the iterative training process, the first sample component image of the labeled category in the training set is input into the component classification model to be trained at that time; after the current training is completed, the unknown class image features are generated according to the first sample component image; and the next component classification model training is performed based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
2. The method according to claim 1, characterized in that After the current training is completed, generating unknown class image features according to the first sample component image includes: After the training is completed, the second sample component image of the labeled category in the verification set is input into the component classification model obtained after the training is completed to obtain the recognition accuracy of each labeled category, and the category to be selected is determined based on the recognition accuracy; and the unknown class image features are generated based on the first sample component image of the category to be selected.
3. The method according to claim 2, characterized in that According to the recognition accuracy, the categories to be selected include: Determine the marked categories whose recognition accuracy is less than a preset accuracy threshold as the categories to be selected; or According to the order of recognition accuracy from small to large, a preset number of labeled categories are selected as the categories to be selected.
4. The method according to claim 1 or 2, characterized in that: Generating unknown class image features according to the first sample component image includes: Generate an unknown class sample component image according to the first sample component image, input the unknown class sample component image into the component classification model obtained after the training is completed, and determine the unknown class image feature corresponding to the unknown class sample component image based on the component classification model; or Determine the known class image features corresponding to the first sample component image based on the component classification model obtained after the training is completed; and generate the unknown class image features according to the known class image features.
5. The method according to claim 4, characterized in that Generating the unknown class image feature according to the known class image feature comprises: Determine the feature fusion weight corresponding to each of the labeled categories according to the recognition accuracy of each of the labeled categories, wherein the lower the recognition accuracy, the higher the corresponding feature fusion weight; According to the feature fusion weights corresponding to the respective labeled categories, feature fusion processing is performed on the known class image features of the respective labeled categories to generate the unknown class image features.
6. The method according to claim 1, characterized in that The next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features includes: Based on the component classification model, the predicted categories corresponding to the known class image features corresponding to the first sample component image and the generated unknown class image features are determined; the loss value is determined according to the corresponding predicted category information and labeled category information; according to the loss value, the component classification model is trained; wherein the labeled category information corresponding to the known class image features is: the probability of a real known category is 1, the probability of a non-real known category is 0, and the probability of an unknown category is between 0 and 1; the labeled category information corresponding to the unknown class image features is: the probability of an unknown category is 1, and the probability of a known category is 0.
7. The method according to claim 1, characterized in that The method further comprises: If the target category of the target component includes an unlabeled category, the unlabeled category in the first image is labeled, and the component detection model is trained based on the labeled first image.
8. An unknown component detection device, characterized in that: The device comprises: A screening module, used for acquiring a first image to be detected, inputting the first image into a component detection model, detecting each candidate component in the first image based on the component detection model, and screening out a target component according to the detection confidence of each candidate component; A determination module, configured to input the second image corresponding to the target component into a component classification model, and determine a target category of the target component based on the component classification model; wherein the target category includes a labeled category or an unlabeled category; The training module is used to input the first sample component image of the labeled category in the training set into the component classification model to be trained at that time during the iterative training process; after the current training is completed, generate unknown class image features according to the first sample component image; and perform the next component classification model training based on the known class image features corresponding to the first sample component image and the generated unknown class image features.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
PCBA element detection method and system based on spatial independence and scale perception
CN121304689A
