Stamping part surface quality detection method and system

By using a knowledge distillation architecture in the stamping parts production workshop, the high-accuracy teacher model is moved to the student model, which solves the problem of insufficient detection accuracy caused by limited computing resources and achieves efficient stamping parts surface quality inspection.

CN120147302AInactive Publication Date: 2025-06-13XUZHOU ZHONGJIASHENG METAL TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510358953.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-06-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In stamping parts production workshops, deep learning-based computer vision detection models are difficult to implement because the equipment has limited computing resources and the use of traditional statistical learning methods or machine learning methods leads to insufficient accuracy of quality detection.

Method used

Using a knowledge distillation architecture, the teacher model with high accuracy but requires higher computing resources is migrated to the student model with smaller parameters and no excessive computing resources, and the student model is used for computer vision detection.

Benefits of technology

With limited computing resources in the stamping parts production workshop, computer vision detection with high accuracy is achieved, avoiding the problem of insufficient detection accuracy in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120147302A_ABST
    Figure CN120147302A_ABST
Patent Text Reader

Abstract

The invention discloses a stamping part surface quality detection method and system, and the method comprises the steps: collecting an image of a stamping part with surface defects, and generating a stamping part surface defect image data set; a teacher model and a student model are established based on the knowledge distillation architecture, the parameter quantity of the teacher model is larger than that of the student model, and the reasoning speed of the student model is faster than that of the teacher model; training a teacher model by using the stamping part surface defect image data set, and fixing all parameters after the teacher model finishes training; training the student model by using the stamping part surface defect image data set and the detection output of the teacher model, and migrating the detection mode of the teacher model to the student model; according to the method, the real-time stamping part image is obtained, the student model completing training is input, the defect position and the corresponding defect type in the real-time stamping part image are detected and output, the surface quality of the stamping part is accurately detected through computer vision detection, and needed computing resources can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of visual inspection, and specifically relates to a method and system for detecting the surface quality of stamping parts. Background Art

[0002] The production process of stamping parts includes multiple steps such as blanking, bending, and stretching. Due to reasons such as material quality and tensile strength, surface defects such as cracks, wrinkles, and pitting may occur in certain cases. In an automated production process, computer vision inspection technology is required to automatically detect these defects to prevent stamping parts with surface quality defects from entering subsequent processing steps.

[0003] However, using computer vision inspection technology for quality inspection usually requires deploying a high-performance deep learning model. In a stamping part production workshop, the computing resources of the equipment are very limited, which makes it difficult to implement a computer vision inspection model based on deep learning. In addition, if traditional statistical learning methods or machine learning methods are used, the accuracy of quality inspection will be insufficient. Summary of the Invention

[0004] The purpose of the present invention is to provide a method and system for detecting the surface quality of stamping parts, aiming to solve the problem that using computer vision inspection technology for quality inspection usually requires deploying a high-performance deep learning model. In a stamping part production workshop, the computing resources of the equipment are very limited, which makes it difficult to implement a computer vision inspection model based on deep learning, and using traditional statistical learning methods or machine learning methods will result in insufficient accuracy of quality inspection.

[0005] In view of the above problems, the present application provides a method and system for detecting the surface quality of stamping parts.

[0006] In the first aspect disclosed by the present application, a method for detecting the surface quality of stamping parts is provided. The method includes: Collect images of stamping parts with surface defects, and mark the defect positions and corresponding defect types in the stamping part images to generate a stamping part surface defect image dataset; Based on a knowledge distillation architecture, establish a teacher model and a student model. Both the teacher model and the student model can detect and output the defect positions and corresponding defect types in the input stamping part images. The number of parameters of the teacher model is greater than that of the student model, and the inference speed of the student model is faster than that of the teacher model; Use the stamping part surface defect image dataset to train the teacher model, and fix all the parameters of the teacher model after training; Use the stamping part surface defect image dataset and the detection output of the teacher model to train the student model, and transfer the detection mode of the teacher model to the student model; Obtain real-time stamping part images, input the trained student model, and detect and output the defect positions and corresponding defect types in the real-time stamping part images.

[0007] Preferably, collect stamping part images with surface defects, mark the defect positions and corresponding defect types in the stamping part images, and generate a stamping part surface defect image dataset, including: Collect stamping part images with surface defects, and unify the file formats and sizes of all stamping part images through format conversion and image cropping; For each stamping part image, create a marking file. Each line of the marking file is used to mark a defect in the current stamping part image. Among them, each line of the marking file includes the coordinates, width, and height of the detection box of the defect position, as well as the type code of the defect type; All marking files are stored in text form, corresponding one by one with all stamping part images. All stamping part images and the corresponding marking files together constitute the stamping part surface defect image dataset.

