CN116797579A - Defect level determining method and device, electronic equipment and storage medium - Google Patents
Defect level determining method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN116797579A CN116797579A CN202310773186.3A CN202310773186A CN116797579A CN 116797579 A CN116797579 A CN 116797579A CN 202310773186 A CN202310773186 A CN 202310773186A CN 116797579 A CN116797579 A CN 116797579A
- Authority
- CN
- China
- Prior art keywords
- defect
- image
- determining
- data
- defect level
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000007547 defect Effects 0.000 title claims abstract description 469
- 238000000034 method Methods 0.000 title claims abstract description 56
- 238000003860 storage Methods 0.000 title claims abstract description 20
- 238000012549 training Methods 0.000 claims abstract description 63
- 238000010801 machine learning Methods 0.000 claims abstract description 34
- 238000012360 testing method Methods 0.000 claims description 39
- 230000002950 deficient Effects 0.000 claims description 21
- 238000002372 labelling Methods 0.000 claims description 17
- 238000004590 computer program Methods 0.000 claims description 16
- 238000012545 processing Methods 0.000 claims description 15
- 238000011156 evaluation Methods 0.000 abstract description 10
- 238000001514 detection method Methods 0.000 description 20
- 230000008569 process Effects 0.000 description 9
- 238000004891 communication Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 8
- 230000005856 abnormality Effects 0.000 description 7
- 238000005070 sampling Methods 0.000 description 7
- 230000002159 abnormal effect Effects 0.000 description 6
- 238000000605 extraction Methods 0.000 description 5
- 238000004364 calculation method Methods 0.000 description 4
- 238000004519 manufacturing process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 241001270131 Agaricus moelleri Species 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000007689 inspection Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012706 support-vector machine Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Landscapes
- Image Analysis (AREA)
Abstract
The invention discloses a defect level determining method, a defect level determining device, electronic equipment and a storage medium. The method comprises the following steps: determining sample data of at least two defect levels, the sample data comprising size feature data and image gray scale feature data; training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model; and inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model. The technical scheme of the invention can realize the grading evaluation of the appearance defects.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and apparatus for determining a defect level, an electronic device, and a storage medium.
Background
In the field of industrial machine vision inspection, the inspection result of an appearance defect is generally to judge NG or OK according to the degree of the appearance defect. However, since the manufacturing process and the production stage of the product are different, the determination criterion of the appearance defect detection result is adjusted to different degrees, and it is necessary to clearly detect the degree level of the appearance defect and adjust the determination criterion of the appearance defect detection result with the degree of the appearance defect as the criterion. Therefore, how to accurately and stably classify the degree of the appearance defect is an important subject in the field of industrial machine vision detection.
Disclosure of Invention
The invention provides a defect level determining method, device, electronic equipment and storage medium, so as to realize grading evaluation of appearance defects.
In a first aspect, an embodiment of the present invention provides a method for determining a defect level, where the method includes:
determining sample data of at least two defect levels, the sample data comprising size feature data and image gray scale feature data;
training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model;
and inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
In a second aspect, an embodiment of the present invention further provides a device for determining a defect level, where the device includes:
a sample data determining module for determining sample data of at least two defect levels, the sample data including size feature data and image gray scale feature data;
the defect level determining model determining module is used for training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model;
And the defect level result determining module is used for inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements a method for determining a defect level according to any one of the embodiments of the present invention when the processor executes the program.
In a fourth aspect, embodiments of the present invention also provide a storage medium storing computer-executable instructions that, when executed by a computer processor, are configured to perform a method of determining a defect level according to any of the embodiments of the present invention.
According to the technical scheme, through determining sample data of a plurality of different defect levels, the sample data comprise size characteristic data and image gray scale characteristic data, training a preset machine learning model through the sample data to obtain a defect level determination model, and determining the defect level of an image to be processed through the defect level determination model. The problem that in the prior art, only two appearance defect detection results of NG or OK can be made, and the method can not adapt to different sites of appearance defect detection, and the judgment standard of the appearance defect detection results is adjusted is solved, so that the grading evaluation of the appearance defects is realized.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for determining a defect level according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a different defect level provided by a first embodiment of the present invention;
FIG. 3 is a flowchart of a method for determining a defect level according to a second embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a defect level determining apparatus according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a method for determining a defect level according to an embodiment of the present invention, where the method may be applied to performing appearance defect grading evaluation on an image to be processed obtained by capturing a product to be detected, and the method may be performed by a defect level determining device, where the defect level determining device may be implemented in a form of hardware and/or software, and the defect level determining device may be configured in an electronic device.
As shown in fig. 1, the method includes:
s110, determining sample data of at least two defect levels, wherein the sample data comprises size characteristic data and image gray scale characteristic data.
Wherein the defect levels are a hierarchical description of defects according to different levels of defects, fig. 2 provides a schematic diagram of different defect levels, wherein fig. 2 includes five small diagrams, the defect level of fig. 2 (1) is the slightest, the defect level of fig. 2 (2) is relatively slight, the defect level of fig. 2 (3) is moderate, the defect level of fig. 2 (4) is relatively serious, and the defect level of fig. 2 (5) is particularly serious. In particular, the defect levels may be represented by numbers or letters, and the number of types of defect levels is at least two. For example, 1, 2, and 3 … … may be used to represent different defect levels, and a larger number may represent a more serious defect level, and A, B, C … … may represent a different defect level, and a more serious defect level may be represented by a more posterior alphabetical order, but the number, the appearance, and the defect levels corresponding to different appearance of the defect levels are not limited in this embodiment.
The sample data may include historical sample data and/or sample data composed of a defect profile, a defect level, feature data and the like determined according to the defect image. The historical sample data refers to stored sample data, and can comprise defect levels, defect quantity, size characteristic data, image gray characteristic data, wherein a defect image corresponding to the historical sample data is an image marked with defect outlines and defect levels, so that the storage space is saved, the historical sample data can not store the defect image, and only the defect levels, the defect quantity, the size characteristic data, the image gray characteristic data and other information can be reserved. When the sample data comprises sample data composed of defect contours, defect levels, feature data and the like which are determined according to the defect images, firstly obtaining the defect images, carrying out defect contour extraction and defect level marking on the defect images, and calculating size feature data and image gray feature data according to the defect images.
Wherein the dimensional characteristic data comprises at least one of: defect length, defect width, and other dimensional characteristic data calculated from the defect length and/or defect width; the image gray scale characteristic data includes at least one of: defect image contrast, defect image gray scale, and other image gray scale characteristic data calculated according to the defect image contrast and/or the defect image gray scale.
By way of example, the dimensional characteristic data may include a maximum length of the defect (maximum value of the defect in the length direction), a minimum length of the defect (minimum value of the defect in the length direction), an average length of the defect, a maximum width of the defect (maximum value of the defect in the width direction), a minimum width of the defect (minimum value of the defect in the width direction), an average width of the defect, an area of the defect, and the like. The image gradation characteristic data may include a defective image contrast, a defective image gradation mean, a defective image gradation difference value (difference between a gradation maximum value and a gradation minimum value in a defective image), a defective image gradation variance, and the like. The present embodiment does not limit the types, specific numbers, and calculation modes of the size feature data and the image gradation feature data.
In this embodiment, sample data of a plurality of defect levels are determined, so that a defect level determination model obtained by training according to the sample data can be used for performing hierarchical evaluation on the appearance defects. Meanwhile, the sample data comprises size characteristic data and image gray characteristic data, and model training is carried out through the characteristics of the size, gray and the like of the defects, so that the accuracy of a defect level determination result of the model can be improved.
Furthermore, the sample data can be normalized to eliminate the influence of large difference of the sample data values on the model training effect.
S120, training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model.
The machine learning model may be an SVM (Support Vector Machines, support vector machine) model, which is a two-class model, and the SVM model may be fused with different feature information of the defect to realize the degree judgment of the defect, however, the specific type of the machine learning model is not limited in this embodiment.
In this embodiment, model training is performed by using sample data of a plurality of defect levels, and the obtained defect level determination model can perform hierarchical evaluation on external defects. Meanwhile, as the defect level result of the defect level determining model is obtained by integrating a plurality of dimensional characteristics, the characteristics of the defect level determining model can be adjusted according to the sites of different appearance defect detection, so that the defect level determining model can be more suitable for the actual conditions of different appearance defect detection sites.
Further, S120 may further include: determining at least two feature combinations according to the size features and the image gray features matched with the sample data of the at least two defect levels; training a preset machine learning model through sample data matched with the candidate feature combination to obtain a candidate defect level determining model; and determining a target defect level determination model in the candidate defect level determination models, and determining a target feature combination matched with the target defect level determination model.
Wherein, the correlation between different characteristics and defect levels is different, and the influence degree of different characteristics on the defect levels is different, so that the accuracy of the defect level determination results corresponding to different characteristic combinations is also different. Therefore, in this embodiment, for all the size features and the image gray level features, different feature combinations are determined, model training is performed on the different feature combinations, a model with an optimal model training result is selected as a target defect level determination model, and the feature combination with the optimal model training result is used as a target feature combination. The optimal model training result may mean that the model accuracy is highest.
Further, for different feature numbers, the feature combination with the highest model accuracy is respectively determined. And determining the use frequency of each feature according to the feature combination with the highest model accuracy under the feature quantity, wherein the key feature with higher use frequency has stronger correlation with the defect level determination result, and the key feature with lower use frequency has weaker correlation with the defect level determination result. Thus, a predetermined number of features having the highest frequency of use may be selected as the target feature combination of the target defect level determination model.
For example, if the size features and the image gray features include 15, and the minimum number of features required for model training is 5, when the feature combinations include 5-15 features, the feature combinations with the highest model accuracy are respectively determined. And counting the use frequency of different features in the feature combination with the highest model accuracy, and selecting 6 features with the highest use frequency as target defect levels to determine the target feature combination of the model. By way of example, the 6 features with highest frequency of use may be defect minimum length, defect maximum length, defect average width, defect image contrast, and defect image gray variance, respectively.
In this embodiment, the optimal feature combination is determined, so that accuracy of determining the model defect level can be improved.
S130, inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
The image to be processed is an image obtained by shooting a product with an appearance defect to be detected, or an image obtained by further processing the shot image, where the further processing may refer to rotation, clipping, extraction of a region of interest, binarization processing, or the like, which is not limited in this embodiment.
In this embodiment, the defect level determination model obtained by performing model training on sample data of a plurality of defect types determines the defect level of the appearance defect on the image to be processed, and the obtained defect level result is a determination result obtained by combining multi-dimensional characteristics of the defect, so that the defect level can be detected more accurately, different processing modes can be adopted to adjust the production process for defects of different levels, and the labor cost and equipment maintenance cost for detecting the appearance defect are reduced.
According to the technical scheme, through determining sample data of a plurality of different defect levels, the sample data comprise size characteristic data and image gray scale characteristic data, training a preset machine learning model through the sample data to obtain a defect level determination model, and determining the defect level of an image to be processed through the defect level determination model. The problem that in the prior art, only two appearance defect detection results of NG or OK can be made, and the method can not adapt to different sites of appearance defect detection, and the judgment standard of the appearance defect detection results is adjusted is solved, so that the grading evaluation of the appearance defects is realized.
Example two
Fig. 3 is a flowchart of a method for determining a defect level according to a second embodiment of the present invention, where the process of determining sample data and the process of model training are further embodied based on the foregoing embodiment, and a process of repairing deviation sample data in the model training process is added.
As shown in fig. 3, the method includes:
s210, determining defect outlines and defect level marking results of at least two defect images.
In this embodiment, defect contour extraction and defect level labeling are performed on each defect image. Further, each defect image at least comprises two defect categories, and the number of the defect images of different defect categories should be distributed and balanced so as to avoid the influence of uneven distribution of the number of the defect images of different defect categories on the model training effect. For example, if the defect levels include 5 types in total, it may be determined that the total number of defect images is greater than 3000 and the number of defect images corresponding to each defect level is not less than 500, but the present embodiment does not limit the total number of defect images and the number of defect images corresponding to different defect levels.
Specifically, in order to ensure the accuracy and objectivity of the defect level labeling, determining the defect level labeling result of the defect image, performing random sampling on each defect image, performing defect level labeling on the sampled defect image through an expert group, and determining the defect level labeling result of the sampled defect image by integrating the defect level labeling conditions of each expert in the expert group on the sampled defect image. And for the rest of defect images except the sampling defect image, marking the defect level of the rest of defect images by marking the defect level marking conditions of each expert in the group of reference experts on the sampling defect image, and determining the defect level marking result of the rest of defect images by integrating the defect level marking conditions of each marking person in the group of reference experts on the rest of defect images. And summarizing the defect level labeling results of the sampled defect images and the defect level labeling results of the rest defect images to obtain the defect level labeling results of all the defect images. The defect level marking condition of each expert in the expert group on the sampling defect image is comprehensively combined, a defect level marking result of the sampling defect image is determined, and if the defect level comprises 5 types, the defect level is respectively represented by numbers 1-5, the greater the number is, the more serious the defect degree is represented, the defect level of each expert in the expert group on the sampling defect image A is respectively marked as 2, 3, 2 and 2, and then the defect level marking result of the sampling defect image A can be determined as 2. Similarly, the defect level marking conditions of the scoring persons on the rest of the defect images in the scoring group are synthesized, the defect level marking results of the rest of the defect images are determined, and if the defect levels of the scoring persons on the rest of the defect images C in the scoring group are respectively marked as 1, 2, 3 and 2, the defect level marking results of the rest of the defect images C can be determined to be 2.
Further, when determining the marking result of the defect level of the defect image, marking results with marked anomalies obviously existing in a plurality of marking persons can be removed, and for example, if the defect level of the defect image M is marked as 1, 2, 4 and 2 respectively, the marking result 4 can be removed, and then the marking result of the defect level of the defect image can be determined according to the remaining marking conditions of the defect level.
Further, when the defect level marking is performed on the defect image, in order to ensure the accuracy and uniformity of the defect level marking result, the marking tool, the label format and other contents are required to be ensured to be kept uniform.
Furthermore, after the defect contour extraction and the defect level labeling are performed on the defect image, the foreground area and the background area of the defect image can be separated, so that the interference of the background area on the defect image can be avoided.
S220, determining size characteristic data matched with the defect image according to the defect outline of the defect image, and determining image gray scale characteristic data matched with the defect image according to the defect image.
In this embodiment, size feature data such as a maximum length of a defect, a minimum length of a defect, an average length of a defect, a maximum width of a defect, a minimum width of a defect, an average width of a defect, and an area of a defect are determined according to a defect contour in a defect image. And determining image gray characteristic data such as defect image contrast, defect image gray mean value, defect image gray difference value, defect image gray variance and the like for the defect image.
When the image gray feature data includes a defective image contrast, S220 may further include: determining a background area of the defect image; according to the defect image and the background area, determining a gray average value of a bright gray scale image and a gray average value of a dark gray scale image; and determining the gray average value of the absolute value image according to the gray average value of the bright gray image and the gray average value of the dark gray image, and taking the gray average value of the absolute value image as the defect image contrast of the defect image.
In the prior art, the contrast is usually calculated by respectively calculating the gray average value of the foreground region and the gray average value of the background region, wherein the gray average value is calculated by the ratio of the sum of gray values of all pixel points in the region to the area of the region. However, such a method of calculating the contrast is affected by the cancellation of the bright and dark gray scales, and thus the result of calculating the contrast is inaccurate. To eliminate the influence of the cancellation of the bright and dark gray scales on the contrast calculation, the contrast is calculated from the absolute value image in this embodiment.
Specifically, the contrast ratio can be calculated by the following formula:wherein G is Light Representing a bright gray-scale image, G Dark A dark gray scale image is represented, G1 represents a defective image, G2 represents a background area, G represents an absolute value image, mult represents a multiplication coefficient, add represents an addition coefficient, where mult=1, add=0. G 1 -G 2 If the gray average value of the defect image is larger than the gray average value of the background area, calculating the difference value between the gray average value of the defect image and the gray average value of the background area, otherwise, G 1 -G 2 And is determined to be 0. Similarly, G 2 -G 1 If the gray average value of the background area is larger than the gray average value of the defect image, calculating the difference value between the gray average value of the background area and the gray average value of the defect image, otherwise, G 2 -G 1 And is determined to be 0.
Further, when the image gray feature data includes a defective image gray difference value, determining image gray feature data matching the defective image according to the defective image, including: removing abnormal gray values in the gray values of the defect image according to a preset abnormal proportion; and taking the difference value between the maximum gray value and the minimum gray value in each gray value after the abnormal gray value is removed as the gray difference value of the defect image.
For example, the anomaly ratio may be 5%, a smaller 5% gray value among the gray values of the defect image is removed, and a larger 5% gray value is calculated from a gray value maximum value and a gray value minimum value among the remaining gray values. In the present embodiment, the stability of the gradation difference value is improved by removing the abnormal gradation value from among the gradation values of the defective image by the abnormal ratio.
Further, when the image gray feature data includes a defective image gray variance, determining image gray feature data matching the defective image according to the defective image, including:
the defective image gray variance is calculated by the following formula:here, the displacement represents the gray variance, mean represents the gray Mean, R represents the region where the gray Mean is calculated, R is a defective image in this embodiment, p represents the pixel point in the R region, F represents the area of the R region, and G (p) represents the gray value of the p point.
S230, dividing the sample data of the at least two defect levels into training data and test data.
In this embodiment, the ratio of the training data to the test data may be 8:2, and the training data and the test data are divided by adopting a random division method, but the ratio of the training data to the test data is not limited in this embodiment.
S240, training a preset machine learning model according to the training data, and testing the machine learning model after training according to the testing data.
Taking a machine learning model as an example of an SVM model, in the embodiment, training the SVM model by training data, inputting test data into the trained SVM model, and judging whether the defect classification of the trained SVM model on the test data is correct or not.
S250, judging whether the accuracy of the machine learning model after training is greater than or equal to a preset accuracy threshold, if so, executing S2690, otherwise, returning to executing S240.
In this embodiment, test data is input to the trained SVM model, and the accuracy of defect classification of each test data by the trained SVM model is counted. Otherwise, the SVM model is considered to incorrectly rank the defects of the test data. And counting the accuracy of the defect grading result of the SVM model on each test data, and recording the test data with incorrect defect grading.
It should be noted that, in this embodiment, the accuracy of the machine learning model after training is used as a judgment basis to judge whether the model training is completed, or alternatively, whether the model training is completed may also be judged based on whether the number of times of model training is greater than or equal to a preset number of times threshold. Or, the two judging conditions can be combined to be used as judging basis for judging whether model training is completed or not. In this embodiment, by limiting the number of model training, model overfitting can be avoided.
And when the number of the types of the defect levels is larger than or equal to a preset number threshold, if the level difference between the defect level prediction result corresponding to the target test data and the defect level marking result corresponding to the target test data is smaller than or equal to a preset deviation, determining that the target test data is accurately predicted.
Further, in the present embodiment, when the number of types of defect levels is large, the limitation of the condition of whether the classification of the defects of the model is accurate can be appropriately relaxed. For example, when 5 defect levels are respectively represented by 1-5, inputting the target test data into the trained SVM model to obtain a defect level prediction result, and when the level difference of the defect level prediction result and the defect level labeling result corresponding to the target test data is within 1 (including 1), accurately predicting the target test data.
Further, it may be determined that the deviation sample data of which the level difference between the defect level prediction result and the defect level labeling result is greater than the preset deviation, and at least one of the following processes is performed on the defect image corresponding to the deviation sample data: redetermining the defect contour, redetermining the defect level labeling result, redetermining the size characteristic data, and redetermining the image gray scale characteristic data.
In this embodiment, for test data in which the level difference between the defect level prediction result and the defect level labeling result is greater than a preset deviation, the test data is used as deviation sample data. Recording each deviation sample data, and analyzing the reason of the grading abnormality of each deviation sample data. For example, the reasons for the classification abnormality may include an extracted defect contour error (larger or smaller), a defect level labeling error (higher or lower), a contrast or gray calculation abnormality due to factors such as a lower brightness of the photographing environment, and the like. Correspondingly, when the reason of the grading abnormality is that the extracted defect outline is wrong, the defect outline is redetermined, and the defect level marking result, the size characteristic data and the image gray characteristic data are redetermined; when the reason of the grading abnormality is defect level marking errors, the defect level marking result is redetermined, and the size characteristic data and the image gray characteristic data are redetermined; when the reason of the gradation abnormality is a contrast or gradation calculation abnormality, image gradation characteristic data such as contrast or gradation is recalculated.
Further, after the correction processing is performed on the deviation sample data, the sample data may be updated, and the model training may be performed again according to the redetermined sample data, so as to improve the accuracy of the model.
S260, obtaining a defect level determination model.
Further, after the defect level determination model is obtained, each sample data utilized in model training is stored, so that the storage space is saved, and only information such as defect level, defect number, size characteristic data, image gray characteristic data and the like can be reserved without storing a defect image. And determining new sample data according to the images of the defect classification performed by the new defect level determination model after the accumulated number of images of the defect classification performed by the defect level determination model is larger than or equal to a preset number threshold value or after a feature combination adjustment instruction of the defect level determination model is received, and retraining the model so that the defect level determination model can flexibly adapt to the requirements of appearance detection.
S270, inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
According to the technical scheme, the defect contour extraction and the defect level marking are respectively carried out on the defect image, the size characteristic data and the image gray characteristic data of the defect image are determined, the size, the gray level, the texture and other characteristics of the defect are integrated, the classification evaluation on the defect can be realized, a preset machine learning model is trained through sample data, in the training process, when the number of types of the defect level is large, whether the classification condition of the defect is accurate or not is relaxed, the prediction is accurate as long as the level difference between the defect level prediction result and the defect level marking result is within the preset deviation, the test data with inaccurate prediction is recorded, the abnormal reason of the prediction is analyzed, the model training is carried out again after the test data with inaccurate prediction is repaired, the defect level determination model is finally obtained, the accuracy of the model is improved, and the defect level determination is carried out on the image to be processed through the defect level determination model. The problem that in the prior art, only two appearance defect detection results of NG or OK can be made, and the method cannot be suitable for different sites of appearance defect detection, and the problem that the judging standard of the appearance defect detection results is adjusted is solved, so that the comprehensive multidimensional characteristics are used for carrying out hierarchical evaluation on the appearance defects, and the characteristics of the defect level determining model can be adjusted aiming at the sites of different appearance defect detection, so that the defect level determining model can be more suitable for the actual conditions of different appearance defect detection sites.
Example III
Fig. 4 is a schematic structural diagram of a defect level determining apparatus according to a third embodiment of the present invention. As shown in fig. 4, the apparatus includes: sample data determination module 310, defect level determination model determination module 320, and defect level result determination module 330. Wherein:
a sample data determining module 310 for determining sample data of at least two defect levels, the sample data including size feature data and image gray scale feature data;
the defect level determining model determining module 320 is configured to train a preset machine learning model according to the sample data of the at least two defect levels to obtain a defect level determining model;
and the defect level result determining module 330 is configured to input an image to be processed into the defect level determining model, and obtain a defect level result output by the defect level determining model.
According to the technical scheme, through determining sample data of a plurality of different defect levels, the sample data comprise size characteristic data and image gray scale characteristic data, training a preset machine learning model through the sample data to obtain a defect level determination model, and determining the defect level of an image to be processed through the defect level determination model. The problem that in the prior art, only two appearance defect detection results of NG or OK can be made, and the method can not adapt to different sites of appearance defect detection, and the judgment standard of the appearance defect detection results is adjusted is solved, so that the grading evaluation of the appearance defects is realized.
On the basis of the above embodiment, the dimensional characteristic data includes at least one of: defect length, defect width, and other dimensional characteristic data calculated from the defect length and/or defect width;
the image gray scale characteristic data includes at least one of: defect image contrast, defect image gray scale, and other image gray scale characteristic data calculated according to the defect image contrast and/or the defect image gray scale.
On the basis of the above embodiment, the sample data determining module 310 includes:
the defect image marking unit is used for determining defect contours and defect level marking results of at least two defect images;
a defect image feature determining unit, configured to determine size feature data matched with the defect image according to a defect contour of the defect image, and determine image gray feature data matched with the defect image according to the defect image.
On the basis of the above embodiment, when the image gray-scale feature data includes a defective image contrast, the defective image feature determining unit is specifically configured to:
determining a background area of the defect image;
According to the defect image and the background area, determining a gray average value of a bright gray scale image and a gray average value of a dark gray scale image;
and determining the gray average value of the absolute value image according to the gray average value of the bright gray image and the gray average value of the dark gray image, and taking the gray average value of the absolute value image as the defect image contrast of the defect image.
Based on the above embodiment, the defect level determination model determination module 320 includes:
a feature combination determining unit configured to determine at least two feature combinations based on the size features and the image gray features matched with the sample data of the at least two defect levels;
the candidate defect level determining model training unit is used for training a preset machine learning model through sample data matched with the candidate feature combination to obtain a candidate defect level determining model;
and the defect level determining model determining unit is used for determining a target defect level determining model in the candidate defect level determining models and determining a target feature combination matched with the target defect level determining model.
Based on the above embodiment, the defect level determination model determination module 320 includes:
The sample data dividing unit is used for dividing the sample data of the at least two defect levels into training data and test data;
the model training unit is used for training a preset machine learning model according to the training data and testing the machine learning model after training according to the testing data;
the model training completion condition judging unit is used for repeatedly training a preset machine learning model through the training data, and testing the trained machine learning model through the test data until the accuracy of the trained machine learning model is greater than or equal to a preset accuracy threshold value and/or the model training times are greater than or equal to a preset times threshold value, so as to obtain a defect level determining model;
and when the number of the types of the defect levels is larger than or equal to a preset number threshold, if the level difference between the defect level prediction result corresponding to the target test data and the defect level marking result corresponding to the target test data is smaller than or equal to a preset deviation, determining that the target test data is accurately predicted.
On the basis of the above embodiment, the apparatus further includes:
The deviation sample data determining unit is used for determining deviation sample data with the level difference between the defect level prediction result and the defect level marking result being larger than the preset deviation;
the deviation sample data processing unit is used for performing at least one of the following processing on the defect image corresponding to the deviation sample data: redetermining the defect contour, redetermining the defect level labeling result, redetermining the size characteristic data, and redetermining the image gray scale characteristic data.
The defect level determining device provided by the embodiment of the invention can execute the defect level determining method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example IV
Fig. 5 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (central processor), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, such as the determination method of the defect level.
In some embodiments, the method of determining defect levels may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the above-described method of determining a defect level may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the method of determining the defect level in any other suitable way (e.g. by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.
Claims (10)
1. A method for determining a defect level, comprising:
determining sample data of at least two defect levels, the sample data comprising size feature data and image gray scale feature data;
training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model;
and inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
2. The method of claim 1, wherein the dimensional characteristic data comprises at least one of: defect length, defect width, and other dimensional characteristic data calculated from the defect length and/or defect width;
the image gray scale characteristic data includes at least one of: defect image contrast, defect image gray scale, and other image gray scale characteristic data calculated according to the defect image contrast and/or the defect image gray scale.
3. The method of claim 2, wherein determining sample data for at least two defect levels comprises:
determining defect contours and defect level marking results of at least two defect images;
and determining size characteristic data matched with the defect image according to the defect outline of the defect image, and determining image gray characteristic data matched with the defect image according to the defect image.
4. A method according to claim 3, wherein when the image gray scale feature data comprises a defective image contrast, the determining image gray scale feature data matching the defective image from the defective image comprises:
Determining a background area of the defect image;
according to the defect image and the background area, determining a gray average value of a bright gray scale image and a gray average value of a dark gray scale image;
and determining the gray average value of the absolute value image according to the gray average value of the bright gray image and the gray average value of the dark gray image, and taking the gray average value of the absolute value image as the defect image contrast of the defect image.
5. The method of claim 1, wherein training a pre-set machine learning model from the sample data of the at least two defect levels to obtain a defect level determination model comprises:
determining at least two feature combinations according to the size features and the image gray features matched with the sample data of the at least two defect levels;
training a preset machine learning model through sample data matched with the candidate feature combination to obtain a candidate defect level determining model;
and determining a target defect level determination model in the candidate defect level determination models, and determining a target feature combination matched with the target defect level determination model.
6. The method of claim 1, wherein training a pre-set machine learning model from the sample data of the at least two defect levels to obtain a defect level determination model comprises:
Dividing the sample data of the at least two defect levels into training data and test data;
training a preset machine learning model according to the training data, and testing the trained machine learning model according to the testing data;
repeating training of a preset machine learning model through the training data, and testing the trained machine learning model through the testing data until the accuracy of the trained machine learning model is greater than or equal to a preset accuracy threshold value and/or the model training times are greater than or equal to a preset times threshold value, so as to obtain a defect level determining model;
and when the number of the types of the defect levels is larger than or equal to a preset number threshold, if the level difference between the defect level prediction result corresponding to the target test data and the defect level marking result corresponding to the target test data is smaller than or equal to a preset deviation, determining that the target test data is accurately predicted.
7. The method according to claim 6, further comprising:
determining deviation sample data with the level difference between the defect level prediction result and the defect level marking result being larger than the preset deviation;
And carrying out at least one of the following processing on the defect image corresponding to the deviation sample data: redetermining the defect contour, redetermining the defect level labeling result, redetermining the size characteristic data, and redetermining the image gray scale characteristic data.
8. A defect level determining apparatus, comprising:
a sample data determining module for determining sample data of at least two defect levels, the sample data including size feature data and image gray scale feature data;
the defect level determining model determining module is used for training a preset machine learning model through the sample data of the at least two defect levels to obtain a defect level determining model;
and the defect level result determining module is used for inputting the image to be processed into the defect level determining model to obtain a defect level result output by the defect level determining model.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of determining a defect level according to any of claims 1-7 when the program is executed by the processor.
10. A storage medium storing computer executable instructions which, when executed by a computer processor, are adapted to perform the method of determining a defect level as claimed in any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310773186.3A CN116797579A (en) | 2023-06-28 | 2023-06-28 | Defect level determining method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310773186.3A CN116797579A (en) | 2023-06-28 | 2023-06-28 | Defect level determining method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116797579A true CN116797579A (en) | 2023-09-22 |
Family
ID=88043447
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310773186.3A Pending CN116797579A (en) | 2023-06-28 | 2023-06-28 | Defect level determining method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116797579A (en) |
-
2023
- 2023-06-28 CN CN202310773186.3A patent/CN116797579A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112581463B (en) | Image defect detection method and device, electronic equipment, storage medium and product | |
CN111693534B (en) | Surface defect detection method, model training method, device, equipment and medium | |
CN111833306A (en) | Defect detection method and model training method for defect detection | |
WO2024002187A1 (en) | Defect detection method, defect detection device, and storage medium | |
CN114419035B (en) | Product identification method, model training device and electronic equipment | |
CN112699824B (en) | Method and device for detecting constant of electric energy meter and storage medium | |
CN116952958B (en) | Defect detection method, device, electronic equipment and storage medium | |
CN115471476A (en) | Method, device, equipment and medium for detecting component defects | |
CN115937101A (en) | Quality detection method, device, equipment and storage medium | |
CN110751170A (en) | Panel quality detection method, system, terminal device and computer readable medium | |
CN116468705A (en) | Welding spot image detection method and device, electronic equipment and storage medium | |
CN116797579A (en) | Defect level determining method and device, electronic equipment and storage medium | |
CN114116688B (en) | Data processing and quality inspection method and device and readable storage medium | |
CN115359322A (en) | Target detection model training method, device, equipment and storage medium | |
CN115546108A (en) | Intelligent detection method for appearance quality of automobile tire based on edge cloud cooperation and AR | |
CN115394442A (en) | Development evaluation method, device, equipment and medium | |
CN113409288B (en) | Image definition detection method, device, equipment and storage medium | |
CN114092739B (en) | Image processing method, apparatus, device, storage medium, and program product | |
CN117115568B (en) | Data screening method, device, equipment and storage medium | |
CN116681697B (en) | Cobalt removal measuring method and device for diamond compact and electronic equipment | |
CN114037865B (en) | Image processing method, apparatus, device, storage medium, and program product | |
CN116681950A (en) | Image processing method based on classification uncertainty | |
CN117216682A (en) | Method and device for processing perception data, electronic equipment and storage medium | |
CN118334644A (en) | Wheat cob phenotype parameter determination method, device, equipment and medium based on deep learning | |
CN117197051A (en) | Defect grading method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |