Object quality detection method, quality detection model construction method, and device

CN116977262BActive Publication Date: 2026-08-18TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310340960.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-08-18
Estimated Expiration
2043-03-28

AI Technical Summary

Technical Problem

[0004]然而,实际应用过程中,由于产品的多样化,对不同产品采集到的缺陷图像并不属于简单的二分类,比如包括较多缺陷图像的程度较低,无法直接划分为有缺陷图像,或者某些图像缺陷程度十分轻微,本质上可以划分为无缺陷图像的情况等,即实际应用过程中的产品图像,无法通过简单的二值标签进行全面表述

Benefits of technology

[0056]上述对象质量检测方法、质量检测模型的构建方法、装置、计算机设备、存储介质和程序产品中,通过接收对象质量检测请求,获取与对象质量检测请求对应的待检测产品图像,进而根据训练好的质量检测模型,对待检测产品图像进行质量检测处理,获得与待检测产品图像对应的缺陷置信度数据。其中,训练好的质量检测模型是根据目标检测模型对第二检测模型进行知识蒸馏训练得到的,目标检测模型则是根据奖励参数从各第一检测模型中确定得到的,达到了利用强化训练实现对各第一检测模型的进一步加权和选择,确定出最合适的目标检测模型的目的,奖励参数则是根据对第二检测模型训练过程中的监督损失、以及根据增强产品图像样本对各第一检测模型进行强化训练过程的强化损失确定得到的,监督损失则是根据与第一预测结果对应的监督数据、以及第二预测结果确定得到的。通过根据目标模型对第二检测模型进行知识蒸馏训练,使得第二检测模型可学习到第一检测模型中的知识,减少对产品图像样本中预先标注的标签的依赖,以及预先标注的标签带来的噪声误差数据,从而获得模型精准度更高的质量检测模型,从而提升了利用质量检测模型对产品的质量检测准确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116977262B_ABST
    Figure CN116977262B_ABST
Patent Text Reader

Abstract

The application relates to an object quality detection method, a quality detection model construction method and device, equipment, a storage medium and a program product. The method relates to artificial intelligence and comprises the following steps: performing quality detection processing on a to-be-detected product image corresponding to an object quality detection request according to a trained quality detection model, and obtaining defect confidence data corresponding to the to-be-detected product image. Each enhanced product image sample is subjected to prediction processing according to each first detection model and second detection model, first prediction results and second prediction results are obtained, supervision loss is determined according to the first prediction results and the second prediction results, a reward parameter is determined according to the supervision loss and the reinforcement loss of the second detection model, a target detection model is determined from each first detection model according to the reward parameter, the quality detection model is obtained by performing distillation training on the second detection model according to the target detection model, and the quality detection accuracy of the product is improved by using the method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an object quality inspection method, a method for constructing a quality inspection model, an apparatus, a computer device, a storage medium, and a computer program product. Background Technology

[0002] With the development of artificial intelligence technology and the increasing quality requirements for different products in the manufacturing process, industrial defect inspection technology has emerged. Industrial defect inspection mainly involves taking pictures of the surface of industrial products to obtain images, and then processing these images through feature extraction, defect identification, and quality inspection to obtain corresponding inspection and identification results, determine whether the product has defects, and prevent defective products from entering the market.

[0003] Traditionally, the method of training a convolutional neural network model is usually adopted to extract features from product surface images based on the convolutional neural network model, and then perform binary classification on the extracted features into two categories: defective and defective, thereby classifying the product as having or not having quality problems.

[0004] However, in practical applications, due to the diversity of products, the defect images collected from different products do not fall under simple binary classification. For example, some images may contain a large number of images with low defect severity, making them unsuitable for direct classification as defective, while others may have very minor defects, essentially classifying them as defect-free. In other words, product images in practical applications cannot be fully represented by simple binary labels. Furthermore, simple binary labels require manual pre-annotation. Different people will produce different annotations depending on the degree of defect in the image, resulting in noisy and erroneous labels. If noisy and erroneous data is used to train the model, the resulting model will also contain noise, leading to a decline in the model's recognition and classification performance, and consequently, lower accuracy in the quality inspection results obtained by the model. Summary of the Invention

[0005] Therefore, it is necessary to provide a method for constructing a quality inspection model, an object quality inspection method, an apparatus, a computer device, a computer-readable storage medium, and a computer program product that can improve the accuracy of product quality inspection in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a method for object quality inspection. The method includes:

[0007] Receive an object quality inspection request and acquire an image of the product to be inspected corresponding to the object quality inspection request;

[0008] Based on the trained quality inspection model, the image of the product to be inspected is subjected to quality inspection processing to obtain defect confidence data corresponding to the image of the product to be inspected.

[0009] The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each of the first detection models based on the reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each of the enhanced product image samples based on multiple trained first detection models, and the second prediction result is obtained by predicting each of the enhanced product image samples based on the second detection model.

[0010] Secondly, this application provides a method for constructing a quality inspection model. The method includes:

[0011] Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model;

[0012] Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results;

[0013] Based on the enhanced product image samples, each of the first detection models is enhanced and trained, and the enhancement loss of the enhancement training process is determined.

[0014] Based on the supervision loss and the reinforcement loss, the reward parameters are determined;

[0015] Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

[0016] Thirdly, this application also provides an object quality inspection device. The device includes:

[0017] The product image acquisition module is used to receive an object quality inspection request and acquire the product image to be inspected corresponding to the object quality inspection request.

[0018] The defect confidence data acquisition module is used to perform quality detection processing on the product image to be detected according to the trained quality detection model, and obtain defect confidence data corresponding to the product image to be detected.

[0019] The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each of the first detection models based on the reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each of the enhanced product image samples based on multiple trained first detection models, and the second prediction result is obtained by predicting each of the enhanced product image samples based on the second detection model.

[0020] Fourthly, this application also provides an apparatus for constructing a quality inspection model. The apparatus includes:

[0021] The prediction result acquisition module is used to acquire enhanced product image samples, and perform prediction processing on each of the enhanced product image samples according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model.

[0022] The supervision loss determination module is used to determine the supervision data corresponding to each of the first prediction results, and to determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results.

[0023] The enhancement loss determination module is used to perform enhancement training on each of the first detection models based on each of the enhanced product image samples, and to determine the enhancement loss during the enhancement training process.

[0024] The reward parameter determination module is used to determine the reward parameters based on the supervision loss and the reinforcement loss;

[0025] The quality detection model acquisition module is used to determine the target detection model from each of the first detection models according to the reward parameters, and to perform knowledge distillation training on the second detection model according to the target detection model to obtain the trained quality detection model.

[0026] Fifthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0027] Receive an object quality inspection request and acquire an image of the product to be inspected corresponding to the object quality inspection request;

[0028] Based on the trained quality inspection model, the image of the product to be inspected is subjected to quality inspection processing to obtain defect confidence data corresponding to the image of the product to be inspected.

[0029] The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each of the first detection models based on the reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each of the enhanced product image samples based on multiple trained first detection models, and the second prediction result is obtained by predicting each of the enhanced product image samples based on the second detection model.

[0030] Sixthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0031] Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model;

[0032] Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results;

[0033] Based on the enhanced product image samples, each of the first detection models is enhanced and trained, and the enhancement loss of the enhancement training process is determined.

[0034] Based on the supervision loss and the reinforcement loss, the reward parameters are determined;

[0035] Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

[0036] Seventhly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0037] Receive an object quality inspection request and acquire an image of the product to be inspected corresponding to the object quality inspection request;

[0038] Based on the trained quality inspection model, the image of the product to be inspected is subjected to quality inspection processing to obtain defect confidence data corresponding to the image of the product to be inspected.

[0039] The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each of the first detection models based on the reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each of the enhanced product image samples based on multiple trained first detection models, and the second prediction result is obtained by predicting each of the enhanced product image samples based on the second detection model.

[0040] Eighthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0041] Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model;

[0042] Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results;

[0043] Based on the enhanced product image samples, each of the first detection models is enhanced and trained, and the enhancement loss of the enhancement training process is determined.

[0044] Based on the supervision loss and the reinforcement loss, the reward parameters are determined;

[0045] Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

[0046] Ninthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0047] Receive an object quality inspection request and acquire an image of the product to be inspected corresponding to the object quality inspection request;

[0048] Based on the trained quality inspection model, the image of the product to be inspected is subjected to quality inspection processing to obtain defect confidence data corresponding to the image of the product to be inspected.

[0049] The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each of the first detection models based on the reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each of the enhanced product image samples based on multiple trained first detection models, and the second prediction result is obtained by predicting each of the enhanced product image samples based on the second detection model.

[0050] Tenthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0051] Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model;

[0052] Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results;

[0053] Based on the enhanced product image samples, each of the first detection models is enhanced and trained, and the enhancement loss of the enhancement training process is determined.

[0054] Based on the supervision loss and the reinforcement loss, the reward parameters are determined;

[0055] Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

[0056] In the aforementioned object quality detection method, quality detection model construction method, apparatus, computer equipment, storage medium, and program product, an object quality detection request is received, an image of the product to be detected corresponding to the object quality detection request is obtained, and then, based on a trained quality detection model, quality detection processing is performed on the image of the product to be detected to obtain defect confidence data corresponding to the image of the product to be detected. The trained quality detection model is obtained by knowledge distillation training of a second detection model based on a target detection model. The target detection model is determined from each first detection model based on reward parameters, achieving the goal of further weighting and selection of each first detection model through reinforcement training to determine the most suitable target detection model. The reward parameters are determined based on the supervised loss during the training process of the second detection model and the reinforcement loss during the reinforcement training process of each first detection model based on enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. By training the second detection model with knowledge distillation based on the target model, the second detection model can learn the knowledge in the first detection model, reducing the reliance on pre-labeled tags in product image samples and the noise error data brought by pre-labeled tags, thereby obtaining a quality detection model with higher accuracy, thus improving the accuracy of product quality detection using the quality detection model. Attached Figure Description

