Model parameter automatic adjustment method and device
By automatically adjusting the detection parameters of the product defect detection model, the problems of low efficiency and poor accuracy of manual adjustment are solved, and the model achieves efficient and stable detection.
Patent Information
- Application Number
- CN202511196840.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-08-25
AI Technical Summary
In existing technologies, the parameter adjustment of product defect detection models relies on manual intervention, which leads to low efficiency, poor accuracy, and a tendency to get trapped in local extrema, affecting the stability of the model's detection performance.
When the performance index of the product defect detection model is lower than a preset threshold, multiple sets of inference data are automatically collected, the model performance index of the detection parameter group is screened and calculated, and the parameter group with the best performance is selected as the target detection parameter, thereby realizing the automatic adjustment of the model.
It improves the detection accuracy and recall rate of the product defect detection model, reduces human intervention, and enhances the model's stability and overall detection effect.
Smart Images

Figure CN120747059B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a model parameter automatic adjustment method and device. BACKGROUND
[0002] In the field of industrial quality inspection, product defect detection models have become a key tool for identifying product surface defects. However, due to the variety of products to be detected, the defect categories will also increase, therefore, in order to accurately identify each defect category, the technical personnel need to continuously adjust the detection parameter group of the product defect detection model, so that it can improve the model detection accuracy. However, the traditional parameter adjustment method is to rely on manual intervention, that is, to update the detection parameter group by statistically counting the detection state of the model on the training set in a human way. But this parameter adjustment scheme has the following problems:
[0003] (1) Artificial statistics and parameter adjustment is a trial-and-error process, and each adjustment needs to re-evaluate the model, which greatly prolongs the time cycle of model optimization;
[0004] (2) Due to the lack of standardized updating strategy, relying on personal experience may lead to inaccurate parameter settings, and in some cases, manual adjustment may cause the model to fall into a local extremum, thereby affecting the stability of long-term detection effect.
[0005] The above problems highlight the limitations of existing technology in model parameter adjustment, especially in the pursuit of efficient, accurate and stable industrial production environment, manual adjustment method is increasingly inadequate. Therefore, there is an urgent need for a scheme that can automatically and intelligently adjust the detection model parameters to overcome the above technical problems. SUMMARY
[0006] The embodiments of the present application provide a model parameter automatic adjustment method and device to at least solve the technical problems of low efficiency and poor accuracy in manually adjusting the model parameters of the product defect detection model.
[0007] According to an aspect of the embodiments of the present application, a model parameter automatic adjustment method is provided, comprising: when a model performance index of a product defect detection model is lower than a preset performance threshold, obtaining a plurality of sets of inference data of the product defect detection model, wherein each set of inference data comprises a defect detection result and a detection state corresponding to an image identifier, and the defect detection result comprises a defect category and a detection parameter group corresponding to each defect detection frame in a product image corresponding to the image identifier, and the detection parameter group comprises at least one of a confidence, a long axis, a short axis, and a frame area; for each defect category in the product defect detection model, determining a plurality of detection parameter groups corresponding to the defect category from the plurality of sets of inference data, and determining a model performance index corresponding to each detection parameter group; and taking the detection parameter group with the highest model performance index as a target detection parameter group corresponding to the defect category.
[0008] Optionally, the obtaining the plurality of sets of inference data of the product defect detection model comprises: using an image acquisition device to acquire a plurality of product images on a product production line and an image identifier of each product image; for each product image, obtaining a defect detection result obtained by using the product defect detection model to detect and analyze the product image, and determining a detection state of the product image according to the defect detection result and a manually annotated defect result corresponding to the product image, wherein the manually annotated defect result comprises each defect real frame in the product image and a corresponding defect category, and the detection state comprises one of a detection state, a false detection state, an over-detection state, a missing detection no-frame state, and a missing detection frame state; and the plurality of sets of inference data of the product defect detection model are composed of the defect detection result and the detection state of the product image corresponding to each image identifier.
[0009] Optionally, the detection state of the product image is determined according to the defect detection result and the artificial labeled defect result corresponding to the product image, including: when the defect category in the defect detection result is the same as the defect category in the artificial labeled defect result corresponding thereto, and the intersection-over-union between the defect detection frame in the defect detection result and the defect real frame in the artificial labeled defect result is higher than a preset threshold value, determining that the detection state of the product image is a detection state; when the defect category in the defect detection result is different from the defect category in the artificial labeled defect result corresponding thereto, but the intersection-over-union between the defect detection frame in the defect detection result and the defect real frame in the artificial labeled defect result is higher than the preset threshold value, determining that the detection state of the product image is a false detection state; when the defect category in the defect detection result is not empty but the defect category in the artificial labeled defect result corresponding thereto is empty, determining that the detection state of the product image is an over-detection state; when the defect category in the defect detection result is empty but the defect category in the artificial labeled defect result corresponding thereto is not empty, determining that the detection state of the product image is a missed detection no-frame state; when the defect category in the defect detection result and the artificial labeled defect result corresponding thereto is not empty, but the number of defect categories in the defect detection result is inconsistent with the number of defect categories in the artificial labeled defect result, determining that the detection state of the product image is a missed detection with frame state.
[0010] Optionally, the model performance index corresponding to each detection parameter group is determined, including: for each detection parameter group, a plurality of target inference data containing the detection parameter group is determined from a plurality of sets of inference data; according to the defect detection result and the detection state in the plurality of sets of target inference data, the number of false negative data, the number of positive positive data and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined; the number of false negative data, the number of positive positive data, the number of false positive data are used to determine the model performance index corresponding to the detection parameter group.
[0011] Optionally, according to the defect detection result and the detection state in the plurality of groups of target inferred data, the number of false negative data, the number of positive data and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined, including: initializing the number of false positive data, the number of positive sample data and the number of false negative data to 0; sequentially traversing the plurality of groups of target inferred data, determining the detection state in the target inferred data; when the detection state is the missing detection no-frame state, the number of false negative data is increased by 1; when the detection state is the missing detection frame state or the detection state and the detection parameter group in the defect detection result of the target inferred data is greater than the detection parameter group, the number of positive data is increased by 1; when the detection state is the missing detection frame state or the detection state, but any one of the detection parameter group in the defect detection result of the target inferred data is not greater than the detection parameter group, the number of false negative data is increased by 1; when the detection state is the over-detection state or the false detection state and the detection parameter group in the defect detection result of the target inferred data is greater than the detection parameter group, the number of false positive data is increased by 1; after traversing the plurality of groups of target inferred data, the number of false negative data, the number of positive data and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined.
[0012] Optionally, the method further comprises: when the detection state is the false detection state and the similarity between the defect category in the defect detection result of the target inferred data and the defect category corresponding to the detection parameter group is higher than a preset threshold, the number of positive data is increased by 1.
[0013] Optionally, the model performance index at least includes: F1 score, wherein the model performance index corresponding to the detection parameter group is determined according to the number of false negative data, the number of positive data and the number of false positive data, including: the quotient value of the number of positive data divided by the sum of the number of positive data and the number of false positive data as the precision; the quotient value of the number of positive data divided by the sum of the number of positive data and the number of false negative data as the recall; the F1 score corresponding to the detection parameter group is determined according to the precision and the recall.
[0014] According to another aspect of the embodiments of the present application, a model parameter automatic adjustment apparatus is also provided, comprising: an acquisition module configured to acquire a plurality of sets of inference data of a product defect detection model when a model performance index of the product defect detection model is lower than a preset performance threshold, wherein each set of inference data comprises a defect detection result corresponding to an image identifier and a detection state, and the defect detection result comprises a defect category and a detection parameter group corresponding to each defect detection frame in the product image corresponding to the image identifier, and the detection parameter group comprises at least one of a confidence, a long axis, a short axis, and a frame area; a performance evaluation module configured to determine, for each defect category in the product defect detection model, a plurality of detection parameter groups corresponding to the defect category from the plurality of sets of inference data, and determine a model performance index corresponding to each detection parameter group; and a determination module configured to take the detection parameter group with the highest model performance index as a target detection parameter group corresponding to the defect category.
[0015] According to another aspect of the embodiments of the present application, a computer program product is also provided, comprising: a computer program, wherein the computer program is executed by a processor to implement the model parameter automatic adjustment method described above.
[0016] According to another aspect of the embodiments of the present application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the model parameter automatic adjustment method described above by the computer program.
[0017] In the embodiments of the present application, when the model performance index of the product defect detection model does not meet the requirements, a plurality of sets of historical inference data of the model are collected, including defect detection results and detection states; for each preset defect category, all relevant detection parameter groups are filtered from the collected plurality of sets of historical inference data, and a model performance index corresponding to each detection parameter group is calculated, so as to quantify the accuracy and reliability of the model. Finally, the detection parameter group corresponding to the peak value of the model performance index is taken as the target detection parameter. Thus, the defect detection capability of the model is improved in a targeted manner, the overall detection precision and recall rate are improved, and the technical problems of low efficiency and poor accuracy in manually adjusting the model parameters of the product defect detection model are solved. BRIEF DESCRIPTION OF DRAWINGS
[0018] The accompanying drawings, which are included to provide a further understanding of the present application, form a part of the present application and illustrate the illustrative embodiments of the present application and the explanation of the present application, and do not constitute improper limitations on the present application. In the drawings:
[0019] Figure 1 is a flow diagram of an optional model parameter automatic adjustment method according to an embodiment of the present application;
[0020] Figure 2 is a structural schematic diagram of an optional model parameter automatic adjustment device according to an embodiment of the application;
[0021] Figure 3 is a structural schematic diagram of a computer terminal for implementing the model parameter automatic adjustment method according to an embodiment of the application. DETAILED DESCRIPTION
[0022] In order for those skilled in the art to better understand the scheme of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] In order to better understand the embodiments of the present application, first, the following translation explanation is given for some nouns or terms appearing in the description of the embodiments of the present application:
[0025] Intersection over Union (IOU): is an important indicator to measure the degree of overlap between two rectangular frames. This concept comes from the set in mathematics, which is often used to describe the relationship between two sets A and B. It is equal to the number of elements contained in the intersection of the two sets, divided by the number of elements contained in their union.
[0026] Embodiment 1
[0027] According to the embodiment of the present application, a model parameter automatic adjustment method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in a different order.
[0028] Figure 1 is a flowchart of a model parameter automatic adjustment method according to an embodiment of the present application, as shown in Figure 1 the method comprises the following steps:
[0029] Step S102, when the model performance index of the product defect detection model is lower than the preset performance threshold, obtaining a plurality of sets of inference data of the product defect detection model.
[0030] Each set of inference data includes: a defect detection result corresponding to the image identifier and a detection state, and the defect detection result includes: a defect category corresponding to each defect detection frame in the product image corresponding to the image identifier and a detection parameter group, and the detection parameter group includes at least one of: confidence, long axis, short axis, and frame area.
[0031] Step S104, for each defect category preset in the product defect detection model, determining a plurality of detection parameter groups corresponding to the defect category from the plurality of sets of inference data, and determining a model performance index corresponding to each detection parameter group.
[0032] Step S106, taking the detection parameter group with the highest model performance index as the target detection parameter group corresponding to the defect category.
[0033] Based on the scheme defined in the above steps S102 to S106, it can be known that in the embodiment of the present application, when the model performance index of the product defect detection model does not meet the standard, a plurality of sets of historical inference data of the model are collected, including: defect detection result and detection state; for each defect category preset, all related detection parameter groups are selected from the collected plurality of sets of historical inference data, and a model performance index corresponding to each detection parameter group is calculated to quantify the accuracy and reliability of the model. Finally, the detection parameter group corresponding to the peak value of the model performance index is taken as the target detection parameter. Thus, the defect detection capability of the model is improved in a targeted manner, especially for those defect types that the model originally performs poorly, the overall detection precision and recall rate are improved, and the low efficiency and non-optimal solution problem caused by relying on manual experience in the background technology is overcome.
[0034] The steps of the model parameter automatic adjustment method will be described below in combination with a specific implementation process.
[0035] In the technical solution provided in step S102, the product defect detection model refers to a deep learning model trained for product defect identification, including but not limited to YOLOv8 or other types of neural network models. The model performance indicator refers to the performance of the product defect detection model under a specific indicator, and once the model performance indicator is lower than the preset performance threshold, the system will trigger the automatic model parameter tuning mechanism.
[0036] When automatically tuning the model, the system can obtain multiple sets of data of the product defect detection model from the preset incremental database and perform post-processing to obtain multiple sets of inference data. The data in the incremental database is data processed by the model before, such as training sample data, test sample data, verification sample data, online inference data, etc. These data include the defect detection result corresponding to the image identifier and the detection state. The defect detection result includes the defect category corresponding to each defect detection frame in the product image corresponding to the image identifier and the boundary coordinates of the detection frame. The specific form is shown in Table 1.
[0037] Table 1
[0038]
[0039] When automatically tuning the model, the system can obtain multiple sets of data from Table 1 above, and perform post-processing on the "detection frame (i.e. the left top, left bottom, right top, right bottom coordinates of the frame)" column to calculate the long axis, short axis and frame area of the detection frame, and form a detection parameter group with the confidence.
[0040] It should be noted that the incremental database is generally deployed online at the same time as the product defect detection model is trained. After loading the product defect detection model, online inference is started, and the detection results output by the model are manually reviewed by artificial means to update the incremental database. In addition, the inference data can also include the detection state corresponding to the product image, such as one of the detection state, the false detection state, the over-detection state, and the missed detection no-frame state. If the detection state is the detection state, the false detection state, or the over-detection state, the product image identifier and the corresponding defect category, defect real boundary frame, confidence, detection state, image name, etc. are usually added to the incremental database. If the detection state is the missed detection no-frame state, the manually annotated defect category, defect real boundary frame, confidence (usually default to 1), detection state, image name, etc. are usually added to the incremental database.
[0041] As an optional implementation, in the technical solution provided in step S102, the system can obtain multiple sets of inference data of the product defect detection model according to the following steps, including:
[0042] First step: acquiring multiple product images on a product production line by using an image acquisition device.
[0043] Second step: for each product image, obtaining a defect detection result obtained by detecting and analyzing the product image by using a product defect detection model, and determining a detection state of the product image according to the defect detection result and an artificial labeled defect result corresponding to the product image, wherein the artificial labeled defect result includes: each defect real box in the product image and a corresponding defect category, and the defect category includes but is not limited to: crack, scratch, stain, etc., and the detection state includes one of the following: detection state, false detection state, over-detection state, missing detection no-box state, and missing detection box state.
[0044] Third step: the defect detection result and the detection state of the corresponding product image of each image identifier form a plurality of reasoning data of the product defect detection model.
[0045] Specifically, the detection state of the product image can be determined according to the following method:
[0046] When the defect category in the defect detection result is the same as the defect category in the corresponding artificial labeled defect result, and the intersection-over-union between the defect detection box in the defect detection result and the defect real box in the artificial labeled defect result is higher than a preset threshold value, it indicates that the model can correctly detect the defect category in the product image, so the detection state of the product image can be determined as the detection state;
[0047] When the defect category in the defect detection result is different from the defect category in the corresponding artificial labeled defect result, but the intersection-over-union between the defect detection box in the defect detection result and the defect real box in the artificial labeled defect result is higher than the preset threshold value, it indicates that the model incorrectly identifies a certain defect category as another defect category, so the detection state of the product image can be determined as the false detection state;
[0048] When the defect category in the defect detection result is not empty but the defect category in the corresponding artificial labeled defect result is empty, the detection state of the product image is determined as the over-detection state;
[0049] When the defect category in the defect detection result is empty but the defect category in the corresponding artificial labeled defect result is not empty, the detection state of the product image is determined as the missing detection no-box state;
[0050] When the defect category in the defect detection result and the defect category in the corresponding artificial labeled defect result are both not empty, but the number of defect categories in the defect detection result is inconsistent with the number of defect categories in the artificial labeled defect result, it indicates that the model has identified some defect categories, but has failed to completely or correctly identify all real defect categories, so the detection state of the product image can be determined as the missing detection box state.
[0051] The determination logic of the above detection state follows the common performance evaluation standard in the field of defect detection, i.e. correct detection (detection state), false classification (false detection state), additional detection (over-detection state) and non-detection (missed detection state). Through the clear definition of these states, the performance change of the model after updating the detection parameter group can be comprehensively evaluated.
[0052] Further, for each defect category preset in the product defect detection model, a plurality of detection parameter groups corresponding to the defect category are determined from the plurality of groups of inferred data, and a model performance index corresponding to each detection parameter group is determined.
[0053] Optionally, the system can determine the model performance index corresponding to each detection parameter group according to the following method, comprising:
[0054] Step S11, for each detection parameter group, a plurality of groups of target inferred data containing the detection parameter group are determined from the plurality of groups of inferred data.
[0055] Step S12, according to the defect detection results and the detection state in the plurality of groups of target inferred data, the number of false negative data, the number of true positive data and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined.
[0056] Step S13, the model performance index corresponding to the detection parameter group is determined according to the number of false negative data, the number of true positive data and the number of false positive data.
[0057] Optionally, in the technical solution provided in the above step S12, it can be realized by the following steps:
[0058] First, the number of false positive data, the number of true positive sample data and the number of false negative data are initialized to 0, wherein the number of false positive data is used to record the number of times that the model fails to correctly identify the defect category, the number of true positive sample data is used to record the number of times that the model correctly identifies the defect category, and the number of false negative data is used to record the number of times that the model incorrectly identifies the non-existing defect category.
[0059] Then, the plurality of groups of target inferred data are traversed in turn to determine the detection state in the target inferred data;
[0060] When the detection state is the missed detection frameless state, it means that the product defect detection model corresponding to the detection parameter group completely fails to identify the defect category in the product image, at this time the number of false negative data is increased by 1;
[0061] When the detection state is the missing detection frame state or the detection state, and each detection parameter group in the defect detection result of the target inferred data is greater than the detection parameter group, it means that the product defect detection model corresponding to the detection parameter group successfully and sufficiently identifies the defect categories in the product image. At this time, the number of true positive data is increased by 1.
[0062] When the detection state is the missing detection frame state or the detection state, but any one of the detection parameter groups in the defect detection result of the target inferred data is not greater than the detection parameter group, it means that the product defect detection model corresponding to the detection parameter group identifies the defect categories in the product image, but may fail to correctly identify the defects due to overly strict parameter settings. At this time, the number of false negative data is increased by 1.
[0063] When the detection state is the over detection state or the false detection state, and each detection parameter group in the defect detection result of the target inferred data is greater than the detection parameter group, it means that the product defect detection model corresponding to the detection parameter group incorrectly identifies the non-existing defect categories in the product image or incorrectly classifies the defect categories. At this time, the number of false positive data is increased by 1.
[0064] After traversing the plurality of target product images, the number of false negative data, the number of true positive data, and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined.
[0065] It should be noted that when the detection state is the false detection state, and the similarity between the defect category in the defect detection result of the target inferred data and the defect category corresponding to the detection parameter group is higher than the preset threshold, the number of true positive data is increased by 1. That is, when the detection result is determined as the false detection state, the defect category identified by the product defect detection model corresponding to the detection parameter group does not match the actual defect category. However, if the similarity evaluation shows that the similarity between the identified category and the actual category to be identified is higher than the preset threshold, it indicates that although the category identification has errors, the model's identification result is not completely without basis, but is close to the correct answer. This mechanism not only provides a more delicate model evaluation, but also encourages the model to make more accurate identification of similar categories, further optimizing the model's performance in complex classification tasks.
[0066] Optionally, in the technical solution provided in step S13, when the model performance indicator is represented by F1 score, it can be realized by the following steps:
[0067] First step: the quotient value of the number of true positive data divided by the sum of the number of true positive data and the number of false positive data is taken as the precision.
[0068] Second step: the quotient value of the number of true positive data divided by the sum of the number of true positive data and the number of false negative data is taken as the recall.
[0069] Third step: determine the F1 score corresponding to the detection parameter group according to the precision and recall. The F1 score is the harmonic mean of the precision and recall, that is .
[0070] In addition to the above-mentioned several implementation schemes, based on the basic concept of the present application, those skilled in the art can also determine the model performance indicators through other technical schemes, for example, through accuracy, precision, recall, ROC curve and AUC curve, etc., which should also be within the protection scope of the present application.
[0071] In the technical scheme provided in the above step S108, the system can take the detection parameter group with the highest model performance indicator as the target detection parameter group corresponding to the defect category, which means that these parameters can make the model achieve the best balance point when identifying this defect category, reducing both false positives and false negatives, thereby improving the overall detection effect.
[0072] Finally, load the product defect detection model according to the target detection parameter group into the memory, for example, load the data of the updated product defect detection model from the non-volatile memory to the volatile memory, so that the processor runs the product defect detection model. The data of the product defect detection model usually includes the parameters and structure data of the updated product defect detection model. The structure data can be a calculation relationship based on the parameters, such as the forward propagation calculation relationship between the intermediate layers and the neurons. Specifically, the structure data can include the structure-related code of the product defect detection model, such as the code for performing related calculations between the intermediate layers and the neurons.
[0073] In an embodiment, a region for loading the product defect detection model can be divided in the memory, which can include a structure data storage area and a parameter storage area. The structure data storage area is used to store the structure-related code, and the parameters referred to by the structure-related code can be pointed to the address of a specific parameter in the parameter storage area by a pointer. In the incremental optimization process of the product defect detection model, the parameters may need to be frequently updated, and then the parameter values in the parameter storage area can be updated.
[0074] The embodiment of the present application can periodically execute the above-mentioned model parameter automatic adjustment method to periodically comprehensively evaluate and compare the performance of the product defect detection model under multiple detection parameter group configurations, constantly find the target detection parameter group that can make the model performance indicator optimal, and ensure that the parameters of the product defect detection model are always in the optimal state, thereby helping to maintain the long-term stability and accuracy of the model, reducing the number of manual interventions, and improving the operation and maintenance efficiency.
[0075] Therefore, after the above model parameter automatic adjustment method is executed, the embodiments of the present application can also adjust the product defect detection model according to the target detection parameter group corresponding to each defect category, and call the adjusted product defect detection model to detect and analyze a plurality of real-time product images collected in real time on the product production line to obtain accurate defect detection results of each product image, thereby realizing the automation, intelligence and high efficiency of product defect detection, effectively preventing defective products from flowing into the next production link, reducing rework and waste, and improving overall production efficiency.
[0076] Embodiment 2
[0077] According to the embodiments of the present application, a model parameter automatic adjustment device for implementing the model parameter automatic adjustment method in Embodiment 1 is also provided, as shown in Figure 2 The model parameter automatic adjustment device at least includes an acquisition module 22, a performance evaluation module 24 and a determination module 26, wherein:
[0078] The acquisition module 22 is configured to acquire a plurality of sets of reasoning data of the product defect detection model when the model performance index of the product defect detection model is lower than the preset performance threshold, wherein each set of reasoning data includes a defect detection result corresponding to an image identifier and a detection state, and the defect detection result includes a defect category corresponding to each defect detection frame in the product image corresponding to the image identifier and a detection parameter group, and the detection parameter group includes at least one of the following: confidence, long axis, short axis, frame area;
[0079] The performance evaluation module 24 is configured to determine a plurality of detection parameter groups corresponding to each defect category in the product defect detection model from the plurality of sets of reasoning data, and determine a model performance index corresponding to each detection parameter group.
[0080] The determination module 26 is configured to determine the detection parameter group with the highest model performance index as the target detection parameter group corresponding to the defect category.
[0081] The functions of each module of the model parameter automatic adjustment device will be described below in combination with the specific implementation process.
[0082] Specifically, the product defect detection model refers to a deep learning model trained for product defect recognition, including but not limited to YOLOv8 or other types of neural network models. The model performance index refers to the performance of the product defect detection model under a specific index, and once the model performance index is lower than the preset performance threshold, the system will trigger the model automatic parameter adjustment mechanism.
[0083] When the model is automatically adjusted, the acquisition module 22 can directly acquire a plurality of sets of data of the product defect detection model from the preset incremental database and perform post-processing to obtain a plurality of sets of reasoning data.
[0084] Optionally, the acquisition module 22 can acquire the multiple sets of inferred data of the product defect detection model according to the following steps, comprising:
[0085] Step 1: Use an image acquisition device to acquire multiple product images on a product production line.
[0086] Step 2: For each product image, acquire a defect detection result obtained by using the product defect detection model to analyze the product image, and determine a detection state of the product image according to the defect detection result and a manually annotated defect result corresponding to the product image, wherein the manually annotated defect result includes: each defect real box in the product image and a corresponding defect category, and the defect category includes but is not limited to: crack, scratch, stain, etc., and the detection state includes one of the following: detection state, false detection state, over-detection state, missed detection no-frame state, and missed detection frame state.
[0087] Step 3: The defect detection result and the detection state of the corresponding product image of each image identifier form a multiple set of inferred data of the product defect detection model.
[0088] Specifically, the detection state of the product image can be determined according to the following method:
[0089] When the defect category in the defect detection result is the same as the defect category in the corresponding manually annotated defect result, and the intersection-over-union between the defect detection box in the defect detection result and the defect real box in the manually annotated defect result is higher than a preset threshold value, it indicates that the model can correctly detect the defect category in the product image, so the detection state of the product image can be determined as the detection state;
[0090] When the defect category in the defect detection result is different from the defect category in the corresponding manually annotated defect result, but the intersection-over-union between the defect detection box in the defect detection result and the defect real box in the manually annotated defect result is higher than the preset threshold value, it indicates that the model incorrectly identifies a certain defect category as another defect category, so the detection state of the product image can be determined as the false detection state;
[0091] When the defect category in the defect detection result is not empty but the defect category in the corresponding manually annotated defect result is empty, the detection state of the product image is determined as the over-detection state;
[0092] When the defect category in the defect detection result is empty but the defect category in the corresponding manually annotated defect result is not empty, the detection state of the product image is determined as the missed detection no-frame state;
[0093] When the defect class in the defect detection result and the corresponding manually-annotated defect result is not empty, but the number of defect classes in the defect detection result is inconsistent with the number of defect classes in the manually-annotated defect result, it indicates that the model has recognized some defect classes, but has failed to completely or correctly recognize all real defect classes, and therefore the detection state of the product image can be determined as a missed detection with a bounding box state.
[0094] The determination logic of the above detection states follows the common performance evaluation standard in the defect detection field, i.e., correct detection (detection state), false classification (false detection state), additional detection (over detection state), and undetected (missed detection state). Through the explicit definition of these states, the performance change of the model after updating the detection parameter group can be comprehensively evaluated.
[0095] Further, for each defect class preset in the product defect detection model, the performance evaluation module 24 determines a plurality of detection parameter groups corresponding to the defect class from the plurality of groups of inferred data, and determines a model performance index corresponding to each detection parameter group.
[0096] Optionally, the performance evaluation module 24 can determine the model performance index corresponding to each detection parameter group according to the following method, comprising:
[0097] Step S21, for each detection parameter group, determining a plurality of groups of target inferred data containing the detection parameter group from the plurality of groups of inferred data.
[0098] Step S22, determining the number of false negative data, the number of true positive data, and the number of false positive data of the product defect detection model corresponding to the detection parameter group according to the defect detection result and the detection state in the plurality of groups of target inferred data.
[0099] Step S23, determining the model performance index corresponding to the detection parameter group according to the number of false negative data, the number of true positive data, and the number of false positive data.
[0100] Specifically, for the technical solution provided in the above step S22, the implementation process comprises:
[0101] First, the number of false positive data, the number of true positive sample data, and the number of false negative data are initialized to 0, wherein the number of false positive data is used to record the number of times that the model fails to correctly recognize the defect class, the number of true positive sample data is used to record the number of times that the model correctly recognizes the defect class, and the number of false negative data is used to record the number of times that the model incorrectly recognizes the non-existing defect class.
[0102] Next, the plurality of groups of target inferred data are traversed in sequence to determine the detection state in the target inferred data.
[0103] When the detection state is the missed detection no-frame state, it means that the product defect detection model corresponding to the detection parameter set fails to recognize the defect category in the product image, and at this time, the number of false negative data is increased by 1.
[0104] When the detection state is the missed detection with-frame state or the detection state and the detection parameter set in the defect detection result of the target inference data is greater than the detection parameter set, it means that the product defect detection model corresponding to the detection parameter set successfully and sufficiently recognizes the defect category in the product image, and at this time, the number of true positive data is increased by 1.
[0105] When the detection state is the missed detection with-frame state or the detection state, but any one of the detection parameter set in the defect detection result of the target inference data is not greater than the detection parameter set, it means that the product defect detection model corresponding to the detection parameter set recognizes the defect category in the product image, but may fail to correctly recognize the defect due to too strict parameter setting, and at this time, the number of false negative data is increased by 1.
[0106] When the detection state is the over detection state or the false detection state and the detection parameter set in the defect detection result of the target inference data is greater than the detection parameter set, it means that the product defect detection model corresponding to the detection parameter set incorrectly recognizes the defect category that does not exist in the product image or incorrectly classifies the defect category, and at this time, the number of false positive data is increased by 1.
[0107] After traversing the plurality of target product images, the number of false negative data, the number of true positive data and the number of false positive data of the product defect detection model corresponding to the detection parameter set are determined.
[0108] It should be noted that when the detection state is the false detection state and the similarity of the defect category in the defect detection result of the target inference data and the defect category corresponding to the detection parameter set is higher than the preset threshold, the number of true positive data is increased by 1. That is, when the detection result is determined as the false detection state, that is, the defect category recognized by the product defect detection model corresponding to the detection parameter set does not match the actual defect category. But if the similarity evaluation shows that the similarity between the category recognized by the model and the category that should be recognized is higher than the preset threshold, it means that although the category recognition has errors, the result recognized by the model is not completely without basis, but close to the correct answer. This mechanism not only provides more delicate model evaluation, but also encourages the model to make more accurate recognition of similar categories, further optimizing the performance of the model in complex classification tasks.
[0109] Optionally, in the technical scheme provided in the above step S23, when the model performance indicator is represented by F1 score, it can be realized by the following steps:
[0110] First step: the quotient value obtained by dividing the number of true positive data by the sum of the number of true positive data and the number of false positive data is taken as the precision.
[0111] Second step: divide the number of positive positive data by the quotient of the sum of the number of positive positive data and the number of false negative data as the recall rate.
[0112] Third step: determine the F1 score corresponding to the detection parameter group according to the precision and recall. The F1 score is the harmonic mean of the precision and the recall.
[0113] In addition to the above-mentioned several implementation schemes, based on the basic idea of the present application, those skilled in the art can also determine the model performance index through other technical schemes, for example, through accuracy, precision, recall, ROC curve and AUC curve, etc., which should also be within the protection scope of the present application.
[0114] Finally, the determination module 26 can adjust the detection parameter group with the highest model performance index as the target detection parameter group corresponding to the defect category. This means that the target detection parameter group can make the model achieve the best balance point when identifying the defect category, reducing both false positives and false negatives, thereby improving the overall detection effect.
[0115] It should be noted that each module in the model parameter automatic adjustment device in the embodiment of the present application corresponds to each implementation step of the model parameter automatic adjustment method in embodiment 1. Since embodiment 1 has been described in detail, the details not embodied in this embodiment can be referred to embodiment 1, and will not be described in detail here.
[0116] Embodiment 3
[0117] According to the embodiments of the present application, a computer program product is also provided, which includes a computer program, wherein the computer program is executed by a processor to implement the model parameter automatic adjustment method in embodiment 1.
[0118] According to the embodiments of the present application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device in which the non-volatile storage medium is located executes the model parameter automatic adjustment method in embodiment 1 by running the computer program.
[0119] According to the embodiments of the present application, a processor is also provided, which is used to run a computer program, wherein the computer program is executed to implement the model parameter automatic adjustment method in embodiment 1.
[0120] According to the embodiments of the present application, an electronic device is also provided, which includes a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the model parameter automatic adjustment method in embodiment 1 through the computer program.
[0121] Specifically, the computer program runs to implement the following steps: when the model performance indicator of the product defect detection model is lower than a preset performance threshold, obtaining a plurality of sets of inferred data of the product defect detection model, wherein each set of inferred data includes: an image identifier corresponding defect detection result and detection state, and the defect detection result includes: a defect category and a detection parameter group corresponding to each defect detection frame in the product image corresponding to the image identifier, and the detection parameter group includes at least one of: confidence, long axis, short axis, and frame area; for each defect category preset in the product defect detection model, determining a plurality of detection parameter groups corresponding to the defect category from the plurality of sets of inferred data, and determining a model performance indicator corresponding to each detection parameter group; and taking the detection parameter group with the highest model performance indicator as the target detection parameter group corresponding to the defect category.
[0122] As an optional implementation, the electronic device can exist in the form of a mobile terminal, a computer terminal, or a similar computing device. Figure 3 A hardware structure block diagram of a computer terminal for implementing the model parameter automatic adjustment method is shown. As shown in Figure 3 The computer terminal 30 can include one or more processors 302 (the processor 302 can include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 304 for storing data, and a transmission device 306 for communication functions. In addition, it can also include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports in the BUS bus), a network interface, a power supply and / or a camera. Those skilled in the art can understand that Figure 3 The structure shown is only schematic, and does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal 30 can include more or fewer components than those shown in Figure 3 or have a different configuration than that shown in Figure 3 .
[0123] It should be noted that the one or more processors 302 and / or other data processing circuits described above can be referred to herein as "data processing circuits" in general. The data processing circuit can be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuit can be a single independent processing module, or all or part of any one of the other elements combined into the computer terminal 30. As referred to in the embodiments of the present application, the data processing circuit serves as a processor control (for example, selection of a variable resistance terminal path connected to an interface).
[0124] The memory 304 can be used to store software programs of application software and modules, such as program instructions / data storage means corresponding to the model parameter automatic adjustment method in the embodiments of the present application, and the processor 302 executes various functional applications and data processing by running the software programs and modules stored in the memory 304, that is, implements the vulnerability detection method of the application program described above. The memory 304 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 304 can further include a memory remotely arranged with respect to the processor 302, which can be connected to the computer terminal 30 through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0125] The transmission device 306 is used to receive or send data via a network. The specific examples of the above-mentioned network can include a wireless network provided by a communication provider of the computer terminal 30. In one example, the transmission device 306 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 306 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
[0126] The display can be, for example, a touch screen type liquid crystal display (LCD), which can enable the user to interact with the user interface of the computer terminal 30.
[0127] The above-mentioned embodiment numbers are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0128] In the above-mentioned embodiments of the present application, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0129] In the several embodiments of the present application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the above-mentioned device embodiments are only schematic, for example, the division of units can be a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.
[0130] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, i.e. may be located in one place, or may be distributed to multiple units. Part or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
[0131] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware, or in the form of a software functional unit.
[0132] If the integrated unit is realized in the form of 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, the technical solutions of the present application, the essential part or contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various program code storage media.
[0133] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should also be considered as the protection scope of the present application.
Claims
1. A method for adjusting model parameters, characterized in that, include: When the performance index of the product defect detection model is lower than the preset performance threshold, multiple sets of inferred data of the product defect detection model are obtained. Each set of inferred data includes: defect detection results and detection status corresponding to the image identifier. The defect detection results include: defect category and detection parameter group corresponding to each defect detection box in the product image corresponding to the image identifier. The detection parameter group includes at least one of the following: confidence, major axis, minor axis, and box area. The detection status includes one of the following: detection status, false detection status, over-detection status, missed detection without box status, and missed detection with box status. For each defect category preset in the product defect detection model, multiple detection parameter groups corresponding to the defect category are determined from the multiple sets of inferred data, and model performance indicators corresponding to each detection parameter group are determined, including: for each detection parameter group, multiple sets of target inferred data containing the detection parameter group are determined from the multiple sets of inferred data; the number of false positive data, the number of positive data, and the number of false negative data are initialized to 0; the multiple sets of target inferred data are sequentially traversed to determine the detection state in the target inferred data; when the detection state is a missed detection without a frame, the number of false negative data is incremented by 1; when the detection state is a missed detection with a frame or a detected state and the detection parameter groups in the defect detection results of the target inferred data are all greater than the detection parameter. When a group of data is detected, the number of positive data is incremented by 1. When the detection state is either a missed detection or a detected state, but any item in the detection parameter group of the defect detection result of the target inferred data is not greater than the detection parameter group, the number of false negative data is incremented by 1. When the detection state is either an over-detection or a false detection state, and all detection parameter groups in the defect detection result of the target inferred data are greater than the detection parameter group, the number of false positive data is incremented by 1. After traversing the multiple groups of target inferred data, the number of false negative data, the number of positive data, and the number of false positive data of the product defect detection model corresponding to the detection parameter group are determined. The model performance index corresponding to the detection parameter group is determined based on the number of false negative data, the number of positive data, and the number of false positive data. The detection parameter group with the highest model performance index is adjusted to the target detection parameter group corresponding to the defect category.
2. The method according to claim 1, characterized in that, Obtain multiple sets of inferred data from the product defect detection model, including: The image acquisition device is used to acquire multiple product images from the product production line and the image identifier of each product image. For each product image, obtain the defect detection result obtained by detecting and analyzing the product image using the product defect detection model, and determine the detection status of the product image based on the defect detection result and the manually annotated defect result corresponding to the product image. The manually annotated defect result includes: the ground truth bounding box of each defect in the product image and the corresponding defect category. The product defect detection model consists of multiple sets of inferred data, which are composed of the defect detection results and detection status of the product images corresponding to each of the image identifiers.
3. The method according to claim 2, characterized in that, The detection status of the product image is determined based on the defect detection results and the manually annotated defect results corresponding to the product image, including: When the defect category in the defect detection result is the same as the defect category in the corresponding manually labeled defect result, and the intersection-union ratio between the defect detection box in the defect detection result and the defect real box in the manually labeled defect result is higher than a preset threshold, the detection state of the product image is determined to be a detection state. If the defect category in the defect detection result is different from the defect category in the corresponding manually labeled defect result, but the intersection-union ratio between the defect detection box in the defect detection result and the defect true box in the manually labeled defect result is higher than a preset threshold, the detection state of the product image is determined to be a false detection state. When the defect category in the defect detection result is not empty but the defect category in the corresponding manually labeled defect result is empty, the detection status of the product image is determined to be an over-detection status. When the defect category in the defect detection result is empty but the defect category in the corresponding manually annotated defect result is not empty, the detection status of the product image is determined to be a missed detection and frameless state. If the defect categories in both the defect detection results and the corresponding manually labeled defect results are not empty, but the number of defect categories in the defect detection results is inconsistent with the number of defect categories in the manually labeled defect results, then the detection status of the product image is determined to be a missed detection with frame.
4. The method according to claim 1, characterized in that, The method further includes: When the detection state is a false detection state and the similarity between the defect category in the defect detection result of the target reasoned data and the defect category corresponding to the detection parameter group is higher than a preset threshold, the number of positive data is incremented by 1.
5. The method according to claim 1, characterized in that, The model performance metrics include at least the F1 score, wherein the model performance metrics corresponding to the detection parameter set are determined based on the number of false negative data, the number of positive data, and the number of false positive data, including: The accuracy rate is the quotient of the number of positive data points divided by the sum of the number of positive data points and the number of false positive data points. The recall rate is the quotient of the number of positive data points divided by the sum of the number of positive data points and the number of false negative data points. The F1 score corresponding to the detection parameter set is determined based on the precision and the recall.
6. A model parameter adjustment device, characterized in that, include: The acquisition module is used to acquire multiple sets of inferred data of the product defect detection model when the model performance index of the product defect detection model is lower than a preset performance threshold. Each set of inferred data includes: defect detection results and detection status corresponding to the image identifier. The defect detection results include: defect category and detection parameter group corresponding to each defect detection box in the product image corresponding to the image identifier. The detection parameter group includes at least one of the following: confidence level, major axis, minor axis, and box area. The detection status includes one of the following: detection status, false detection status, over-detection status, missed detection without box status, and missed detection with box status. The performance evaluation module is used to determine multiple detection parameter groups corresponding to each defect category preset in the product defect detection model from the multiple sets of inferred data, and to determine the model performance index corresponding to each detection parameter group. This includes: for each detection parameter group, determining multiple sets of target inferred data containing the detection parameter group from the multiple sets of inferred data; initializing the number of false positives, positives, and false negatives to 0; sequentially traversing the multiple sets of target inferred data to determine the detection state in the target inferred data; when the detection state is a missed detection without a frame, incrementing the number of false negatives by 1; and when the detection state is a missed detection with a frame or a detected state and all detection parameter groups in the defect detection results of the target inferred data are greater than the specified value. When detecting parameter groups, increment the number of positive data by 1; when the detection state is a missed detection with a frame or a detected state, but any item in the detection parameter group of the defect detection result of the target inferred data is not greater than the detection parameter group, increment the number of false negative data by 1; when the detection state is an over-detection state or a false detection state and all detection parameter groups in the defect detection result of the target inferred data are greater than the detection parameter group, increment the number of false positive data by 1; after traversing the multiple sets of target inferred data, determine the number of false negative data, the number of positive data, and the number of false positive data of the product defect detection model corresponding to the detection parameter group; determine the model performance index corresponding to the detection parameter group based on the number of false negative data, the number of positive data, and the number of false positive data. The determination module is used to adjust the detection parameter group with the highest model performance index to the target detection parameter group corresponding to the defect category.
7. A computer program product, characterized in that, include: A computer program, wherein when executed by a processor, the computer program implements the model parameter adjustment method according to any one of claims 1 to 5.
8. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the model parameter adjustment method of any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
Deep learning model evaluation method for industrial detection
CN115908398A
Defect detection model parameter construction method, controller, medium and product
CN119810509A