[0008] Preferably, establish a teacher model and a student model based on the knowledge distillation architecture, specifically including: Use the YOLOv5x model as the teacher model and the YOLOv5n model as the student model to construct a knowledge distillation architecture; Align the feature maps output by the backbone networks and feature pyramids of the teacher model and the student model respectively through mean squared error loss.

[0009] Preferably, use the stamping part surface defect image dataset to train the teacher model, and fix all the parameters of the teacher model after training, specifically including: Divide the stamping part surface defect image dataset into a training set, a validation set, and a test set according to the ratio of 8:1:1; Iteratively train the teacher model through the training set. The loss function of the teacher model includes a classification loss function, an object existence loss function, and a detection box regression loss function; At the end of each round of iterative training of the teacher model, calculate the mean average precision of the teacher model through the validation set. When the mean average precision on the validation set does not increase after 20 consecutive rounds of iterative training, stop the iterative training; Calculate the mean average precision of the teacher model through the test set. If it is greater than the preset threshold, the teacher model is considered to be trained. Otherwise, use the training set to re-iteratively train the teacher model; Fix all the parameters of the teacher model after training and make no further changes or updates.

[0010] Preferably, the student model is trained using the stamping part surface defect image dataset and the detection output of the teacher model, and the detection mode of the teacher model is transferred to the student model, which specifically includes: Obtain all stamping part images in the stamping part surface defect image dataset, and input all stamping part images into the teacher model. The teacher model detects and outputs the defect positions and corresponding defect types in all stamping part images. Based on the defect positions and corresponding defect types in all the stamping part images annotated in the stamping part surface defect image dataset, establish the original loss function of the student model. The original loss function of the student model includes a classification loss function, an object existence loss function, and a detection box regression loss function. Based on the defect positions and corresponding defect types in all the stamping part images detected and output by the teacher model, establish the distillation loss function of the student model. The distillation loss function of the student model includes a classification loss function and a detection box regression loss function. Among them, the KL divergence is used as the classification loss function, and the mean square error loss is used as the detection box regression loss function. Combine the original loss function and the distillation loss function of the student model to train the student model. Among them, in the combination process, a weighted summation method is used for the original loss function and the distillation loss function of the student model.

[0011] The second aspect disclosed in this application provides a stamping part surface quality detection system, which is used for the above-mentioned stamping part surface quality detection method. The system includes: A dataset module, which is used to collect stamping part images with surface defects, annotate the defect positions and corresponding defect types in the stamping part images, and generate a stamping part surface defect image dataset. An architecture module, which is used to establish a teacher model and a student model based on the knowledge distillation architecture. Both the teacher model and the student model can, according to the input stamping part image, detect and output the defect positions and corresponding defect types in the stamping part image. The number of parameters of the teacher model is greater than that of the student model, and the inference speed of the student model is faster than that of the teacher model. A first training module, which is used to train the teacher model using the stamping part surface defect image dataset and fix all the parameters of the teacher model after training. A second training module, which is used to train the student model using the stamping part surface defect image dataset and the detection output of the teacher model, and transfer the detection mode of the teacher model to the student model. A real-time detection module, which is used to obtain real-time stamping part images, input the trained student model, and detect and output the defect positions and corresponding defect types in the real-time stamping part images.

[0012] The third aspect disclosed in this application provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned method for detecting the surface quality of a stamping part are implemented.

[0013] The fourth aspect disclosed in this application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for detecting the surface quality of a stamping part are implemented.

[0014] The fifth aspect disclosed in this application provides a computer program product, including a computer program or instruction. When the computer program or instruction is executed by a processor, the steps of the above-mentioned method for detecting the surface quality of a stamping part are implemented.

[0015] The beneficial effects of the present invention are as follows: (1) The present invention utilizes a knowledge distillation architecture to transfer a teacher model with high accuracy but requiring high computing resources to a student model with a small number of parameters and without excessive computing resources. The student model is used to implement computer vision detection in the case of extremely limited computing resources in a stamping part production workshop. (2) Through the knowledge distillation architecture, while compressing a model with a large number of parameters into a model with a small number of parameters, the detection accuracy of the model with a large number of parameters is maintained, and accurate detection of the surface quality of stamping parts is achieved using computer vision detection technology. Description of the Drawings

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0017] Figure 1 It is an overall flowchart of a method for detecting the surface quality of a stamping part.