[0057] Figure 1 This is an application environment diagram of the object quality detection method and the construction method of the quality detection model in one embodiment;

[0058] Figure 2 This is a flowchart illustrating an object quality detection method in one embodiment;

[0059] Figure 3 This is a schematic diagram of defects of different severity in one embodiment;

[0060] Figure 4 This is a schematic diagram illustrating the process of obtaining defect confidence data corresponding to an image of the product to be inspected in one embodiment.

[0061] Figure 5 This is a schematic diagram of the defect confidence data corresponding to the image of the product to be detected in one embodiment.

[0062] Figure 6 This is a flowchart illustrating the process of obtaining a trained quality detection model in one embodiment;

[0063] Figure 7 This is a schematic diagram illustrating the process of obtaining a trained first detection model in one embodiment.

[0064] Figure 8 This is a schematic diagram of a reinforcement learning algorithm during the reinforcement training process in one embodiment.

[0065] Figure 9 This is a flowchart illustrating the object quality detection method in another embodiment;

[0066] Figure 10 This is a flowchart illustrating the method for constructing a quality inspection model in one embodiment;

[0067] Figure 11 This is a schematic diagram illustrating the process of obtaining a quality inspection model in one embodiment.

[0068] Figure 12 This is a structural block diagram of an object quality detection device in one embodiment;

[0069] Figure 13 This is a structural block diagram of a device for constructing a quality detection model in one embodiment;

[0070] Figure 14 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0071] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0072] The object quality detection method and the method for constructing the quality detection model provided in this application specifically involve artificial intelligence technology and can be applied to various scenarios such as cloud technology, artificial intelligence, intelligent transportation, network media, and assisted driving. Artificial intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. Artificial intelligence studies the design principles and implementation methods of various intelligent machines, enabling them to have perception, reasoning, and decision-making functions. Artificial intelligence technology is a comprehensive discipline involving a wide range of fields, including both hardware and software technologies. Basic AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, and mechatronics. AI software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0073] Computer vision (CV) is a science that studies how to enable machines to "see." More specifically, it refers to using cameras and computers to replace human eyes in recognizing, detecting, and measuring targets, and then performing image processing to create images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, 3D object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), and common biometric recognition technologies such as facial recognition and fingerprint recognition. Machine learning (ML), on the other hand, is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence. Its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.

[0074] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.

[0075] Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. It's a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology based on cloud computing business models. These technologies can form resource pools, providing flexible and convenient on-demand access. Because the backend services of technical network systems require substantial computing and storage resources—such as video websites, image websites, and many portal websites—and with the rapid development and application of the internet industry, every item may eventually have its own identification mark, requiring transmission to the backend system for logical processing. Data of different levels will be processed separately, and various industry data require robust system support, typically achieved through cloud computing as a crucial support. Artificial intelligence cloud services, generally known as AIaaS (AI as a Service), are a mainstream service model for artificial intelligence platforms. Specifically, AIaaS platforms break down several common AI services and provide them as independent or packaged services in the cloud. This service model is similar to opening an AI-themed marketplace, where all developers can access and use one or more artificial intelligence services provided by the platform through API interfaces. Some experienced developers can also use the AI ​​framework and AI infrastructure provided by the platform to deploy and maintain their own exclusive cloud artificial intelligence services.

[0076] The object quality detection method and the method for constructing the quality detection model provided in this application specifically involve computer vision and machine learning technologies in artificial intelligence, as well as cloud technologies, and can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on the cloud or other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, portable wearable devices, and aircraft. IoT devices can be smart speakers, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be a standalone physical server, a server cluster consisting of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal 102 and server 104 can be directly or indirectly connected via wired or wireless communication; this embodiment does not impose any limitations on this.

[0077] Furthermore, both terminal 102 and server 104 can be used independently to execute the object quality detection method and the quality detection model construction method provided in the embodiments of this application. Terminal 102 and server 104 can also collaboratively execute the object quality detection method and the quality detection model construction method provided in the embodiments of this application. For example, taking the collaborative execution of the object quality detection method provided in the embodiments of this application by terminal 102 and server 104 as an example, server 104 receives an object quality detection request and obtains the image of the product to be detected corresponding to the object quality detection request. The object quality detection request can be triggered by terminal 102, which can send the triggered object quality request to server 104. The image of the product to be detected can be stored in the cloud storage of server 104, in the data storage system, or in the local storage of terminal 102. When object quality detection processing is required, it can be obtained from server 104, the data storage system, or terminal 102. Furthermore, the server 104 performs quality inspection processing on the product image to be inspected based on the trained quality inspection model, thereby obtaining defect confidence data corresponding to the product image to be inspected. The obtained defect confidence data can also be fed back to the terminal 102, or the defect confidence data can be stored in the cloud storage data or storage system of the server 104.

[0078] The trained quality detection model is obtained by server 104 through knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined by server 104 from each first detection model based on reward parameters. The reward parameters are determined by server 104 based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model based on enhanced product image samples. The supervised loss is determined by server 104 based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each enhanced product image sample based on multiple trained first detection models. Similarly, the second prediction result is obtained by predicting each enhanced product image sample based on the second detection model.

[0079] Similarly, taking the collaborative execution of the quality detection model construction method provided in this application embodiment by terminal 102 and server 104 as an example, server 104 acquires enhanced product image samples and performs prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each first detection model and a second prediction result corresponding to each second detection model. The enhanced product image samples can be stored in the cloud storage of server 104, in a data storage system, or in the local storage of terminal 102. When it is necessary to construct a quality detection model, they can be obtained from server 104, the data storage system, or terminal 102. Further, server 104 determines the supervision data corresponding to each first prediction result and, based on the supervision data and the second prediction result, determines the supervision loss during the training process of the second detection model. Similarly, server 104 also needs to perform reinforcement training on each first detection model according to each enhanced product image sample and determine the reinforcement loss during the reinforcement training process. Then, based on the supervision loss and the reinforcement loss, it determines the reward parameters. Finally, server 104 determines the target detection model from each of the first detection models based on the reward parameters, and performs knowledge distillation training on the second detection model based on the target detection model to obtain a trained quality detection model.

[0080] In one embodiment, such as Figure 2 As shown, an object quality inspection method is provided, which is applied to... Figure 1 Taking the server in the example, the following steps are included:

[0081] Step S202: Receive an object quality inspection request and obtain the image of the product to be inspected corresponding to the object quality inspection request.

[0082] Specifically, during the quality inspection of industrial or electronic products, inspectors can trigger an object quality inspection request based on a terminal. The terminal then sends the triggered object quality inspection request to the server. After receiving the object quality inspection request, the server can obtain the image of the product to be inspected corresponding to the object quality inspection request by further parsing the object quality request.

[0083] The product images to be inspected can be images of industrial or electronic products, such as the overall surface image of an industrial or electronic product, the surface image of a component, or the connection image of different components. By performing quality inspection on the product images of industrial or electronic products, corresponding defect confidence data can be obtained, and the presence of quality defects in each product image can be determined based on the defect confidence data.

[0084] In one embodiment, such as Figure 3 As shown, schematic diagrams of defects of varying severity are provided for reference. Figure 3 It can be seen that, Figure 3 Figure a in the image is an OK image (i.e., a product image without quality defects). Figure 3 Figure b in the image is a slightly defective image (i.e., the degree of image defect is very slight, and it can essentially be classified as a defect-free image), while Figure 3 Figure c in the image shows a severely defective image.

[0085] Traditional binary classification deep learning models, when detecting product images, can only simply categorize them as defective or non-defective. They cannot further subdivide product images based on different degrees of severity. This can easily lead to the direct classification of product images with low defect severity as defective, ignoring the fact that some images with very minor defects could essentially be classified as non-defective. Therefore, it is necessary to use a trained quality detection model to perform quality detection on product images of different severity levels to obtain their respective defect confidence data, and then further determine whether an image is defective based on the defect confidence data.

[0086] Step S204: Based on the trained quality detection model, perform quality detection processing on the product image to be detected to obtain defect confidence data corresponding to the product image to be detected. The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each first detection model based on the reward parameter. The reward parameter is determined based on the supervised loss during the training process of the second detection model and the reinforcement loss during the reinforcement training process of each first detection model based on the enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each enhanced product image sample based on multiple trained first detection models. The second prediction result is obtained by predicting each enhanced product image sample based on the second detection model.

[0087] Specifically, a pre-trained quality inspection model is used to perform quality inspection processing on each product image to be inspected. The quality inspection model obtains defect confidence data corresponding to the product images to be inspected. The defect confidence data is used to determine whether a product image to be inspected is a defective image. This is achieved by comparing the defect confidence data with a preset defect confidence threshold. If the defect confidence data is greater than the preset defect confidence threshold, the corresponding product image to be inspected is a defective image; if the defect confidence data is not greater than the preset defect confidence threshold, the corresponding product image to be inspected is a defect-free image.

