Product defect detection method and device, computer equipment and storage medium

By analyzing the product data set and optimizing the loss, the target detection threshold is determined, and the problem of low accuracy in detection of fuzzy defects in the prior art is solved, and higher accuracy in product defect detection is achieved.

CN119516261APending Publication Date: 2025-02-25SHENZHEN SMARTMORE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411562178.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

When existing appearance detection technologies detect fuzzy defects (such as depth defects), they cannot accurately obtain the defect depth value, resulting in low detection accuracy.

Method used

By obtaining the product dataset of the target product type, the initial detection thresholds for each detection dimension are determined, and the missed detection and overtest losses are calculated based on the differences between the label defect results and the predicted defect results. Then, the loss optimization parameters are used to combine the missed detection loss and the over-detection loss to obtain the target loss, and the initial detection threshold is adjusted until the convergence condition is met to obtain the target detection threshold.

Benefits of technology

Accurate quantification of detection thresholds for each defect category is achieved, the accuracy of product defect detection is improved, and the effectiveness and accuracy of target detection thresholds are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119516261A_ABST
    Figure CN119516261A_ABST
Patent Text Reader

Abstract

The invention relates to a product defect detection method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring a product data set of a target product type, wherein the product data set comprises defect data and label defect results of each sampling product in each detection dimension under the same defect type; determining an initial detection threshold value of the target product type in each detection dimension based on the defect data, and determining a prediction defect result corresponding to each sampling product based on the initial detection threshold value and the defect data; determining missing detection loss and over detection loss based on the difference between the label defect result and the prediction defect result corresponding to each sampling product; carrying out loss fusion on the leak detection loss and the over detection loss based on the loss optimization parameters to obtain target loss; and adjusting the initial detection threshold based on the target loss until a convergence condition is met, and obtaining target detection thresholds corresponding to the target product type in each detection dimension under the same defect type. By adopting the method, the accuracy of product defect detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of appearance inspection, and in particular to a product defect detection method, device, computer equipment and storage medium. Background Art

[0002] As the application of appearance inspection technology in industry gradually increases, it gradually replaces manual defect inspection of products. In the existing appearance inspection process, a pre-set detection threshold is usually compared with the detection value obtained to determine the defect detection result of the product.

[0003] However, the pre-set detection threshold is often obtained based on the subjective settings or experience of the inspectors. When it comes to some fuzzy defects, such as depth defects (scratches), etc., since it is impossible to obtain accurate depth values, the inspectors' appearance inspection of such defects has a fuzzy inspection range and cannot accurately quantify the detection threshold, resulting in low accuracy in product defect detection. Summary of the invention

[0004] Based on this, it is necessary to provide a product defect detection method, device, computer equipment, computer readable storage medium and computer program product to address the above technical problems, which can improve the accuracy of product defect detection.

[0005] In a first aspect, the present application provides a product defect detection method, comprising:

[0006] Obtain a product dataset of the target product type, where the product dataset includes defect data and labeled defect results of each sampled product in each detection dimension under the same defect category;

[0007] Determine the initial detection threshold of the target product type in each detection dimension based on the defect data, and determine the predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data;

[0008] Determine missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product;

[0009] Based on the loss optimization parameters, the missed detection loss and over-detection loss are fused to obtain the target loss. Based on the target loss, the initial detection threshold is adjusted until the convergence condition is met, and the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category are obtained.

[0010] In a second aspect, the present application also provides a product defect detection device, comprising:

[0011] A data acquisition module is used to acquire a product data set of a target product type, where the product data set includes defect data and label defect results of each sampled product in each detection dimension under the same defect category;

[0012] A defect prediction module is used to determine the initial detection threshold of the target product type in each detection dimension based on the defect data, and determine the predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data;

[0013] A loss calculation module, used to determine missed inspection loss and over-inspection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product;

[0014] The threshold determination module is used to fuse the missed detection loss and the over-detection loss based on the loss optimization parameters to obtain the target loss; adjust the initial detection threshold based on the target loss until the convergence condition is met, and obtain the target detection threshold corresponding to each detection dimension of the target product type under the same defect category.

[0015] In a third aspect, the present application further provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.

[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.

[0017] In a fifth aspect, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps in the above method are implemented.

[0018] The above-mentioned product defect detection method, device, computer equipment, computer-readable storage medium and computer program product can quantify the initial detection threshold of the same defect type in each detection dimension by obtaining the label defect results of each sampled product for the same defect category and the defect data of each detection dimension of the sampled product under the same defect category, and determine the initial detection threshold of each detection dimension based on the defect data, thereby ensuring the accuracy of the initial detection threshold; determine the predicted defect results of each sampled product according to the initial detection threshold and the defect data, obtain the missed detection loss and over-detection loss through the difference between the label defect result and the predicted defect result, and realize the missed detection verification and over-detection verification of the initial detection threshold in each sampled product; then, according to the loss optimization parameter, the missed detection loss and the over-detection loss are fused to obtain the target loss, and the initial detection threshold is adjusted based on the target loss until the convergence condition is met, and the target detection threshold of each detection dimension under the same defect category is obtained, so that the target detection threshold satisfies the missed detection verification and over-detection verification, which can ensure the effectiveness and accuracy of the target detection threshold, thereby realizing the accurate quantification of the detection threshold of each defect category and improving the accuracy of product defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] FIG1 is an application environment diagram of a product defect detection method provided by an embodiment of the present application;