[0018] Figure 2 It is an overall structural diagram of a system for detecting the surface quality of a stamping part. Detailed Embodiments

[0019] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0020] Embodiment 1: As Figure 1 shown, an embodiment of the present application provides a method for detecting the surface quality of stamped parts, and the method includes: Collect images of stamped parts with surface defects, and mark the defect positions and corresponding defect types in the stamped part images to generate a dataset of stamped part surface defect images; Specifically, collect images of stamped parts with surface defects, and unify the file formats and sizes of all stamped part images through format conversion and image cropping; for each stamped part image, create a marking file, and each line of the marking file is used to mark a defect in the current stamped part image. Among them, each line of the marking file includes the coordinates, width, and height of the detection box of the defect position, as well as the type code of the defect type; all marking files are stored in text form and correspond one by one with all stamped part images. All stamped part images and their corresponding marking files together form a dataset of stamped part surface defect images.

[0021] For example, in the marking file corresponding to a stamped part image, each line represents a defect in the current stamped part image, and its format is usually class,x_center,y_center,width,height. Among them, class is the type code of the defect type, represented in the form of a one-hot vector; x_center and y_center are the coordinates of the center point of the detection box respectively, represented as a ratio of the image width and height, and the value range is between 0 and 1; width and height are the width and height of the detection box respectively, also represented as a ratio of the image width and height, and the value range is between 0 and 1.

[0022] Based on the knowledge distillation architecture, a teacher model and a student model are established. Both the teacher model and the student model can detect and output the defect positions and corresponding defect types in the input stamped part images. The number of parameters of the teacher model is greater than that of the student model, and the inference speed of the student model is faster than that of the teacher model; Specifically, use the YOLOv5x model as the teacher model and the YOLOv5n model as the student model to construct a knowledge distillation architecture; align the feature maps output by the backbone network and the feature pyramid of the teacher model and the student model respectively through mean squared error loss; Specifically, in a knowledge distillation architecture, a complex and parameter-rich model is usually used as the teacher model, and a model with a simple structure is used as the student model. The teacher model is used to assist in the training of the student model, and the patterns learned by the teacher model are transferred to the student model to enhance the detection accuracy of the student model. The YOLOv5x model is large in scale, high in complexity, and high in detection accuracy, making it suitable as the teacher model. YOLOv5n is a lightweight model with low computational resource requirements, fast detection speed but relatively low accuracy, making it suitable as the student model to learn the patterns of the teacher model to improve its own accuracy.

[0023] Train the teacher model using the stamping part surface defect image dataset, and fix all the parameters of the teacher model after training is completed; Specifically, divide the stamping part surface defect image dataset into a training set, a validation set, and a test set according to a ratio of 8:1:1; perform iterative training on the teacher model using the training set. The loss function of the teacher model includes a classification loss function, an object existence loss function, and a detection box regression loss function; at the end of each round of iterative training of the teacher model, calculate the mean average precision of the teacher model using the validation set. When the mean average precision on the validation set does not increase after 20 consecutive rounds of iterative training, stop the iterative training; calculate the mean average precision of the teacher model using the test set. If it is greater than the preset threshold, the teacher model is considered to be trained. Otherwise, use the training set to re-iterate the training of the teacher model; fix all the parameters of the teacher model after training is completed and make no further changes or updates.

[0024] Train the student model using the stamping part surface defect image dataset and the detection output of the teacher model, and transfer the detection pattern of the teacher model to the student model; Specifically, all stamping part images in the stamping part surface defect image dataset are obtained, and all stamping part images are input into the teacher model. The teacher model detects and outputs the defect positions and corresponding defect types in all stamping part images; based on the defect positions and corresponding defect types in all stamping part images annotated in the stamping part surface defect image dataset, the original loss function of the student model is established. The original loss function of the student model includes a classification loss function, an object existence loss function, and a detection box regression loss function. Among them, both the classification loss function and the object existence loss function use the cross-entropy loss function, and the detection box regression loss function uses the GIoU loss function; based on the defect positions and corresponding defect types in all stamping part images detected and output by the teacher model, the distillation loss function of the student model is established. The distillation loss function of the student model includes a classification loss function and a detection box regression loss function. Among them, the KL divergence is used as the classification loss function, and the mean square error loss is used as the detection box regression loss function. In the distillation loss function, the student model learns the soft label distribution of the teacher model. The soft label distribution is the probability distribution output by the teacher model for the input softened through the temperature scaling technique; the original loss function and the distillation loss function of the student model are combined to train the student model. Among them, in the combination process, the method of weighted summation of the original loss function and the distillation loss function of the student model is adopted. In this process, it is necessary to balance the weights used in the weighted summation of the two to avoid the distillation loss function dominating the training process of the student model.