[0088] The preset defect confidence threshold can be set according to actual needs, and can be different values ​​within the range of (0,1), such as 0.5, 0.8, or 0.9, etc., and is not limited to one or more specific values. For example, the preset defect confidence threshold can be set to 0.5. If the defect confidence data is greater than the preset defect confidence threshold of 0.5, it indicates that the corresponding product image to be inspected is a defective image; if the defect confidence data is not greater than the preset defect confidence threshold of 0.5, it indicates that the corresponding product image to be inspected is a defect-free image.

[0089] In one embodiment, the quality detection model used for quality inspection is obtained by knowledge distillation training of a second detection model based on an object detection model. The object detection model is determined from each of the first detection models based on reward parameters, which are determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each of the first detection models using enhanced product image samples. The supervised loss is determined based on supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each enhanced product image sample using multiple trained first detection models, and the second prediction result is obtained by predicting each enhanced product image sample using the second detection model.

[0090] The first detection model and the second detection model have the same network hierarchical structure, and the number of hierarchical nodes in the first detection model is greater than the number of hierarchical nodes in the same level in the second detection model. Therefore, during knowledge distillation training, the knowledge of the target detection model determined from each of the first detection models is transferred to the second detection model.

[0091] Specifically, by performing prediction processing on each enhanced product image sample based on multiple trained first detection models, a first prediction result can be obtained. By performing prediction processing on each enhanced product image sample based on a second detection model, a second detection result can be obtained. Then, by determining the supervision data corresponding to each first prediction result, and based on the supervision data and the second prediction result, the supervision loss during the training process of the second detection model can be determined.

[0092] Furthermore, by performing reinforcement training on each first detection model based on enhanced product image samples, the reinforcement loss of the training process can be obtained. Then, based on the determined supervision loss and reinforcement loss, the reward parameters used to screen the target detection model can be determined. The target detection model is then determined from each first detection model based on the reward parameters. Finally, the second detection model is trained by knowledge distillation based on the target detection model to obtain the trained quality detection model.

[0093] In one embodiment, such as Figure 4 As shown, an example of a process for obtaining defect confidence data corresponding to an image of a product to be inspected is provided, referring to... Figure 4 It can be seen that by inputting the image of the product to be inspected into a trained quality inspection model, the model extracts features and predicts probabilities from the image, outputting defect confidence data corresponding to the image. Furthermore, by comparing the defect confidence data with a preset defect confidence threshold (…),… Figure 4The image is compared with one example of the defect confidence threshold (e.g., when the defect confidence threshold is 0.5), and the product image to be inspected is classified according to the comparison results.

[0094] Specifically, if the defect confidence data is greater than the preset defect confidence threshold of 0.5, it indicates that the corresponding product image to be inspected is a defective image. If the defect confidence data is not greater than the preset defect confidence threshold of 0.5, it indicates that the corresponding product image to be inspected is a defect-free image, that is, a normal image, thereby achieving accurate classification of the product image to be inspected based on the defect confidence data.

[0095] Furthermore, such as Figure 5 As shown, an example of defect confidence data corresponding to an image of a product to be inspected is provided. (Refer to...) Figure 5 It can be seen that, Figure 5 Figure a in the image is an OK image (i.e., a normal image without defects). The defect confidence score for Figure a is 0.05, which is less than the defect confidence threshold of 0.5. Figure 5 Figure b in the figure is the defect image, and the defect confidence score corresponding to Figure b is 0.95, which is greater than the defect confidence threshold of 0.5.

[0096] In the aforementioned object quality detection method, an object quality detection request is received, and an image of the product to be detected corresponding to the request is obtained. Then, based on a trained quality detection model, the image is processed for quality detection to obtain defect confidence data corresponding to the image. The trained quality detection model is obtained by knowledge distillation training of a second detection model using a target detection model. The target detection model is determined from each first detection model based on reward parameters. This achieves the goal of further weighting and selection of each first detection model through reinforcement training to determine the most suitable target detection model. The reward parameters are determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model using enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. By training the second detection model with knowledge distillation based on the target model, the second detection model can learn the knowledge in the first detection model, reducing the reliance on pre-labeled tags in product image samples and the noise error data brought by pre-labeled tags, thereby obtaining a quality detection model with higher accuracy, thus improving the accuracy of product quality detection using the quality detection model.

[0097] In one embodiment, such as Figure 6 As shown, the method for obtaining a trained quality detection model includes the following steps:

[0098] Step S602: Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each first detection model and a second prediction result corresponding to each second detection model.

[0099] Specifically, by acquiring product image samples and performing data augmentation processing on each sample, enhanced product image samples from different perspectives are obtained. This increases the randomness of the product image samples used for model training and reduces the error data carried by each product image sample during training. The data augmentation processing includes various methods such as rotating, translating, scaling, cropping, and adding Gaussian noise to the product images.

[0100] Furthermore, based on multiple trained first detection models, prediction processing is performed on each enhanced product image sample to obtain a first prediction result corresponding to each first detection model. Similarly, based on the second detection model, prediction processing is performed on each enhanced product image sample to obtain a second prediction result corresponding to the second detection model.

[0101] In this model, the first and second detection models have the same network hierarchical structure, and the number of nodes in the first detection model is greater than the number of nodes in the same level in the second detection model. That is, the first detection model can be understood as a teacher model used for knowledge distillation training of the second detection model, while the second detection model can be understood as a student model learning knowledge from other teacher models. Specifically, the first and second detection models can be deep learning models or neural network models, etc. That is, by training deep learning models or neural network models at multiple levels, the final quality detection model used for quality detection can be obtained.

[0102] In one embodiment, before acquiring enhanced product image samples and performing prediction processing on each enhanced product image sample based on multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each first detection model and a second prediction result corresponding to each second detection model, the method further includes obtaining a trained first detection model. The method for obtaining the trained first detection model includes:

[0103] Acquire product image samples and train the initial detection model based on each product image sample; determine the training loss during the training process of the initial detection model; if the training loss meets the termination condition for training the initial detection model, obtain the trained first detection model.

[0104] Specifically, by acquiring product images corresponding to industrial or electronic products and pre-annotating each product image (i.e., adding labels to the product images, including defect labels and normal labels), multiple product image samples are obtained. Based on each product image sample carrying labels, the initial detection model is trained to obtain a trained first detection model.

[0105] Furthermore, during the training process, the training loss for training the initial detection model is determined, and it is judged whether the training loss meets the training termination condition for the initial detection model. If the training loss meets the training termination condition for the initial detection model, the trained first detection model is obtained. Specifically, the training termination condition for the initial detection model can be that the training loss reaches a preset loss threshold, or that the number of training iterations for the initial detection model reaches a preset number.

[0106] Specifically, the training loss for training the initial detection model is determined by the following formula (1). :

[0107] (1);

[0108] in, This represents the feature extraction and probability prediction results obtained from the initial detection model for product image samples. This refers to the labels (including normal labels and defect labels) carried by the product sample images. This represents the cross-entropy loss function, which calculates the probability of prediction. Labels carried with product sample images The cross-entropy loss value between the two values ​​can be used to obtain the training loss for training the initial detection model. .

[0109] In one embodiment, the training loss is calculated. In addition, other loss functions can be used, such as Kl loss (i.e., KL divergence loss), and the cross-entropy loss function is not the only loss calculation method.

[0110] Furthermore, the probability prediction results obtained from feature extraction and output of the product image sample by the initial detection model are determined using the following formula (2). :

[0111] (2);

[0112] in, This represents the initial detection model. This represents a product image sample. This represents the initial weight parameters of the detection model during training, achieved by utilizing the training loss. By iteratively updating the model parameters using gradient descent, the weights of the trained model can be obtained. .

[0113] In one embodiment, such as Figure 7 As shown, an example of a process for obtaining a trained first detection model is provided. Figure 7 It can be seen that by using multiple product image samples, the initial detection model is trained, and the training loss during the training process is determined based on the model's output result, i.e. the probability prediction result, and the corresponding labels of the product image samples. The subsequent step is to further judge whether the training loss meets the training termination condition of the initial detection model, and when it is determined that the training loss meets the training termination condition of the initial detection model, the trained first detection model is obtained.

[0114] Furthermore, specifically, multiple initial detection models are trained based on different product image sample sets to obtain multiple trained first detection models. For example, K trained first detection models and their respective model weights are obtained. By randomly initializing the model weights of each first detection model, differentiated model weights can be obtained, including... .

[0115] Specifically, by using a structure with a large number of model parameters as the teacher model (i.e., the first detection model), the strong learning and fitting ability of the large model is utilized, enabling the student model (i.e., the second detection model) to learn the knowledge of the teacher model. In the subsequent training process of the second detection model, supervision signals are provided in addition to the pre-labeled labels to overcome the influence of noisy labels. Furthermore, the teacher model is not directly deployed in the final deployment stage. That is, the quality detection model obtained by multi-level training of the second detection model is actually deployed, without the need to deploy the teacher model. This avoids the problem of increased training time caused by the need to train and deploy a large model.

[0116] In one embodiment, for product image samples Enhancement processing, including rotation, translation, scaling, cropping, and adding Gaussian noise, is performed to obtain enhanced product image samples. Using K pre-trained first detection models, prediction processing is performed on each enhanced product image sample to obtain a first prediction result corresponding to each first detection model. Then, a second detection model is used to perform prediction processing on each enhanced product image sample to obtain a second prediction result corresponding to the second detection model.

[0117] Specifically, the first prediction result corresponding to each first detection model is obtained through the following formula (3):

[0118]

[0119]

[0120] (3);

[0121]