[0020] FIG2 is a schematic diagram of a process flow of a product defect detection method provided in an embodiment of the present application;

[0021] FIG3 is a schematic diagram of a process flow of a product defect detection step provided in an embodiment of the present application;

[0022] FIG4 is a schematic diagram of a defect marking provided in an embodiment of the present application;

[0023] FIG5 is a schematic diagram of a calculation process of a target detection threshold provided in an embodiment of the present application;

[0024] FIG6 is a structural block diagram of a product defect detection device provided in an embodiment of the present application;

[0025] FIG7 is an internal structure diagram of a computer device provided in an embodiment of the present application;

[0026] FIG8 is an internal structure diagram of another computer device provided in an embodiment of the present application;

[0027] FIG. 9 is a diagram of the internal structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0029] The product defect detection method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through a communication network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be an independent physical server, or it can be a server cluster or distributed system composed of multiple physical servers, or it can be a cloud server that provides cloud computing services.

[0030] As shown in FIG2 , the embodiment of the present application provides a product defect detection method, which is illustrated by applying the method to the terminal in FIG1 . It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0031] Step 202 , obtaining a product data set of the target product type, where the product data set includes defect data and label defect results of each sampled product in each detection dimension under the same defect category.

[0032] Among them, the target product type refers to the product type of each sampled product in the product data set currently in use. The sampled product is a product with appearance defects and defect data can be collected. The sampled product can be an industrial product, etc. The defect category refers to the category of appearance defects existing in the sampled product, such as scratches, notches, bruises, etc. The detection dimension is the physical dimension that characterizes the appearance defects, such as length, width, area, etc. The defect data refers to the detection value of the appearance defects in the sampled product in each physical dimension. The label defect result refers to the real label that characterizes the defect situation set in advance for the appearance defects of the sampled product, including defective product labels and non-defective product labels. The defective product label indicates that the defect situation of the sampled product meets the conditions of a defective product and is regarded as a defective product. The non-defective product label indicates that the defect situation of the sampled product does not meet the conditions of a defective product and is regarded as a normal product.

[0033] Specifically, the manager can input a detection threshold generation instruction for defect detection for the target product type to the terminal according to the demand, and the terminal collects the product data set of the target product type in response to the detection threshold generation instruction. The product data set includes the defect data of each sampled product in each detection dimension under the same defect category and the label defect result corresponding to each sampled product in the same defect category. The defect data can be obtained by using a data acquisition device to identify the appearance defects of the same defect category for each sampled product in advance, and collecting data on the appearance defects of the same defect category according to each detection dimension. The label defect result can be a real label that the inspection personnel have marked on each sampled product in advance according to the appearance defect, such as a defective product label and a non-defective product label marked on the sampled product, and then the terminal generates a detection threshold generation request based on the product data set, and sends the detection threshold generation request to the server. In some embodiments, when the sampled product contains a single appearance defect of the same defect type, the defect result set by the inspection personnel according to the appearance defect is used as the label defect result of the sampled product to which it belongs.

[0034] Step 204, determining the initial detection threshold of the target product type in each detection dimension based on the defect data, and determining the predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data.

[0035] The predicted defect result refers to the product defect result obtained by judging each sampled product using the initial detection threshold.

[0036] Specifically, the server receives a detection threshold generation request sent by the terminal, and obtains the defect data and label defect results of each detection dimension of each sampled product under the same defect category according to the detection threshold generation request. For any detection dimension, the server obtains the defect data corresponding to each sampled product under the detection dimension, determines the initial detection threshold corresponding to the detection dimension according to each acquired defect data, and obtains the initial detection threshold corresponding to each detection dimension of the sampled product under the same defect category. The server can input each defect data into a preset detection threshold prediction model for calculation, and use the result output by the detection threshold prediction model as the initial detection threshold corresponding to the detection dimension; it can also select the initial detection threshold that meets the detection condition from each defect data according to the distribution of each defect data; it can also use each defect data as a candidate detection threshold, and select the initial detection threshold that meets the detection condition from each candidate detection threshold.

[0037] Then, after obtaining the initial detection thresholds corresponding to each detection dimension of the sampled product under the same defect category, the server compares the defect data of each detection dimension corresponding to the sampled product with the initial detection threshold of the corresponding detection dimension for any sampled product, and determines the predicted defect result corresponding to the sampled product based on the comparison result. For example, the sampled product whose defect data is greater than or equal to the corresponding detection threshold is determined as a defective product, and the sampled product whose defect data is less than the corresponding detection threshold is determined as a non-defective product.