[0025] Obtain real-time stamping part images, input them into the trained student model, and detect and output the defect positions and corresponding defect types in the real-time stamping part images; Specifically, the defect positions and corresponding defect types detected and output by the student model in the real-time stamping part images are mainly represented as class, x_center, y_center, width, and height. Among them, class is the type code of the defect type, represented in the form of a one-hot vector; x_center and y_center are the coordinates of the center point of the detection box, represented as a ratio of the image width and height, with a value range between 0 and 1; width and height are the width and height of the detection box, also represented as a ratio of the image width and height, with a value range between 0 and 1.

[0026] In summary, the stamping part surface quality detection method provided by the embodiments of the present application has the following technical effects: (1) The present invention uses a knowledge distillation architecture to transfer the teacher model with high accuracy but requiring high computing resources to the student model with a small number of parameters and not requiring excessive computing resources, and uses the student model to achieve computer vision detection in the case of extremely limited computing resources in the stamping part production workshop; (2) Through the knowledge distillation architecture, while compressing a model with a large number of parameters into a model with a small number of parameters, the detection accuracy of the model with a large number of parameters is maintained, and accurate detection of the surface quality of stamping parts is achieved using computer vision detection technology.

[0027] Embodiment 2: Based on the same inventive concept as a method for detecting the surface quality of stamping parts in Embodiment 1, as Figure 2 shown, the present application provides a system for detecting the surface quality of stamping parts, the system comprising: A dataset module, which is used to collect stamping part images with surface defects, annotate the defect positions and corresponding defect types in the stamping part images, and generate a stamping part surface defect image dataset; An architecture module, which is used to establish a teacher model and a student model based on the knowledge distillation architecture. Both the teacher model and the student model can, according to the input stamping part image, detect and output the defect positions and corresponding defect types in the stamping part image. The number of parameters of the teacher model is greater than that of the student model, and the inference speed of the student model is faster than that of the teacher model; A first training module, which is used to train the teacher model using the stamping part surface defect image dataset and fix all the parameters of the teacher model after training; A second training module, which is used to train the student model using the stamping part surface defect image dataset and the detection output of the teacher model, and transfer the detection mode of the teacher model to the student model; A real-time detection module, which is used to obtain real-time stamping part images, input the trained student model, and detect and output the defect positions and corresponding defect types in the real-time stamping part images.

[0028] Through the foregoing detailed description of a method for detecting the surface quality of stamping parts in this specification, those skilled in the art can clearly know a system for detecting the surface quality of stamping parts in this embodiment. Since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and for related parts, reference may be made to the description in the method part.

[0029] Embodiment 3: In Embodiment 3, a computer device is provided, comprising a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps of the above-mentioned method for detecting the surface quality of stamping parts are implemented.

[0030] Embodiment 4: In the fourth embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for detecting the surface quality of a stamping part are implemented.

[0031] Embodiment Five: In the fifth embodiment, a computer program product is provided, including a computer program or instruction. When the computer program or instruction is executed by a processor, the steps of the above-mentioned method for detecting the surface quality of a stamping part are implemented.

[0032] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, 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, it should be considered as the scope described in this specification.

[0033] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting the surface quality of stamping parts, characterized in that: The method comprises: Collect images of stamping parts with surface defects, mark the defect locations and corresponding defect types in the stamping parts images, and generate stamping parts surface defect image datasets; The teacher model and student model are established based on the knowledge distillation architecture. Both the teacher model and the student model can detect the defect locations and corresponding defect types in the output stamping part images based on the input stamping part images. The number of parameters of the teacher model is greater than that of the student model, and the reasoning speed of the student model is faster than that of the teacher model. The teacher model is trained using a stamping parts surface defect image dataset, and all parameters of the teacher model are fixed after training. The student model is trained using the stamping surface defect image dataset and the detection output of the teacher model, and the detection mode of the teacher model is transferred to the student model. Acquire real-time stamping part images, input the trained student model, detect and output the defect locations and corresponding defect types in the real-time stamping part images.