[0122] in, This indicates that the number of the first detection models is... The first detection model can specifically include one, that is, one. , Indicates the first detection model The first prediction result, The first detection model is represented by [symbol]. The first prediction result, Indicates the first detection model The first prediction result, This indicates the addition of product image samples. , These are used to represent the model parameters of each first detection model.

[0123] Similarly, the second prediction result corresponding to the second detection model is obtained through the following formula (4):

[0124] (4);

[0125] in, This indicates the second detection model. The model weights are the second detection model to be optimized during training. This indicates the addition of product image samples. This represents the second prediction result corresponding to the second detection model.

[0126] Step S604: Determine the supervision data corresponding to each first prediction result, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction result.

[0127] Specifically, by initializing and normalizing the weighting parameters associated with each first detection model, the processed weighting coefficients are obtained. Then, based on each weighting coefficient, the first prediction results are weighted sequentially to obtain the supervision data for the training process of the second detection model.

[0128] In order to utilize the prediction results of multiple trained first detection models to further guide the second detection model, a set of weighted parameters is designed during the training process of the second detection model. This is used to perform weighted processing on the first prediction result of the first detection model.

[0129] Specifically, by weighting Initialization is performed, and the weighted parameters are adjusted using the softmax function according to the following formula (5). Normalization is performed to obtain the weighted coefficients after processing. :

[0130] (5)

[0131] in, Indicates the first Each weighting coefficient Indicates that there is Each weighted coefficient, specifically including the following: Each of the first detection models corresponds to one-to-one There are several weighted coefficients. Among them, the learnable parameters are adjusted using the softmax function. After normalization, the weighted coefficients are obtained This can be understood as a probability, where the sum of all weighting coefficients is 1. The summation result is 1.

[0132] Furthermore, through weighting coefficients The first prediction results are weighted sequentially to construct the supervision data for training the second detection model. Specifically, the supervision data is constructed using the following formula (6). :

[0133] (6);

[0134] in, Indicates the first detection model The first prediction result, The first detection model is represented by [symbol]. The first prediction result, Indicates the first detection model The first prediction result, , This represents the weighting coefficient corresponding to each of the first detection models.

[0135] Furthermore, after determining the supervision data corresponding to each first prediction result, the supervision loss during the training process of the second detection model is determined based on the supervision data and the second prediction result. Specifically, the supervision loss during the training process of the second detection model is determined using the following formula (7). :

[0136] (7);

[0137] in, This represents the second prediction result corresponding to the second detection model. This represents the supervisory data used during the training of the second detection model. This represents the cross-entropy loss function, which is calculated by determining the second prediction result. and supervisory data The cross-entropy loss value between the two values ​​can be used to obtain the supervised loss during the training of the second detection model. .

[0138] In one embodiment, the supervision loss is calculated. In addition, other loss functions can be used, such as Kl loss (i.e., KL divergence loss), and the cross-entropy loss function is not the only loss calculation method.

[0139] Step S606: Based on each enhanced product image sample, perform reinforcement training on each first detection model and determine the reinforcement loss during the reinforcement training process.

[0140] Specifically, based on each enhanced product image sample, each first detection model is trained to obtain model weight data corresponding to each first detection model. From these model weight data, target model weight data that meets the selection criteria for enhanced training is determined. After determining the target model weight data that meets the selection criteria, an enhanced detection model matching the target model weight data is identified. Based on this enhanced detection model, prediction processing is performed on each enhanced product image sample to obtain the enhanced prediction results corresponding to each enhanced detection model. The enhanced loss is then determined based on the enhanced prediction results and the second prediction results.

[0141] The purpose of reinforcing each first detection model based on each enhanced product image sample is to utilize the discrete search capability of reinforcement learning to determine the most suitable enhanced detection model from K first detection models for different enhanced product image samples. The most suitable enhanced detection model is then used to supervise the training process of the second detection model, thereby enhancing the selection ability and feature representation ability in the knowledge distillation process.

[0142] Furthermore, by determining the model weight data corresponding to each first detection model after reinforcement training, specifically including ,in, This represents the model weight data corresponding to the i-th first detection model. Indicates the first The model weight data corresponding to the first detection model. Among them, The value range of is (0,1). The larger the value, the higher the score of the first detection model. The reinforcement training selection criteria can be understood as the need to select... The largest first detection model, that is, the first detection model that matches the target model weight data by filtering out the largest target model weight data, is determined as the enhanced detection model.

[0143] Specifically, the model index of the first detection model that matches the target model weight data is determined by the following formula (8). :

[0144] (8);

[0145] in, This represents the model index of the first detection model that matches the weight data of the target model. This represents the largest target model weight data.

[0146] Similarly, after determining the enhancement detection model that matches the target model weight data, the enhancement detection model is used to perform prediction processing on each enhanced product image sample to obtain the enhancement prediction result corresponding to each enhancement detection model. The enhancement loss is then determined based on the enhancement prediction result and the second prediction result.

[0147] Furthermore, the enhancement loss is specifically determined using the following formula (9). :

[0148] (9);

[0149] in, This represents the second prediction result corresponding to the second detection model. This indicates the enhancement prediction results obtained by performing predictive processing on each enhanced product image sample based on the determined enhancement detection model. This represents the cross-entropy loss function, which is calculated by determining the second prediction result. and enhance prediction results The reinforcement loss can be obtained from the cross-entropy loss value between them. .

[0150] In one embodiment, the reinforcement loss is calculated. In addition, other loss functions can be used, such as Kl loss (i.e., KL divergence loss), and the cross-entropy loss function is not the only loss calculation method.

[0151] In one embodiment, reinforcement learning can be understood as an optimization algorithm during the training process, such as... Figure 8 As shown, an example of a reinforcement learning algorithm in the reinforcement training process is provided, referring to... Figure 8 As can be seen, in reinforcement learning algorithms, the environment is changed by the agent's behavioral policy (i.e., action a) based on the current state s, and a reward parameter r is fed back. Here, the reward parameter r is used to measure the score in the current state; the higher the score, the more correct the agent's behavior. That is, through reinforcement learning, the agent can learn a behavioral policy that maximizes the reward function r.

[0152] Specifically, in the embodiments of this application, when performing reinforcement training on the first detection model, the agent is the model weight data corresponding to each first detection model after reinforcement training, including... The agent's behavioral strategy can be understood as the first detection model specifically trained during reinforcement training, and the enhanced image samples applied to the trained first detection model. When determining the reward parameter r, the fusion loss from the training process of the second detection model needs to be applied. Specifically, the reward parameter r is determined by taking the negative of the fusion loss from the training process of the second detection model.

[0153] Specifically, the reward parameter r is determined using the following formula (10):

[0154] (10);

[0155] in, This represents the fusion loss during the training process of the second detection model, specifically determined by the label loss, supervision loss, reinforcement loss, and difference loss during the training process of the second detection model.

[0156] Step S608: Determine the reward parameters based on the supervised loss and the reinforcement loss.

[0157] The reward parameter is the negative of the fusion loss during the training of the second detection model. The fusion loss during the training of the second detection model is specifically determined by the label loss, supervision loss, reinforcement loss, and difference loss during the training of the second detection model.

[0158] Specifically, based on the second prediction results and the labeled tags carried by the enhanced product image samples, the label loss during the training process of the second detection model is determined, and the difference loss is determined based on the enhanced prediction results and the supervision data.

[0159] Specifically, the label loss during the training process of the second detection model is calculated using the following formula (11). :

[0160] (11);

[0161] in, This is the second prediction result corresponding to the second detection model. This refers to the labels (including normal labels and defect labels) carried by the enhanced product sample images. This represents the cross-entropy loss function, which is calculated by determining the second prediction result. and enhance the labeling of product sample images. The cross-entropy loss value between the two values ​​can be used to obtain the label loss during the training process of the second detection model. .

[0162] In one embodiment, the label loss is calculated. In addition, other loss functions can be used, such as Kl loss (i.e., KL divergence loss), and the cross-entropy loss function is not the only loss calculation method.

[0163] Similarly, the difference loss is specifically calculated using the following formula (12). :

[0164] (12);

[0165] in, Denotes KL divergence, Indicates supervisory data, This indicates that the prediction results are being reinforced. This can be understood as calculating supervised data. Strengthen prediction results The divergence data between them is used to obtain the difference loss between the reinforcement learning branch and the softmax function weighted branch during training. This is achieved by setting the difference loss... This avoids the reinforcement learning branch and the softmax function weighted branch converging to the same minimum, instead making... and enhance prediction results The differences between them become larger, so it is necessary to avoid the occurrence of This reduces the impact on the accuracy of the second detection model during training.

[0166] Furthermore, based on the label loss, supervision loss, the first weight corresponding to the supervision loss, reinforcement loss, the second weight corresponding to the reinforcement loss, difference loss, and the third weight corresponding to the difference loss, the fusion loss is determined, and the reward parameters in the reinforcement training process can be determined based on the fusion loss. Specifically, the fusion loss in the model training process is calculated using the following formula (13). :

[0167] (13);

[0168] in, This represents the label loss during the training process of the second detection model. This represents the supervised loss during the training of the second detection model. This represents the first weight corresponding to the monitoring loss. This indicates an increased risk of loss. This represents the second weight corresponding to the reinforcement loss. Indicates difference loss, This represents the third weight corresponding to the difference loss. Wherein, , , It is used to adjust the proportion of various losses and can be adjusted and set according to actual application needs, without being limited to specific values.