[0038] Step 206, based on the difference between the label defect result and the predicted defect result corresponding to each sampled product, determine the missed detection loss and the over-detection loss.

[0039] Among them, missed inspection loss refers to the proportion of missed inspection products among all sampled products, and missed inspection products refer to defective products judged as non-defective products among all sampled products. Over-inspection loss refers to the proportion of over-inspected products among all sampled products, and over-inspected products refer to non-defective products judged as defective products among all sampled products.

[0040] Specifically, the server searches for differential products with difference results based on the label defect results and predicted defect results corresponding to each sampled product, such as sampled products whose label defect results are inconsistent with the predicted defect results, and then determines the differential product type to which the differential product belongs, including missed detection product type and passed detection product type, based on the difference between the label defect results and the predicted results corresponding to the differential product. The server determines missed detection products and passed detection products in each sampled product based on the differential product types corresponding to the differential products in the sampled products, and calculates the proportion of missed detection products and the proportion of passed detection products in each sampled product, to obtain missed detection losses and passed detection losses corresponding to each sampled product.

[0041] Step 208, based on the loss optimization parameters, the missed detection loss and the over-detection loss are fused to obtain the target loss; based on the target loss, the initial detection threshold is adjusted until the convergence condition is met, and the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category are obtained.

[0042] Among them, the loss optimization parameter is the calculation parameter used to generate the target loss. Loss fusion refers to the calculation process of merging the missed detection loss and the over-detection loss.

[0043] The target loss is an optimization function used to adjust the initial detection threshold to achieve detection threshold optimization. The convergence condition refers to the pre-set stop condition for stopping the optimization of the detection threshold. The target detection threshold refers to the detection threshold that meets the convergence condition and can be actually applied to product defect detection.

[0044] Specifically, the server verifies the missed detection loss and over-detection loss obtained based on the difference between the label defect result and the predicted defect result. It can be to detect whether the missed detection loss and over-detection loss meet the preset loss conditions. If they meet, the initial detection threshold is used as the target detection threshold corresponding to each detection dimension of the target product type under the same defect category; if not, the loss optimization parameter is used to merge the missed detection loss and over-detection loss to obtain the target loss. Specifically, it can be based on actual needs, such as determining the basic loss and non-basic loss in the missed detection loss and over-detection loss according to the weights of the missed detection loss and over-detection loss. The basic loss represents the loss parameter with the loss deviation between itself and its corresponding loss threshold as the optimization object; the non-basic loss represents the loss parameter with itself as the optimization object. The server calculates the loss deviation between the basic loss and the corresponding loss threshold. Since there is a large dimensional difference between the loss deviation and the non-basic loss (such as a multiple difference of 100 and 0.1), the loss optimization parameter is used to unify the basic loss and the non-basic loss, and the basic loss and the non-basic loss after the dimensional unification are merged to obtain the target loss. For example, taking the missed detection loss as the basic loss and the over-detection loss as the non-basic loss, the target loss obtained by integrating the missed detection loss and the non-basic loss based on the loss optimization parameters can be understood as an optimization function generated by taking the loss deviation between the missed detection loss and its corresponding loss threshold and the over-detection loss as the optimization objects.

[0045] The server adjusts the initial detection threshold according to the target loss until the convergence conditions are met, such as the target loss is minimized, the number of adjustments to the initial detection threshold reaches the upper limit, etc., to obtain the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category. For example, the initial detection threshold is adjusted with the minimum target loss as the optimization goal, and the target detection threshold after the initial detection threshold is adjusted is obtained. The server uses the obtained target detection threshold as the defect detection parameter of the target product type under the same defect category and returns it to the terminal. The terminal can perform product defect detection according to the defect detection parameter.

[0046] In the above-mentioned product defect detection method, by obtaining the label defect results of each sampled product for the same defect category and the defect data of each detection dimension of the sampled product under the same defect category, and determining the initial detection threshold of each detection dimension based on the defect data, the initial detection threshold of the same defect type in each detection dimension can be quantified, thereby ensuring the accuracy of the initial detection threshold; the predicted defect results of each sampled product are determined according to the initial detection threshold and the defect data, and the missed detection loss and over-detection loss are obtained by the difference between the label defect result and the predicted defect result, thereby realizing the missed detection verification and over-detection verification of the initial detection threshold in each sampled product; then, the missed detection loss and over-detection loss are fused according to the loss optimization parameter to obtain the target loss, and the initial detection threshold is adjusted based on the target loss until the convergence condition is met, thereby obtaining the target detection threshold of each detection dimension under the same defect category, so that the target detection threshold satisfies the missed detection verification and over-detection verification, thereby ensuring the effectiveness and accuracy of the target detection threshold, thereby realizing the accurate quantification of the detection threshold of each defect category and improving the accuracy of product defect detection.

[0047] In some embodiments, as shown in FIG. 3 , step 206, based on the difference between the label defect result and the predicted defect result corresponding to each sampled product, determines the missed detection loss and the over-detection loss, including:

[0048] Step 302, classifying each sampled product into a label defective product and a label non-defective product based on the label defect result;