2. A stamping part surface quality inspection method as claimed in claim 1, characterized in that: The method of collecting images of stamping parts with surface defects, marking defect locations and corresponding defect types in the stamping parts images, and generating a stamping parts surface defect image dataset includes: Collect images of stamping parts with surface defects, and unify the file format and size of all stamping part images through format conversion and image cropping; For each stamping part image, create a labeling file, where each line of the labeling file is used to label a defect in the current stamping part image, wherein each line of the labeling file includes the coordinates, width and height of the detection box of the defect position, and the type code of the defect type; All annotation files are stored in the form of text and correspond one-to-one to all stamping part images. All stamping part images and the corresponding annotation files together constitute the stamping part surface defect image dataset.

3. A stamping part surface quality inspection method as claimed in claim 2, characterized in that: The teacher model and the student model are established based on the knowledge distillation architecture, specifically including: Use the YOLOv5x model as the teacher model and the YOLOv5n model as the student model to build a knowledge distillation architecture; The feature maps output by the backbone network and feature pyramid of the teacher model and the student model are respectively aligned using the mean square error loss.

4. A stamping part surface quality inspection method as claimed in claim 3, characterized in that: The teacher model is trained using a stamping part surface defect image dataset, and all parameters of the teacher model are fixed after training, specifically including: The stamping parts surface defect image dataset is divided into training set, validation set and test set in a ratio of 8:1:1; The teacher model is iteratively trained using the training set. The loss functions of the teacher model include classification loss function, target existence loss function, and detection box regression loss function. At the end of each round of iterative training of the teacher model, the average accuracy of the teacher model is calculated through the validation set. When the average accuracy on the validation set does not increase after 20 consecutive rounds of iterative training, the iterative training is stopped; The average precision of the teacher model is calculated through the test set. If it is greater than the preset threshold, the teacher model has completed the training. Otherwise, the teacher model is re-trained iteratively using the training set. All parameters of the teacher model after training are fixed and no changes or updates are made.

5. A stamping part surface quality inspection method as claimed in claim 4, characterized in that: The method uses the stamping part surface defect image dataset and the detection output of the teacher model to train the student model, and transfers the detection mode of the teacher model to the student model, specifically including: Obtain all stamping part images in the stamping part surface defect image dataset, and input all stamping part images into the teacher model. The teacher model detects and outputs the defect locations and corresponding defect types in all stamping part images. Based on the defect locations and corresponding defect types in all stamping parts images marked in the stamping parts surface defect image dataset, the original loss function of the student model is established. The original loss function of the student model includes the classification loss function, the target existence loss function and the detection box regression loss function. Based on the defect locations and corresponding defect types in all stamping parts images detected and output by the teacher model, a distillation loss function of the student model is established. The distillation loss function of the student model includes a classification loss function and a detection box regression loss function, where KL divergence is used as the classification loss function and mean square error loss is used as the detection box regression loss function; The original loss function and the distillation loss function of the student model are combined to train the student model, wherein a weighted summation of the original loss function and the distillation loss function of the student model is adopted in the combination process.

6. A stamping part surface quality detection system, the system comprising: A data set module, which is used to collect images of stamping parts with surface defects, mark the defect locations and corresponding defect types in the stamping part images, and generate a stamping part surface defect image data set; An architecture module, wherein the architecture module is used to establish a teacher model and a student model based on a knowledge distillation architecture. Both the teacher model and the student model can detect defect locations and corresponding defect types in output stamping part images based on input stamping part images. The number of parameters of the teacher model is greater than that of the student model, and the reasoning speed of the student model is faster than that of the teacher model. A first training module, the first training module is used to train the teacher model using the stamping part surface defect image dataset, and fix all parameters of the teacher model after the training is completed; A second training module, the second training module is used to train the student model using the stamping part surface defect image dataset and the detection output of the teacher model, and transfer the detection mode of the teacher model to the student model; A real-time detection module is used to obtain a real-time stamping part image, input a trained student model, detect and output the defect position and corresponding defect type in the real-time stamping part image.

7. 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, the steps of a stamping part surface quality detection method described in any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of any one of claims 1 to 5 for detecting the surface quality of stamping parts are implemented.

9. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of a stamping part surface quality detection method described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Knowledge distillation-based YOLOv5 target detection method

    CN115631396A

  • Steel plate surface defect detection method and system based on knowledge distillation

    CN118096768A

  • Lightweight track surface defect real-time detection method and device

    CN119313663A