[0169] In one embodiment, through fusion loss Gradient calculation is performed, and backpropagation can be used to update the model weights of the second detection model. Weighting coefficients and the model weight data corresponding to each first detection model after reinforcement training { This allows for the joint optimization of different weights or parameters.

[0170] Among them, the weighting coefficient The model weight data corresponding to each first detection model after reinforcement training { During training, the model is continuously updated. This means that different augmentation detection models and object detection models are determined for different augmentation training data (i.e., different augmented product image samples). and The size also directly reflects the corresponding number. The contribution levels of each teacher model are considered to select the most suitable enhancement detection model and object detection model. Specifically, by utilizing the differences in fitting ability of different first detection models to different enhanced product image samples, the model weights of each first detection model can be adaptively adjusted. This allows for supervision of the second detection model based on the determined object detection model, reducing the impact of noisy labels in the annotation process on the second detection model.

[0171] Step S610: Based on the reward parameters, determine the target detection model from each of the first detection models, and perform knowledge distillation training on the second detection model based on the target detection model to obtain a trained quality detection model.

[0172] Specifically, the maximum reward parameter is determined from each reward parameter, and the target detection model corresponding to the maximum reward parameter is determined from each first detection model. Then, based on each enhanced product image sample and the target detection model, the second detection model is trained by knowledge distillation to obtain a trained quality detection model.

[0173] Furthermore, the target detection model corresponding to the maximum reward parameter can be understood as the first detection model with the highest score determined during the reinforcement training process. That is, by using the first detection model with the highest score, the second detection model is supervised and trained using knowledge distillation, and when the training termination condition of the second detection model is met, a well-trained quality detection model is obtained.

[0174] Specifically, the training termination condition for the second detection model can be that the fusion loss during the model training process reaches a preset fusion loss threshold, or that the number of training iterations for the second detection model reaches a preset number of training iterations. When the training termination condition for the second detection model is met, the second detection model at the end of training is determined as the well-trained quality detection model.

[0175] In this embodiment, enhanced product image samples are acquired, and prediction processing is performed on each enhanced product image sample based on multiple trained first and second detection models to obtain first and second prediction results. Further, by determining the supervision data corresponding to each first prediction result, supervised training of the second prediction result of the second detection model is achieved using the supervision data. Thus, the supervision loss during the training process of the second detection model can be determined based on the supervision data and the second prediction result. Simultaneously, based on the enhanced product image samples, each first detection model is reinforced and trained, and the reinforcement loss during the reinforcement training process is determined. Based on the obtained supervised loss and reinforcement loss, the reward parameter is determined. Thus, based on the reward parameter, the most suitable target detection model is determined from each first detection model. This achieves the purpose of using reinforcement training to further weight and select each first detection model and determine the most suitable target detection model. Furthermore, the second detection model is trained by knowledge distillation based on the target detection model, which enables the second detection model to learn the knowledge in the first detection model, reducing the dependence on pre-labeled labels in the product image samples and the noise error data brought by the pre-labeled labels. This results in a quality detection model with higher model accuracy, thereby improving the accuracy of product quality detection using the quality detection model.

[0176] In one embodiment, such as Figure 9 As shown, an object quality inspection method is provided, which specifically includes the following steps:

[0177] Step S901: Obtain product image samples and train the initial detection model based on each product image sample.

[0178] Step S902: Determine the training loss during the training process of the initial detection model. If the training loss meets the training termination condition of the initial detection model, obtain the trained first detection model.

[0179] Step S903: Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each first detection model and a second prediction result corresponding to each second detection model.

[0180] Step S904: Initialize and normalize the weighted parameters associated with each first detection model to obtain the processed weighted coefficients.

[0181] Step S905: Based on each weighting coefficient, the first prediction results are weighted sequentially to obtain the supervision data for the training process of the second detection model.

[0182] Step S906: Based on the supervised data and the second prediction results, determine the supervised loss during the training process of the second detection model.

[0183] Step S907: Based on each enhanced product image sample, perform enhanced training on each first detection model to obtain the model weight data corresponding to each first detection model.

[0184] Step S908: Determine the target model weight data that meets the screening conditions for reinforcement training from the weight data of each model.

[0185] Step S909: Determine the enhancement detection model that matches the target model weight data, and perform prediction processing on each enhanced product image sample according to the enhancement detection model to obtain the enhancement prediction result corresponding to each enhancement detection model.

[0186] Step S910: Determine the reinforcement loss based on the reinforcement prediction result and the second prediction result.

[0187] Step S911: Based on the second prediction result and the annotation labels carried by the enhanced product image samples, determine the label loss during the training process of the second detection model.

[0188] Step S912: Determine the difference loss based on the enhanced prediction results and supervision data.

[0189] Step S913: Determine the fusion loss based on the label loss, supervision loss, the first weight corresponding to the supervision loss, reinforcement loss, the second weight corresponding to the reinforcement loss, difference loss, and the third weight corresponding to the difference loss.

[0190] Step S914: Determine the reward parameters during the reinforcement training process based on the fusion loss.

[0191] Step S915: Determine the maximum reward parameter from the reward parameters, and determine the target detection model corresponding to the maximum reward parameter from the first detection models.

[0192] Step S916: Based on the enhanced product image samples and the target detection model, the second detection model is trained by knowledge distillation to obtain a trained quality detection model.

[0193] Step S917: Receive an object quality inspection request and obtain the image of the product to be inspected corresponding to the object quality inspection request.

[0194] Step S918: Based on the trained quality inspection model, perform quality inspection processing on the image of the product to be inspected to obtain the defect confidence data corresponding to the image of the product to be inspected.

[0195] In the aforementioned object quality detection method, an object quality detection request is received, and an image of the product to be detected corresponding to the request is obtained. Then, based on a trained quality detection model, the image is processed for quality detection to obtain defect confidence data corresponding to the image. The trained quality detection model is obtained by knowledge distillation training of a second detection model using a target detection model. The target detection model is determined from each first detection model based on reward parameters. This achieves the goal of further weighting and selection of each first detection model through reinforcement training to determine the most suitable target detection model. The reward parameters are determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model using enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. By training the second detection model with knowledge distillation based on the target model, the second detection model can learn the knowledge in the first detection model, reducing the reliance on pre-labeled tags in product image samples and the noise error data brought by pre-labeled tags, thereby obtaining a quality detection model with higher accuracy, thus improving the accuracy of product quality detection using the quality detection model.

[0196] In one embodiment, such as Figure 10 As shown, a method for constructing a quality inspection model is provided, which can be applied to... Figure 1 Taking the server in the example, the specific steps are as follows:

[0197] Step S1002: Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain first prediction results corresponding to each first detection model and second prediction results corresponding to each second detection model.

[0198] Specifically, by acquiring product image samples and performing data augmentation processing on each product image sample, enhanced product image samples with data augmentation processing are obtained from different perspectives. The data augmentation processing includes different processing methods such as rotating, translating, scaling, cropping, and adding Gaussian noise to the product images.

[0199] Furthermore, based on multiple trained first detection models, prediction processing is performed on each enhanced product image sample to obtain a first prediction result corresponding to each first detection model. Similarly, based on the second detection model, prediction processing is performed on each enhanced product image sample to obtain a second prediction result corresponding to the second detection model.

[0200] In one embodiment, obtaining the trained first detection model includes:

[0201] Acquire product image samples and train the initial detection model based on each product image sample; determine the training loss during the training process of the initial detection model; if the training loss meets the termination condition for training the initial detection model, obtain the trained first detection model.

[0202] Specifically, by acquiring product images corresponding to industrial or electronic products and pre-annotating each product image (i.e., adding labels to the product images, including defect labels and normal labels), multiple product image samples are obtained. Based on each product image sample carrying labels, the initial detection model is trained to obtain a trained first detection model.

[0203] Step S1004: Determine the supervision data corresponding to each first prediction result, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction result.

[0204] Specifically, by initializing and normalizing the weighting parameters associated with each first detection model, the processed weighting coefficients are obtained. Then, based on each weighting coefficient, the first prediction results are weighted sequentially to obtain the supervision data for the training process of the second detection model. After determining the supervision data corresponding to each first prediction result, the supervision loss for the training process of the second detection model is further determined based on the supervision data and the second prediction results.

[0205] Step S1006: Based on each enhanced product image sample, perform reinforcement training on each first detection model and determine the reinforcement loss during the reinforcement training process.

[0206] Specifically, based on each enhanced product image sample, each first detection model is trained to obtain enhanced model weight data. From this enhanced model weight data, target model weight data that meets the enhanced training selection criteria is determined. After determining the target model weight data that meets the enhanced training selection criteria, an enhanced detection model matching the target model weight data is identified. Based on this enhanced detection model, prediction processing is performed on each enhanced product image sample to obtain the enhanced prediction results corresponding to each enhanced detection model. The enhancement loss is then determined based on the enhanced prediction results and the second prediction results.

[0207] Step S1008: Determine the reward parameters based on the supervised loss and the reinforcement loss.

[0208] The reward parameter is the negative of the fusion loss during the training of the second detection model. The fusion loss during the training of the second detection model is specifically determined by the label loss, supervision loss, reinforcement loss, and difference loss during the training of the second detection model.

[0209] Specifically, based on the second prediction result and the labeled tags carried by the enhanced product image samples, the label loss during the training process of the second detection model is determined, and the difference loss is determined based on the enhanced prediction result and the supervised data. Further, based on the label loss, supervised loss, the first weight corresponding to the supervised loss, enhanced loss, the second weight corresponding to the enhanced loss, the difference loss, and the third weight corresponding to the difference loss, the fusion loss is determined, and finally, the reward parameters during the enhanced training process are determined based on the fusion loss.

[0210] Step S1010: Based on the reward parameters, determine the target detection model from each of the first detection models, and perform knowledge distillation training on the second detection model based on the target detection model to obtain a trained quality detection model.

[0211] Specifically, the maximum reward parameter is determined from each reward parameter, and the target detection model corresponding to the maximum reward parameter is determined from each first detection model. Then, based on each enhanced product image sample and the target detection model, the second detection model is trained by knowledge distillation to obtain a trained quality detection model.

[0212] In one embodiment, such as Figure 11 As shown, an example of a process for obtaining a quality inspection model is provided, referring to... Figure 11 It can be seen that the process of obtaining a quality inspection model specifically includes the following stages:

[0213] 1. One training phase

[0214] In this context, a training phase refers to training multiple initial detection models to obtain K first detection models.

[0215] Specifically, by acquiring product images corresponding to industrial or electronic products and pre-annotating each product image (i.e., adding labels to the product images, including defect labels and normal labels), multiple product image samples are obtained. Then, based on the different product image samples carrying labels, the initial detection model is trained to obtain K trained first detection models.

[0216] Among them, reference Figure 11 It can be seen that the product image sample is Using product image samples, the initial detection model is trained to obtain K first detection models (including T1, T2, ..., T3).K ), and the model weights of each first detection model. .

[0217] 2. Second training phase

[0218] In the secondary training phase, it is necessary to obtain the first prediction results (including P1, P2, ..., P1, P2, ..., P3) of the trained first detection model for the enhanced product image samples. K ), and obtain the second prediction result of the second detection model for the enhanced product image sample (i.e., P). S ), and design a set of weighted parameters during the training of the second detection model. After initializing and normalizing the weighting parameters, the weighting coefficients are obtained. }, and according to the weighting coefficients { The first prediction result of the first detection model is weighted to construct the supervision data for training the second detection model, and the supervision loss for training the second detection model is determined based on the supervision data and the second prediction result.

[0219] Specifically, for product image samples Enhancement processing, including rotation, translation, scaling, cropping, and adding Gaussian noise, is performed to obtain enhanced product image samples. Using K pre-trained first detection models, prediction processing is performed on each enhanced product image sample to obtain a first prediction result corresponding to each first detection model. Then, a second detection model is used to perform prediction processing on each enhanced product image sample to obtain a second prediction result corresponding to the second detection model.

[0220] Similarly, in the secondary training phase, it is also necessary to perform reinforcement training on each first detection model based on each enhanced product image sample, and determine the reinforcement loss in the reinforcement training process.

[0221] Specifically, based on each enhanced product image sample, each first detection model is trained to obtain model weight data corresponding to each first detection model. From the model weight data, target model weight data that meets the selection criteria for enhanced training is determined. After determining the target model weight data that meets the selection criteria, an enhanced detection model that matches the target model weight data is identified. Based on the enhanced detection model, prediction processing is performed on each enhanced product image sample to obtain the enhanced prediction result corresponding to each enhanced detection model. The enhancement loss is then determined based on the enhanced prediction result and the second prediction result.

[0222] In one embodiment, reinforcement learning can be understood as an optimization algorithm during the training process. Specifically, based on the current state s, the agent changes the environment through its behavioral policy (i.e., action a) and provides a reward parameter r. The reward parameter r measures the score in the current state; a higher score indicates a more correct action by the agent. In other words, through reinforcement learning, the agent can learn a behavioral policy that maximizes the reward function r.

[0223] Specifically, in the embodiments of this application, when performing reinforcement training on the first detection model, the agent is the model weight data corresponding to each first detection model after reinforcement training, including... The agent's behavioral strategy can be understood as the first detection model specifically trained during reinforcement training, and the enhanced image samples applied to the trained first detection model. When determining the reward parameter r, the fusion loss from the training process of the second detection model needs to be applied. Specifically, the reward parameter r is determined by taking the negative of the fusion loss from the training process of the second detection model.

[0224] Similarly, in the secondary training phase, after determining the supervision loss and reinforcement loss, it is also necessary to determine the label loss during the training process of the second detection model based on the second prediction result and the labeled labels carried by the enhanced product image samples, and to determine the difference loss based on the reinforcement prediction result and supervision data. Thus, the fusion loss can be determined based on the label loss, supervision loss, the first weight corresponding to the supervision loss, reinforcement loss, the second weight corresponding to the reinforcement loss, difference loss, and the third weight corresponding to the difference loss. Finally, the reward parameters during the reinforcement training process can be determined based on the fusion loss.

[0225] Furthermore, by determining the maximum reward parameter from each reward parameter and the target detection model corresponding to the maximum reward parameter from each first detection model, and then using knowledge distillation training on the second detection model based on each enhanced product image sample and the target detection model, a well-trained quality detection model is obtained.

[0226] 3. Testing Phase

[0227] Specifically, during the testing phase, a trained quality inspection model is used to extract features and predict probabilities from the input test product images to obtain corresponding predicted defect confidence data. The test product image category is then determined by comparing the test defect confidence data with a preset defect confidence threshold.

[0228] The test product images were pre-labeled, with tags added to them including defect and normal labels. Images with a defect label were classified as defective, while those with a normal label were classified as normal. When comparing the test defect confidence data with a preset defect confidence threshold, the results included whether the test defect confidence data was greater than the threshold or less than the threshold. A test defect confidence data greater than the threshold indicated a defective product, while a test defect confidence data less than the threshold indicated a normal product.

[0229] Furthermore, based on the pre-added labels and the category of the test product image determined by the prediction results, the accuracy of the test results is judged. When the accuracy of the test results reaches the preset accuracy threshold, it indicates that the quality inspection model trained at this time meets the actual application requirements and can be put into the quality inspection process of actual industrial products, electronic products, etc., so as to improve the accuracy of product quality inspection and the accuracy of product defect classification.

[0230] In the above-mentioned method for constructing the quality detection model, enhanced product image samples are acquired, and prediction processing is performed on each enhanced product image sample based on multiple trained first and second detection models to obtain first and second prediction results. Further, by determining the supervision data corresponding to each first prediction result, supervised training of the second prediction result of the second detection model is achieved using the supervision data. Thus, the supervised loss during the training process of the second detection model can be determined based on the supervision data and the second prediction result. Simultaneously, based on the enhanced product image samples, each first detection model is reinforced and trained, and the reinforcement loss during the reinforcement training process is determined. Based on the obtained supervised loss and reinforcement loss, the reward parameter is determined. Thus, based on the reward parameter, the most suitable target detection model is determined from each first detection model. This achieves the purpose of using reinforcement training to further weight and select each first detection model and determine the most suitable target detection model. Furthermore, the second detection model is trained by knowledge distillation based on the target detection model, which enables the second detection model to learn the knowledge in the first detection model, reducing the dependence on pre-labeled labels in the product image samples and the noise error data brought by the pre-labeled labels. This results in a quality detection model with higher model accuracy, thereby improving the accuracy of product quality detection using the quality detection model.

[0231] In one embodiment, a method for constructing a quality inspection model is provided, specifically including the following steps:

[0232] Obtain product image samples and train the initial detection model based on each product image sample.

[0233] Determine the training loss during the training process of the initial detection model. If the training loss satisfies the termination condition for the initial detection model, the first trained detection model is obtained.

[0234] The system acquires enhanced product image samples and performs prediction processing on each enhanced product image sample based on multiple trained first detection models and second detection models to obtain first prediction results corresponding to each first detection model and second prediction results corresponding to each second detection model.

[0235] The weighting parameters associated with each first detection model are initialized and normalized to obtain the processed weighting coefficients.

[0236] Based on each weighting coefficient, the first prediction results are weighted sequentially to obtain supervisory data for the training process of the second detection model.

[0237] Based on the supervised data and the second prediction results, the supervised loss during the training of the second detection model is determined.

[0238] Based on the enhanced product image samples, each first detection model is trained to obtain the model weight data corresponding to each first detection model.

[0239] From the weight data of each model, the target model weight data that meets the selection criteria for reinforcement training is determined.

[0240] Determine the enhancement detection model that matches the target model weight data, and perform prediction processing on each enhanced product image sample based on the enhancement detection model to obtain the enhancement prediction result corresponding to each enhancement detection model.

[0241] The reinforcement loss is determined based on the reinforcement prediction results and the second prediction results.

[0242] Based on the second prediction results and the labeled tags carried by the enhanced product image samples, the label loss during the training process of the second detection model is determined.

[0243] Based on the enhanced forecast results and monitoring data, the differential loss is determined.

[0244] The fusion loss is determined based on the label loss, supervision loss, the first weight corresponding to the supervision loss, reinforcement loss, the second weight corresponding to the reinforcement loss, difference loss, and the third weight corresponding to the difference loss.

[0245] Based on the fusion loss, the reward parameters during the reinforcement training process are determined.

[0246] The maximum reward parameter is determined from all reward parameters, and the target detection model corresponding to the maximum reward parameter is determined from all first detection models.

[0247] Based on the enhanced product image samples and the target detection model, the second detection model is trained by knowledge distillation to obtain a well-trained quality detection model.

[0248] In the above-mentioned method for constructing the quality detection model, enhanced product image samples are acquired, and prediction processing is performed on each enhanced product image sample based on multiple trained first and second detection models to obtain first and second prediction results. Further, by determining the supervision data corresponding to each first prediction result, supervised training of the second prediction result of the second detection model is achieved using the supervision data. Thus, the supervised loss during the training process of the second detection model can be determined based on the supervision data and the second prediction result. Simultaneously, based on the enhanced product image samples, each first detection model is reinforced and trained, and the reinforcement loss during the reinforcement training process is determined. Based on the obtained supervised loss and reinforcement loss, the reward parameter is determined. Thus, based on the reward parameter, the most suitable target detection model is determined from each first detection model. This achieves the purpose of using reinforcement training to further weight and select each first detection model and determine the most suitable target detection model. Furthermore, the second detection model is trained by knowledge distillation based on the target detection model, which enables the second detection model to learn the knowledge in the first detection model, reducing the dependence on pre-labeled labels in the product image samples and the noise error data brought by the pre-labeled labels. This results in a quality detection model with higher model accuracy, thereby improving the accuracy of product quality detection using the quality detection model.

[0249] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0250] Based on the same inventive concept, this application also provides an object quality detection device and a quality detection model construction device for implementing the object quality detection method and the quality detection model construction method described above. The solution provided by this device is similar to the implementation scheme described in the above method. Therefore, the specific limitations of one or more object quality detection devices and quality detection model construction device embodiments provided below can be found in the limitations of the object quality detection method and the quality detection model construction method described above, and will not be repeated here.