[0049] Step 304, based on the predicted defect result, determine the difference non-defective products in the label defective products to obtain missed detection products; calculate the missed detection loss based on the missed detection products and the label defective products;

[0050] Step 306, based on the predicted defect results, differential defective products are determined in the labeled non-defective products to obtain inspected products; and the inspected loss is calculated based on the inspected products and each sampled product.

[0051] Among them, the label defect product refers to the defective product in the label defect result, which can be regarded as the real defective product. The label non-defective product refers to the non-defective product in the label defect result, which can be regarded as the real non-defective product. The difference non-defective product refers to the sampled product whose label defect result is a defective product and the predicted defect result is a non-defective product, which can be understood as the real defective product mistakenly judged as a non-defective product. The difference defective product refers to the sampled product whose label defect result is a non-defective product and the predicted defect result is a defective product, which can be understood as the real non-defective product mistakenly judged as a defective product.

[0052] Specifically, the server obtains the label defect results and predicted defect results corresponding to each sampled product, and divides each sampled product into label defective products and label non-defective products according to the label defect results. The server searches for difference non-defective products that are inconsistent with the predicted defect results in the label defective products, determines the difference non-defective products as missed detection products, and calculates the proportion of missed detection products in the label defective products to obtain the missed detection loss. The calculation of missed detection loss is shown in formula (1):

[0053] g(x*) = Σ((Human.m=Ng)&(Pm < x*)) / Σ(Human.m=Ng) (1)

[0054] Among them, g(x*) represents the missed detection loss; x* represents the detection threshold corresponding to each detection dimension; Human.m=Ng represents the real defective product determined according to the label defect result; Pm represents the defect data corresponding to the sampled product in each detection dimension.

[0055] Then, the difference defective products that are inconsistent with the predicted defect results are searched in the labeled non-defective products, and the difference defective products are determined as the passed-inspection products. The proportion of the passed-inspection products in each sampled product is calculated to obtain the passed-inspection loss. The calculation of the passed-inspection loss is shown in formula (2):

[0056] p(x*) = Σ((Human.m=Ok)&(Pm > x*)) / sample product (2)

[0057] Among them, g(x*) represents the over-inspection loss; Human.m= Ok represents the real non-defective product determined according to the label defect result.

[0058] In some embodiments, the product data set is shown in Table 1, including defect data and label defect results corresponding to each detection dimension of the same defect category in the sampled products, such as defect data of detection dimensions B, C, and D corresponding to defect numbers 1, 2, ... n of the same defect category, and label defect results of the sampled products to which each defect number belongs. In formulas (1) and (2), x* is the detection threshold B*, C*, D* of the detection dimensions B, C, and D, which can be expressed as x*= [B*, C*, D*].

[0059] Table 1

[0060]

[0061] In some embodiments, as shown in FIG4 , a schematic diagram of defect marking is provided. Product images of each sampled product can be collected in advance by a data collection device and displayed by a terminal. The product image includes defect data of each detection dimension of the appearance defect existing in the sampled product. For example, the defect example in FIG4 includes defect data such as the length, width and area of ​​the defect. The inspector marks the appearance defects in the product image displayed by the terminal, such as an ok mark and an ng mark, and obtains the label defect results of each sampled product.

[0062] In this embodiment, by calculating the over-inspection loss and the missed detection loss in each sampled product based on the difference between the label defect result and the predicted defect result, the accuracy of the missed detection loss and the over-inspection loss can be ensured; since the missed detection loss and the over-inspection loss can be used as reference data for verifying the effectiveness of the detection threshold, the effectiveness and accuracy of the initial detection threshold can be verified through the missed detection loss and the over-inspection loss.

[0063] In some embodiments, step 208, based on the loss optimization parameter, the missed detection loss and the over-detection loss are fused to obtain the target loss, including:

[0064] Calculate the missed detection difference between the missed detection loss and the target missed detection loss;

[0065] Based on the loss optimization parameters, the missed detection difference and over-detection loss are fused to obtain the target loss.

[0066] Specifically, the server uses the missed detection loss as the basic loss and the over-detection loss as the non-basic loss according to the pre-settings. The missed detection difference is calculated between the missed detection loss and the target missed detection loss. The target missed detection loss refers to the loss threshold corresponding to the missed detection loss, and the missed detection difference is the loss deviation between the missed detection loss and the corresponding loss threshold. Then, the missed detection difference is dimensionally unified using the loss optimization parameters, and the over-detection loss and the missed detection difference after dimension unification are merged to obtain the target loss. The target loss is calculated as shown in formula (3):

[0067] F(x)=p(x) + A*abs(g(x)- B) (3)

[0068] Where F(x) represents the target loss; p(x) represents the over-detection loss; g(x) represents the missed detection loss; B represents the target missed detection loss; A represents the loss optimization parameter, which can be set to a value greater than or equal to 100. abs( ) represents absolute value calculation.

[0069] In some embodiments, both missed detection loss and over-detection loss can be used as basic losses according to actual needs. The missed detection difference between the missed detection loss and the target missed detection loss is calculated, as is the over-detection difference between the over-detection loss and the target over-detection loss. When there is no dimensional difference between the missed detection difference and the over-detection difference, the over-detection difference and the missed detection difference are combined to obtain the target loss, indicating an optimization function with the missed detection difference and the over-detection difference as optimization objects.

[0070] In some embodiments, both missed detection loss and over-detection loss can be regarded as non-basic losses according to actual needs, and the target loss is obtained by combining the missed detection loss and the over-detection loss, which represents an optimization function with the missed detection loss and the over-detection loss as optimization objects.

[0071] In this embodiment, the target loss is calculated according to the missed detection loss and the over-detection loss, so that the initial detection threshold is subsequently adjusted by the target loss to obtain the target detection threshold, thereby ensuring the accuracy of the target detection threshold.

[0072] In some embodiments, step 208, adjusting the initial detection threshold based on the target loss until a convergence condition is met, and obtaining the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category, includes:

[0073] Calculate the multi-order loss gradient values ​​of the target loss for the initial detection threshold;

[0074] Based on the initial detection threshold and the multi-order loss gradient value, determine the updated detection threshold corresponding to each detection dimension of the target product type under the same defect category;

[0075] The updated detection threshold is used as the initial detection threshold, and the step of calculating the multi-order loss gradient value of the target loss for the initial detection threshold is returned to execute until the convergence condition is met, and the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category are obtained.

[0076] The multi-order loss gradient value refers to the gradient value obtained by performing multi-order gradient calculation on the target loss based on the initial detection threshold.

[0077] Specifically, the server can pre-construct an optimization function corresponding to the target loss according to the expressions of missed detection loss and over-detection loss, calculate the first-order loss gradient value and the second-order loss gradient value of the target loss on the initial detection threshold, and calculate the updated detection threshold corresponding to the initial detection threshold according to the ratio of the initial detection threshold, the first-order loss gradient value and the second-order loss gradient value.

[0078] When the target loss meets the minimum condition based on the updated detection threshold, the updated detection threshold is determined as the target detection threshold; when the target loss does not meet the minimum condition based on the updated detection threshold, the updated detection threshold is used as the initial detection threshold, and the step of calculating the multi-order loss gradient value of the target loss for the initial detection threshold is returned to execute until the convergence condition is met, that is, when the target loss meets the minimum condition, the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category are obtained. For example, the initial detection threshold is x0, and the first-order loss gradient value F'(x0) and the second-order gradient F''(x0) of the target loss F(x) on x0 are calculated according to the discrete gradient derivative; the updated detection threshold x1=x0-F'(x0) / F''(x0) is calculated; it is determined whether F(x1) meets the minimum condition, if so, x1 is the target detection threshold; if not, x1 is taken as x0, and the step of calculating the first-order loss gradient value F'(x0) and the second-order gradient F''(x0) of the target loss F(x) on x0 according to the discrete gradient derivative is returned, and the process is executed until the target detection threshold of each detection dimension that makes the target loss F(x) meet the minimum condition is obtained.

[0079] In this embodiment, the target detection threshold is obtained by iteratively updating the initial detection threshold according to the target loss, thereby ensuring the accuracy of the target detection threshold and improving the accuracy of product defect detection based on the target detection threshold.

[0080] In some embodiments, step 204, determining the initial detection threshold of the target product type in each detection dimension based on the defect data, includes:

[0081] For any detection dimension, each defect data of the detection dimension is used as a candidate detection threshold corresponding to the target product type in the detection dimension, and the predicted defect result corresponding to the detection dimension is determined based on the candidate detection threshold and each defect data of the detection dimension;

[0082] Based on the difference between the label defect result and the predicted defect result corresponding to the detection dimension, the missed detection loss corresponding to the detection dimension is obtained;

[0083] Based on the missed detection loss corresponding to the detection dimension, the initial detection threshold of the target product type in the detection dimension is determined from each candidate detection threshold.

[0084] Specifically, after the server obtains the defect data of each sampled product in each detection dimension under the same defect category, for any detection dimension, each defect data of the detection dimension is used as the candidate detection threshold corresponding to the target product type in the detection dimension, and each candidate detection threshold is compared with the defect data of each sampled product in the corresponding detection dimension, and the predicted defect result corresponding to each candidate detection threshold in the corresponding detection dimension is obtained according to the comparison result. For example, there are 5 sampled products, and for the detection dimension of defect length, the defect length values ​​of the 5 sampled products are used as the candidate detection thresholds of defect length, and any candidate detection threshold is compared with the defect length values ​​of the other 4 sampled products, and the predicted defect results of the defect length of the 4 sampled products corresponding to the candidate detection threshold are obtained according to the comparison result.