[0251] In one embodiment, such as Figure 12 As shown, an object quality inspection device is provided, including: an image acquisition module 1202 for the product to be inspected and a defect confidence data acquisition module 1204, wherein:

[0252] The product image acquisition module 1202 is used to receive an object quality inspection request and acquire the product image corresponding to the object quality inspection request.

[0253] The defect confidence data acquisition module 1204 is used to perform quality inspection processing on the product image to be inspected based on the trained quality inspection model, and obtain defect confidence data corresponding to the product image to be inspected. Specifically, the trained quality inspection model is obtained by knowledge distillation training of the second detection model based on the target detection model; the target detection model is determined from each first detection model based on reward parameters, which are determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model based on enhanced product image samples; the supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result, which is obtained by predicting each enhanced product image sample based on multiple trained first detection models, and the second prediction result is obtained by predicting each enhanced product image sample based on the second detection model.

[0254] In the aforementioned object quality inspection device, an object quality inspection request is received, and an image of the product to be inspected corresponding to the request is acquired. Then, based on a trained quality inspection model, the image is processed to obtain defect confidence data corresponding to the image. The trained quality inspection model is obtained by knowledge distillation training of a second detection model using a target detection model. The target detection model is determined from each first detection model based on reward parameters. This achieves the goal of further weighting and selection of each first detection model through reinforcement training, determining the most suitable target detection model. The reward parameters are determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model using enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result. By training the second detection model with knowledge distillation based on the target model, the second detection model can learn the knowledge in the first detection model, reducing the reliance on pre-labeled tags in product image samples and the noise error data brought by pre-labeled tags, thereby obtaining a quality detection model with higher accuracy, thus improving the accuracy of product quality detection using the quality detection model.