[0085] For any detection dimension, the server calculates the missed detection loss corresponding to the candidate detection threshold in the detection dimension based on the difference between the label defect result and the predicted defect result corresponding to the detection dimension. The missed detection loss corresponding to each candidate detection threshold in the detection dimension can be calculated according to formula (1), and then the server selects the candidate detection threshold whose missed detection loss matches the target missed detection loss of the corresponding detection dimension from each candidate detection threshold, and determines it as the initial detection threshold corresponding to the detection dimension. Then, the corresponding initial detection threshold is determined based on the missed detection loss of the next detection dimension, until the initial detection threshold corresponding to the target product type in each detection dimension is obtained.

[0086] In some embodiments, for any detection dimension, the defect data corresponding to the detection dimension can be sorted by size, and a defect data distribution map corresponding to the detection dimension can be generated according to the sorting result. Then, the manager determines the candidate area in the defect data distribution map, such as the area of ​​the top 5% of defect data in the defect data distribution map, and uses the defect data in the candidate area (such as 5% of defect data) as the candidate detection threshold, and enters the step of determining the predicted defect result corresponding to the detection dimension based on the candidate detection threshold and each defect data, until the initial detection threshold corresponding to the target product type in each detection dimension is obtained.

[0087] In this embodiment, each defect data of the detection dimension is used as a candidate detection threshold, the missed detection loss corresponding to the candidate detection threshold is calculated, and the candidate detection threshold that matches the target missed detection loss is determined as the initial detection threshold among each candidate detection threshold according to the missed detection loss, thereby ensuring the accuracy of the initial detection threshold, and further ensuring the accuracy of the target detection threshold subsequently adjusted based on the initial detection threshold.

[0088] In some embodiments, the method further comprises:

[0089] Based on the target detection threshold and defect data, determine the target defect results corresponding to the sampled products;

[0090] Based on the difference between the label defect results corresponding to each sampled product and the target defect results, determine the current missed detection loss and the current over-detection loss;

[0091] When the current missed detection loss satisfies the missed detection condition and the current over-detection loss satisfies the over-detection condition, defect detection is performed on the target product of the target product type based on the target detection threshold; or,

[0092] When the current missed detection loss does not meet the missed detection condition and the current over-inspection loss does not meet the over-inspection condition, the product data set is updated, and the step of obtaining the product data set of the target product type is returned to execute until the target detection threshold is obtained so that the current missed detection loss meets the missed detection condition and the current over-inspection loss meets the over-inspection condition.

[0093] Specifically, after obtaining the target detection threshold corresponding to each detection dimension of the target product type, the server uses the target detection threshold to compare with the defect data corresponding to each sampled product to obtain the target defect result corresponding to each sampled product. Then, based on the difference between the label defect result and the target defect result corresponding to each sampled product, the current missed detection loss and the current over-detection loss are calculated.

[0094] When the current missed detection loss meets the target missed detection loss and the over-inspection loss meets the target over-inspection loss, the target detection threshold corresponding to each detection dimension is used as the defect detection parameter of the corresponding defect category, and defect detection is performed on the target product of the target product type; when the current missed detection loss does not meet the target missed detection loss or the over-inspection loss does not meet the target over-inspection loss, the product dataset is updated and the step of obtaining the product dataset of the target product type is returned to execute until the target detection threshold is obtained so that the current missed detection loss meets the missed detection condition and the current over-inspection loss meets the over-inspection condition.

[0095] In this embodiment, the product data set is updated when it is detected that the current missed detection loss does not meet the missed detection condition and the current over-inspection loss does not meet the over-inspection condition, and the target detection threshold that meets the missed detection condition and the over-inspection condition is determined based on the updated product data set, thereby ensuring the effectiveness and accuracy of the target detection threshold.

[0096] In some embodiments, as shown in FIG5 , a schematic diagram of a target detection threshold calculation process is provided, wherein the process includes selecting data, obtaining defect data, obtaining label defect results, and calculating the target detection threshold. The specific implementation steps for calculating the target detection threshold are as follows:

[0097] Selected data: The server obtains product images corresponding to each defect category, for example, 50-100 product images are selected for each defect category;

[0098] Obtaining defect data: A detection technology module is pre-set in the server, which can be a data acquisition device. The detection technology module detects the defect data of each detection dimension of the appearance defects in each product image, such as area, length (minimum circumscribed moment), width (minimum circumscribed moment), average gray value and other defect data. Among them, the detection technology module can use a single appearance defect as a detection unit and output the defect data of a single appearance defect X=[length, width, area, ...]; it can also use the product image as a detection unit and output the product image defect data X=[single length of the defect, single area of ​​the defect, the overall area of ​​this defect in the image, ...]; it can also output the defect level of the product image X=[relative area, relative length, relative width, affected area, affected width, minimum spacing between defects, ...].

[0099] Obtain label defect results: In advance, the inspection personnel mark the defect data of the appearance defects in each product image as ok or ng, and obtain the manually marked defect situation of the appearance defects in each sampled product, which can be used as the label defect results of each sampled product.