[0255] In one embodiment, an object quality detection device is provided, further comprising a quality detection model training module, including:

[0256] The prediction result acquisition module is used to acquire enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain first prediction results corresponding to each first detection model and second prediction results corresponding to the second detection model.

[0257] The supervision loss determination module is used to determine the supervision data corresponding to each first prediction result, and to determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction result.

[0258] The enhancement loss determination module is used to enhance each first detection model based on each enhanced product image sample and determine the enhancement loss during the enhancement training process.

[0259] The reward parameter determination module is used to determine the reward parameters based on the supervised loss and the reinforcement loss.

[0260] The quality detection model acquisition module is used to determine the target detection model from each first detection model based on the reward parameters, and to perform knowledge distillation training on the second detection model based on the target detection model to obtain the trained quality detection model.

[0261] In one embodiment, the reinforcement loss determination module is further configured to:

[0262] Based on each enhanced product image sample, each first detection model is trained to obtain the model weight data corresponding to each first detection model; from each model weight data, the target model weight data that meets the screening conditions for enhanced training is determined; the enhanced detection model that matches the target model weight data is determined, and based on the enhanced detection model, each enhanced product image sample is predicted to obtain the enhanced prediction result corresponding to each enhanced detection model; based on the enhanced prediction result and the second prediction result, the enhancement loss is determined.

[0263] In one embodiment, the reward parameter determination module is further configured to:

[0264] Based on the second prediction result and the labeled labels carried by the enhanced product image samples, the label loss during the training process of the second detection model is determined; the difference loss is determined based on the enhanced prediction result and the supervised data; the fusion loss is determined based on the label loss, the supervised loss, the first weight corresponding to the supervised loss, the enhanced loss, the second weight corresponding to the enhanced loss, the difference loss, and the third weight corresponding to the difference loss; and the reward parameters during the enhanced training process are determined based on the fusion loss.

[0265] In one embodiment, the supervision loss determination module is further configured to:

[0266] The weighting parameters associated with each first detection model are initialized and normalized to obtain the processed weighting coefficients. Based on each weighting coefficient, the first prediction results are weighted sequentially to obtain the supervision data for the training process of the second detection model.

[0267] In one embodiment, the quality inspection model acquisition module is further configured to:

[0268] The maximum reward parameter is determined from all reward parameters, and the target detection model corresponding to the maximum reward parameter is determined from all first detection models. Based on the enhanced product image samples and the target detection model, the second detection model is trained by knowledge distillation to obtain a trained quality detection model.

[0269] In one embodiment, an object quality inspection apparatus is provided, further comprising a first inspection model acquisition module, used for:

[0270] Acquire product image samples and train the initial detection model based on each product image sample; determine the training loss during the training process of the initial detection model; if the training loss meets the termination condition for training the initial detection model, obtain the trained first detection model.

[0271] In one embodiment, such as Figure 13 As shown, a device for constructing a quality inspection model is provided, including: a prediction result acquisition module 1302, a supervision loss determination module 1304, a reinforcement loss determination module 1306, a reward parameter determination module 1308, and a quality inspection model acquisition module 1310, wherein:

[0272] The prediction result acquisition module 1302 is used to acquire enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each first detection model and a second prediction result corresponding to each second detection model.

[0273] The supervision loss determination module 1304 is used to determine the supervision data corresponding to each first prediction result, and to determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction result.

[0274] The enhancement loss determination module 1306 is used to perform enhancement training on each first detection model based on each enhanced product image sample, and to determine the enhancement loss during the enhancement training process.

[0275] The reward parameter determination module 1308 is used to determine the reward parameters based on the supervised loss and the reinforcement loss.

[0276] The quality detection model acquisition module 1310 is used to determine the target detection model from each first detection model according to the reward parameters, and to perform knowledge distillation training on the second detection model based on the target detection model to obtain the trained quality detection model.

[0277] In the aforementioned quality detection model construction apparatus, enhanced product image samples are acquired, and prediction processing is performed on each enhanced product image sample based on multiple trained first and second detection models to obtain first and second prediction results. Further, by determining the supervision data corresponding to each first prediction result, supervised training of the second prediction result of the second detection model is achieved using the supervision data. Thus, the supervision loss during the training process of the second detection model can be determined based on the supervision data and the second prediction result. Simultaneously, based on the enhanced product image samples, each first detection model is reinforced and trained, and the reinforcement loss during the reinforcement training process is determined. Based on the obtained supervised loss and reinforcement loss, the reward parameter is determined. Thus, based on the reward parameter, the most suitable target detection model is determined from each first detection model. This achieves the purpose of using reinforcement training to further weight and select each first detection model and determine the most suitable target detection model. Furthermore, the second detection model is trained by knowledge distillation based on the target detection model, which enables the second detection model to learn the knowledge in the first detection model, reducing the dependence on pre-labeled labels in the product image samples and the noise error data brought by the pre-labeled labels. This results in a quality detection model with higher model accuracy, thereby improving the accuracy of product quality detection using the quality detection model.

[0278] Each module in the aforementioned object quality inspection device and quality inspection model construction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0279] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 14As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as images of the product to be inspected, quality inspection models, defect confidence data, target detection models, first detection models, second detection models, reward parameters, supervised loss, reinforcement loss, first prediction results, second prediction results, supervised data, and enhanced product image samples. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements an object quality inspection method and a method for constructing a quality inspection model.

[0280] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0281] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0282] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0283] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0284] 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, data stored, data displayed, 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 related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0285] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0286] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 specification.

[0287] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for inspecting the quality of an object, characterized in that, The method includes: Receive an object quality inspection request and acquire an image of the product to be inspected corresponding to the object quality inspection request; Based on the trained quality inspection model, the image of the product to be inspected is subjected to quality inspection processing to obtain defect confidence data corresponding to the image of the product to be inspected. The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each first detection model based on a reward parameter, which is determined based on the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model based on enhanced product image samples. The supervised loss is determined based on the supervised data corresponding to the first prediction result and the second prediction result, where the first prediction result is obtained by predicting each enhanced product image sample based on multiple trained first detection models, and the second prediction result is obtained by predicting each enhanced product image sample based on the second detection model. The reinforcement loss is determined based on the reinforcement prediction result and the second prediction result, where the reinforcement prediction result is obtained by predicting each enhanced product image sample based on the reinforcement detection model matched with the target model weight data. The target model weight data is selected from the model weight data corresponding to each first detection model after reinforcement training according to the reinforcement training selection criteria. The process of determining reward parameters based on the supervised loss and the reinforcement loss includes: determining the label loss during the training process of the second detection model based on the second prediction result and the labeled tags carried by the enhanced product image samples; determining the difference loss based on the reinforcement prediction result and the supervised data; determining the fusion loss based on the label loss, the supervised loss, the first weight corresponding to the supervised loss, the reinforcement loss, the second weight corresponding to the reinforcement loss, the difference loss, and the third weight corresponding to the difference loss; and determining the reward parameters during the reinforcement training process based on the fusion loss.

2. The method according to claim 1, characterized in that, Methods for obtaining a well-trained quality detection model include: Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model; Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results; Based on the enhanced product image samples, each of the first detection models is enhanced and trained, and the enhancement loss of the enhancement training process is determined. Based on the supervision loss and the reinforcement loss, the reward parameters are determined; Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

3. The method according to claim 2, characterized in that, The step of performing reinforcement training on each of the first detection models based on each of the enhanced product image samples, and determining the reinforcement loss during the reinforcement training process, includes: Based on the enhanced product image samples, each of the first detection models is enhanced and trained to obtain the model weight data corresponding to each of the enhanced first detection models. From the model weight data described above, determine the target model weight data that meets the screening conditions for reinforcement training; Determine the enhancement detection model that matches the target model weight data, and perform prediction processing on each of the enhanced product image samples according to the enhancement detection model to obtain the enhancement prediction result corresponding to each enhancement detection model; The reinforcement loss is determined based on the reinforcement prediction result and the second prediction result.

4. The method according to claim 2 or 3, characterized in that, Determine the supervision data corresponding to each of the first prediction results, including: The weighting parameters associated with each of the first detection models are initialized and normalized to obtain the processed weighting coefficients. Based on the weighting coefficients, the first prediction results are weighted sequentially to obtain supervision data for the training process of the second detection model.

5. The method according to claim 2 or 3, characterized in that, The step of determining a target detection model from each of the first detection models based on the reward parameters, and then training the second detection model using knowledge distillation based on the target detection model to obtain a trained quality detection model includes: The maximum reward parameter is determined from each of the reward parameters, and the target detection model corresponding to the maximum reward parameter is determined from each of the first detection models; Based on the enhanced product image samples and the target detection model, the second detection model is trained by knowledge distillation to obtain a trained quality detection model.

6. The method according to any one of claims 1 to 3, characterized in that, Methods for obtaining a well-trained first detection model include: Obtain product image samples and train the initial detection model based on each of the product image samples; Determine the training loss during the training process of the initial detection model; If the training loss satisfies the training termination condition for the initial detection model, a well-trained first detection model is obtained.

7. A method for constructing a quality inspection model, characterized in that, The method includes: Obtain enhanced product image samples, and perform prediction processing on each enhanced product image sample according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model; Determine the supervision data corresponding to each of the first prediction results, and determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results; Based on the enhanced product image samples, each of the first detection models is subjected to reinforcement training, and the reinforcement loss of the reinforcement training process is determined; the reinforcement loss is determined based on the reinforcement prediction result and the second prediction result, wherein the reinforcement prediction result is obtained by performing prediction processing on each of the enhanced product image samples based on the enhanced detection model matched with the target model weight data; the target model weight data is selected from the model weight data corresponding to each of the first detection models after reinforcement training according to the reinforcement training selection criteria; Based on the second prediction result and the labeled tags carried by the enhanced product image samples, the label loss during the training process of the second detection model is determined; based on the enhanced prediction result and the supervised data, the difference loss is determined; based on the label loss, the supervised loss, the first weight corresponding to the supervised loss, the enhanced loss, the second weight corresponding to the enhanced loss, the difference loss, and the third weight corresponding to the difference loss, the fusion loss is determined; based on the fusion loss, the reward parameters during the enhanced training process are determined. Based on the reward parameters, a target detection model is determined from each of the first detection models, and the second detection model is trained by knowledge distillation based on the target detection model to obtain a trained quality detection model.

8. An object quality inspection device, characterized in that, The device includes: The product image acquisition module is used to receive an object quality inspection request and acquire the product image to be inspected corresponding to the object quality inspection request. The defect confidence data acquisition module is used to perform quality detection processing on the product image to be detected according to the trained quality detection model, and obtain defect confidence data corresponding to the product image to be detected. The trained quality detection model is obtained by knowledge distillation training of the second detection model based on the target detection model. The target detection model is determined from each first detection model based on a reward parameter, which is determined by the supervised loss during the training of the second detection model and the reinforcement loss during the reinforcement training of each first detection model based on enhanced product image samples. The supervised loss is determined based on supervised data corresponding to the first prediction result and the second prediction result. The first prediction result is obtained by predicting each enhanced product image sample using multiple trained first detection models, and the second prediction result is obtained by predicting each enhanced product image sample using the second detection model. The reinforcement loss is determined based on the reinforcement prediction result and the second prediction result. The result is obtained by predicting each of the enhanced product image samples based on the enhanced detection model matched with the target model weight data; the target model weight data is selected from the model weight data corresponding to each of the first detection models after enhanced training according to the enhanced training selection conditions; wherein, determining the reward parameter based on the supervised loss and the enhanced loss includes: determining the label loss during the training process of the second detection model based on the second prediction result and the labeled tags carried by the enhanced product image samples; determining the difference loss based on the enhanced prediction result and the supervised data; determining the fusion loss based on the label loss, supervised loss, the first weight corresponding to the supervised loss, the enhanced loss, the second weight corresponding to the enhanced loss, the difference loss, and the third weight corresponding to the difference loss; and determining the reward parameter during the enhanced training process based on the fusion loss.

9. The apparatus according to claim 8, characterized in that, The device also includes a quality detection model training module, comprising: The prediction result acquisition module is used to acquire enhanced product image samples, and perform prediction processing on each of the enhanced product image samples according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model. The supervision loss determination module is used to determine the supervision data corresponding to each of the first prediction results, and to determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results. The enhancement loss determination module is used to perform enhancement training on each of the first detection models based on each of the enhanced product image samples, and to determine the enhancement loss during the enhancement training process. The reward parameter determination module is used to determine the reward parameters based on the supervision loss and the reinforcement loss; The quality detection model acquisition module is used to determine the target detection model from each of the first detection models according to the reward parameters, and to perform knowledge distillation training on the second detection model according to the target detection model to obtain the trained quality detection model.

10. The apparatus according to claim 9, characterized in that, The enhancement loss determination module is further configured to: Based on the enhanced product image samples, each of the first detection models is subjected to reinforcement training to obtain the model weight data corresponding to each of the first detection models after reinforcement training; from the model weight data, target model weight data that meets the reinforcement training screening conditions is determined; an enhanced detection model that matches the target model weight data is determined, and based on the enhanced detection model, each of the enhanced product image samples is subjected to prediction processing to obtain the enhancement prediction result corresponding to each of the enhanced detection models; the enhancement loss is determined based on the enhancement prediction result and the second prediction result.

11. The apparatus according to claim 9 or 10, characterized in that, The supervision loss determination module is further used for: The weighting parameters associated with each of the first detection models are initialized and normalized to obtain the processed weighting coefficients. Based on the weighting coefficients, the first prediction results are weighted sequentially to obtain the supervision data for the training process of the second detection model.

12. The apparatus according to claim 9 or 10, characterized in that, The quality inspection model acquisition module is also used for: The maximum reward parameter is determined from each of the reward parameters, and the target detection model corresponding to the maximum reward parameter is determined from each of the first detection models; the second detection model is trained by knowledge distillation based on each of the enhanced product image samples and the target detection model to obtain a trained quality detection model.

13. The apparatus according to any one of claims 8 to 10, characterized in that, The device further includes a first detection model acquisition module, used for: Acquire product image samples and train an initial detection model based on each product image sample; determine the training loss during the training process of the initial detection model; if the training loss satisfies the training termination condition of the initial detection model, obtain a trained first detection model.

14. A device for constructing a quality inspection model, characterized in that, The device includes: The prediction result acquisition module is used to acquire enhanced product image samples, and perform prediction processing on each of the enhanced product image samples according to multiple trained first detection models and second detection models to obtain a first prediction result corresponding to each of the first detection models and a second prediction result corresponding to the second detection model. The supervision loss determination module is used to determine the supervision data corresponding to each of the first prediction results, and to determine the supervision loss during the training process of the second detection model based on the supervision data and the second prediction results. The enhancement loss determination module is used to perform enhancement training on each of the first detection models based on each of the enhanced product image samples, and to determine the enhancement loss during the enhancement training process. The enhancement loss is determined based on the enhancement prediction result and the second prediction result. The enhancement prediction result is obtained by performing prediction processing on each of the enhanced product image samples based on the enhanced detection model that matches the target model weight data. The target model weight data is selected from the model weight data corresponding to each of the first detection models after enhancement training based on the enhancement training selection criteria. The reward parameter determination module is used to determine the label loss during the training process of the second detection model based on the second prediction result and the labeled tags carried by the enhanced product image samples; determine the difference loss based on the enhanced prediction result and the supervision data; determine the fusion loss based on the label loss, supervision loss, a first weight corresponding to the supervision loss, enhancement loss, a second weight corresponding to the enhancement loss, difference loss, and a third weight corresponding to the difference loss; and determine the reward parameters during the enhancement training process based on the fusion loss. The quality detection model acquisition module is used to determine the target detection model from each of the first detection models according to the reward parameters, and to perform knowledge distillation training on the second detection model according to the target detection model to obtain the trained quality detection model.

15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Abdominal lymph node detection method and device based on semi-supervised learning

    CN115018852A

  • Defect detection model training method and device, equipment, medium and program product

    CN115147353A