[0100] Calculate the target detection threshold: Preset the parameter control expectations corresponding to each defect category, namely, the target missed detection loss and the target over-detection loss. For example, the target missed detection rate of defect category 1 is 0.5%, and the target missed detection rate of defect category 2 is 0%. The server obtains the defect data of each sampled product in each detection dimension under the same defect category from the product data set, defines x as the threshold parameter (i.e., detection dimension), x=[area, length, width, etc.], and defines g(x) as the missed detection loss for the product data set and p(x) as the over-detection loss for the product data set according to formulas (1) and (2). Then, an optimizable objective function F(x)=p(x) + A*abs(g(x)- B) (i.e., target loss) is defined based on the missed detection loss and over-detection loss. The optimization goal of the objective function F(x) is to make F(x) meet the minimum value condition. The server determines the initial detection threshold of the target product type in each detection dimension based on the defect data, and iteratively adjusts the initial detection threshold based on the target loss until the target loss meets the minimum value condition, thereby obtaining the target detection threshold corresponding to each detection dimension of the target product type under the same defect category.

[0101] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0102] Based on the same inventive concept, the embodiment of the present application also provides a product defect detection device. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more product defect detection device embodiments provided below can refer to the limitations of the product defect detection method above, and will not be repeated here.

[0103] As shown in FIG6 , the embodiment of the present application provides a product defect detection device 600, including:

[0104] The data acquisition module 602 is used to acquire a product data set of the target product type, where the product data set includes defect data and label defect results of each sampled product in each detection dimension under the same defect category;

[0105] The defect prediction module 604 is used to determine the initial detection threshold of the target product type in each detection dimension based on the defect data, and determine the predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data;

[0106] A loss calculation module 606, used to determine missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product;

[0107] The threshold determination module 608 is used to perform loss fusion on missed detection loss and over-detection loss based on the loss optimization parameters to obtain the target loss; adjust the initial detection threshold based on the target loss until the convergence condition is met, and obtain the target detection threshold corresponding to each detection dimension of the target product type under the same defect category.

[0108] In some embodiments, in determining missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product, the loss calculation module 606 is specifically used to:

[0109] Classify each sampled product into a label defective product and a label non-defective product based on the label defect result;

[0110] Based on the predicted defect results, the difference non-defective products are determined among the label defective products to obtain missed detection products; the missed detection loss is calculated based on the missed detection products and the label defective products;

[0111] Based on the predicted defect results, the difference defective products are determined among the labeled non-defective products to obtain the inspected products; the inspection loss is calculated based on the inspected products and each sampled product.

[0112] In some embodiments, in terms of performing loss fusion on missed detection loss and over-detection loss based on the loss optimization parameter to obtain the target loss, the threshold determination module 608 is specifically used to:

[0113] Calculate the missed detection difference between the missed detection loss and the target missed detection loss;

[0114] Based on the loss optimization parameters, the missed detection difference and over-detection loss are fused to obtain the target loss.

[0115] In some embodiments, in terms of adjusting the initial detection threshold based on the target loss until the convergence condition is met to obtain the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category, the threshold determination module 608 is specifically used to:

[0116] Calculate the multi-order loss gradient values ​​of the target loss for the initial detection threshold;

[0117] Based on the initial detection threshold and the multi-order loss gradient value, determine the updated detection threshold corresponding to each detection dimension of the target product type under the same defect category;

[0118] The updated detection threshold is used as the initial detection threshold, and the step of calculating the multi-order loss gradient value of the target loss for the initial detection threshold is returned to execute until the convergence condition is met, and the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category are obtained.

[0119] In some embodiments, in determining the initial detection threshold of the target product type in each detection dimension based on the defect data, the defect prediction module 604 is specifically used to:

[0120] For any detection dimension, each defect data of the detection dimension is used as a candidate detection threshold corresponding to the target product type in the detection dimension, and the predicted defect result corresponding to the detection dimension is determined based on the candidate detection threshold and each defect data of the detection dimension;

[0121] Based on the difference between the label defect result and the predicted defect result corresponding to the detection dimension, the missed detection loss corresponding to the detection dimension is obtained;

[0122] Based on the missed detection loss corresponding to the detection dimension, the initial detection threshold of the target product type in the detection dimension is determined from each candidate detection threshold.

[0123] In some embodiments, the product defect detection device 600 is specifically used for:

[0124] Based on the target detection threshold and defect data, determine the target defect result corresponding to the sampled product; based on the difference between the label defect result and the target defect result corresponding to each sampled product, determine the current missed detection loss and the current over-inspection loss; when the current missed detection loss meets the missed detection condition and the current over-inspection loss meets the over-inspection condition, perform defect detection on the target product of the target product type based on the target detection threshold; or, when the current missed detection loss does not meet the missed detection condition and the current over-inspection loss does not meet the over-inspection condition, update the product data set, return to the step of obtaining the product data set of the target product type, and execute until the target detection threshold is obtained so that the current missed detection loss meets the missed detection condition and the current over-inspection loss meets the over-inspection condition.

[0125] Each module in the above-mentioned product defect detection device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0126] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG7. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to product defect detection. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the above-mentioned product defect detection method are implemented.

[0127] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, the steps in the above-mentioned product defect detection method are implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0128] Those skilled in the art will understand that the structure shown in FIG. 7 or FIG. 8 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In some embodiments, a computer device is also provided. The computer device includes a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the steps in the above method embodiments are implemented.

[0130] In some embodiments, an internal structure diagram of a computer-readable storage medium is provided as shown in FIG9 . The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0131] In some embodiments, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0134] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0135] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A product defect detection method, characterized in that: include: Acquire a product data set of the target product type, wherein the product data set includes defect data and label defect results of each sampled product in each detection dimension under the same defect category; Determine an initial detection threshold of the target product type in each detection dimension based on the defect data, and determine a predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data; Determine missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product; The missed detection loss and the over-detection loss are fused based on the loss optimization parameter to obtain the target loss; the initial detection threshold is adjusted based on the target loss until the convergence condition is met, so as to obtain the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category.

2. The method according to claim 1, characterized in that The determining of missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product includes: Classifying each of the sampled products into label defective products and label non-defective products based on the label defect results; Determine the difference non-defective products among the labeled defective products based on the predicted defect result to obtain missed detection products; calculate missed detection losses based on the missed detection products and the labeled defective products; Determine difference defective products among the labeled non-defective products based on the predicted defect results to obtain inspected products; and calculate inspected losses based on the inspected products and the various sampled products.

3. The method according to claim 1, characterized in that The step of performing loss fusion on the missed detection loss and the over-detection loss based on the loss optimization parameter to obtain a target loss includes: Calculating a missed detection difference between the missed detection loss and a target missed detection loss; The missed detection difference and the over-detection loss are fused based on the loss optimization parameter to obtain a target loss.

4. The method according to claim 1, characterized in that: The adjusting the initial detection threshold based on the target loss until a convergence condition is satisfied, and obtaining the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category, respectively, includes: Calculate the multi-order loss gradient value of the target loss with respect to the initial detection threshold; Based on the initial detection threshold and the multi-order loss gradient value, determine the updated detection thresholds corresponding to each detection dimension of the target product type under the same defect category; The updated detection threshold is used as the initial detection threshold, and the step of calculating the multi-order loss gradient value of the target loss for the initial detection threshold is returned to be executed until the convergence condition is met, so as to obtain the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category.

5. The method according to claim 1, characterized in that: The determining, based on the defect data, an initial detection threshold of the target product type in each detection dimension includes: For any detection dimension, each defect data of the detection dimension is used as a candidate detection threshold corresponding to the target product type in the detection dimension, and a predicted defect result corresponding to the detection dimension is determined based on the candidate detection threshold and each defect data of the detection dimension; Based on the difference between the label defect result and the predicted defect result corresponding to the detection dimension, obtaining the missed detection loss corresponding to the detection dimension; Based on the missed detection loss corresponding to the detection dimension, an initial detection threshold of the target product type in the detection dimension is determined from various candidate detection thresholds.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Determining a target defect result corresponding to the sampled product based on the target detection threshold and the defect data; Determine the current missed detection loss and the current over-detection loss based on the difference between the label defect results corresponding to the respective sampled products and the target defect results; When the current missed detection loss satisfies a missed detection condition and the current over-detection loss satisfies an over-detection condition, defect detection is performed on a target product of the target product type based on the target detection threshold; or, When the current missed detection loss does not satisfy the missed detection condition and the current over-inspection loss does not satisfy the over-inspection condition, the product data set is updated, and the step of obtaining the product data set of the target product type is returned to be executed until a target detection threshold is obtained that makes the current missed detection loss satisfy the missed detection condition and the current over-inspection loss satisfy the over-inspection condition.

7. A product defect detection device, characterized in that: include: A data acquisition module is used to acquire a product data set of a target product type, wherein the product data set includes defect data and label defect results of each sampled product in each detection dimension under the same defect category; A defect prediction module, used to determine the initial detection threshold of the target product type in each detection dimension based on the defect data, and determine the predicted defect result corresponding to each sampled product based on the initial detection threshold and the defect data; A loss calculation module, used to determine missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product; A threshold determination module is used to perform loss fusion on the missed detection loss and the over-detection loss based on the loss optimization parameter to obtain a target loss; adjust the initial detection threshold based on the target loss until the convergence condition is met, and obtain the target detection thresholds corresponding to each detection dimension of the target product type under the same defect category.

8. The device according to claim 7, characterized in that In the aspect of determining missed detection loss and over-detection loss based on the difference between the label defect result and the predicted defect result corresponding to each sampled product, the loss calculation module is specifically used to: Classifying each of the sampled products into label defective products and label non-defective products based on the label defect results; Determine the difference non-defective products among the labeled defective products based on the predicted defect result to obtain missed detection products; calculate missed detection losses based on the missed detection products and the labeled defective products; Based on the predicted defect results, different defective products are determined among the labeled non-defective products to obtain inspected products; and based on the inspected products and the various sampled products, the inspected losses are calculated.

9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.