Enhanced YOLOv7-based metal appearance quality detection method and system, computer equipment and storage medium

By adding a small object detection layer and a moving window self-attention module in the YOLOv7 model and replacing the loss function, the problem of insufficient detection accuracy of small size defects in metal appearance defect detection is solved, achieving higher detection accuracy and adaptability to complex environments.

CN119887705APending Publication Date: 2025-04-25KEPENG INTELLIGENT TECH (SUZHOU) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411972075.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the detection of metal appearance defects, especially small-size defects, the detection accuracy is insufficient and the adaptability to complex industrial environments.

Method used

Based on the metal appearance quality detection method of enhanced YOLOv7, a small object detection layer is added to the detection head of the original YOLOv7 model, a mobile window self-attention module is introduced, and the CIoU loss function is replaced as a SIoU loss function, so as to improve the model's detection ability and detection accuracy of small-size defects.

Benefits of technology

The model's detection ability and detection accuracy for small-sized defects is improved, the adaptability to complex industrial environments is enhanced, and the accuracy and real-time detection of metal appearance defects is significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119887705A_ABST
    Figure CN119887705A_ABST
Patent Text Reader

Abstract

The invention discloses a metal appearance quality detection method and system based on enhanced YOLOv7, computer equipment and a storage medium, and relates to the cross technical field of metal processing and quality control, and the method comprises the following steps: collecting aluminum foil surface defect picture data, constructing an aluminum foil surface defect data set, and carrying out preprocessing to obtain a first data set; based on the first data set and the enhanced YOLOv7 network, constructing an aluminum foil surface defect detection model; training the aluminum foil surface defect detection model by using the training set in the first data set, and evaluating the performance of the model through a preset evaluation index; detecting a to-be-detected aluminum foil surface picture by using the trained aluminum foil surface defect detection model; the method has extremely high detection precision, can meet the requirement of real-time detection, remarkably improves the accuracy of metal appearance anomaly detection, and provides powerful technical support for quality control and appearance anomaly point recognition of various metal products.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the cross-technical field of metal processing and quality control, and in particular to a metal appearance quality detection method, system, computer equipment and storage medium based on enhanced YOLOv7. Background Art

[0002] With the continuous growth of the global economy and industrial upgrading, the demand for basic metal materials, as an indispensable basic element of modern industry, continues to rise. In order to meet the urgent demand for high-quality metal materials for national defense and civilian products, and to meet the international product quality standards, the appearance quality of metals has become one of the key indicators for measuring material quality. Especially in the production process of high-end materials such as battery aluminum foil and PS substrate, any tiny defects on the surface of raw materials may have a significant impact on subsequent processing and product performance. Therefore, it is particularly important to conduct timely and accurate detection and control of metal appearance quality. However, in the actual metal processing process, due to various factors such as fluctuations in raw material quality, precision limitations of rolling equipment, and improper adjustment of process parameters, various types of defects such as indentations, scratches, bumps, and holes often appear on the metal surface. These defects not only damage the appearance of the product, but are also likely to weaken its mechanical properties, corrosion resistance, and service life, thereby increasing subsequent processing costs and reducing the market competitiveness of enterprises. At the same time, the complexity of the metal processing environment, such as high temperature, dust, vibration and other harsh conditions, as well as the high efficiency requirements of production speed, make traditional manual detection methods difficult to perform online detection tasks.

[0003] In this context, the online automatic detection technology of metal appearance defects has emerged and has become the focus of many companies. In recent years, algorithm research with machine vision as the core has made significant progress in the field of metal appearance defect detection. However, facing the challenges of real and complex industrial environments, such as low contrast between defects and background, diverse defect sizes and uneven distribution, and severe image noise interference, traditional image processing methods often find it difficult to achieve satisfactory detection results. They usually require complex preprocessing steps and threshold settings, and have obvious deficiencies in efficiency and accuracy; in contrast, methods based on deep learning have shown strong advantages in the field of surface defect detection. Deep learning algorithms can automatically learn and extract high-level features in images, and efficiently identify and locate defects under complex backgrounds. In particular, based on the YOLO series of target detection algorithms, the detection accuracy and real-time performance of metal appearance defects can be further improved by introducing attention mechanisms, optimizing network structures, and improving loss functions. However, although the detection algorithms based on deep learning have achieved remarkable results, the detection accuracy of small-size defects still needs to be further improved to meet the higher requirements of industrial production. Summary of the invention

[0004] In view of the above-mentioned problems, the present invention is proposed.

[0005] Therefore, the technical problems solved by the present invention are: technical problems in metal appearance defect detection, especially the insufficient detection accuracy of small-size defects and the adaptability to complex industrial environments.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] In a first aspect, an embodiment of the present invention provides a metal appearance quality detection method based on enhanced YOLOv7, comprising:

[0008] Collecting aluminum foil surface defect image data, constructing an aluminum foil surface defect data set and performing preprocessing to obtain a first data set;

[0009] Based on the first data set and the enhanced YOLOv7 network, an aluminum foil surface defect detection model is constructed;

[0010] Using the training set in the first data set to train the aluminum foil surface defect detection model, and evaluating the model performance through the preset evaluation index;

[0011] Use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

[0012] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0013] The construction of the aluminum foil surface defect data set and preprocessing includes:

[0014] The collected aluminum foil surface defect image data were manually annotated to obtain an aluminum foil surface defect dataset, which includes 15 types of aluminum foil surface defects, namely peeling, holes, oil stains, black spots, lines, insect marks, wrinkles, knocks, bulges, foreign body intrusion, corrosion, oxidation, scratches, bubbles, and aluminum sticking; the aluminum foil surface defect dataset was enhanced and the enhanced dataset was divided into training set, validation set and test set.

[0015] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0016] The construction of the aluminum foil surface defect detection model comprises:

[0017] A small target detection layer is added to the detection head of the original YOLOv7 model, a moving window self-attention module is added after the large-size feature map feature extraction, and the SIoU loss function is used to replace the CIoU loss function of the original YOLOv7 model.

[0018] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0019] The dimension of the detection head output of the small target detection layer is 3×160×160×85, where 160×160 represents the size of the feature map, each point in the feature map corresponds to an anchor point, 3 represents that each anchor point has three target boxes, 85 represents the confidence corresponding to 80 categories, 1 is used to represent the probability of being an object, and the other 4 give the coordinates of the four vertices of the predicted target box; the preset parameters of the anchor box of the detection head of the small target detection layer are [19, 27, 44, 40, 38, 94].

[0020] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0021] The aluminum foil surface defect detection model is trained using the training set in the first data set, and the model performance is evaluated by a preset evaluation index, including:

[0022] The images in the training set are uniformly cropped to a preset size, the input image size, training batch size, and number of repeated training of the aluminum foil surface defect detection model are set, the model is trained using the training set images, the model with the best performance during the training process is selected as the trained aluminum foil surface defect detection model, and the model effect is evaluated using the test set.

[0023] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0024] The method of using the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be detected includes:

[0025] The image of the aluminum foil surface to be inspected is resized to match the input size requirement of the aluminum foil surface defect detection model; the pixel values ​​of the image are normalized and converted into a tensor format suitable for model input, and the processed image is input into the model for forward propagation to obtain the model's prediction results.

[0026] As a preferred solution for metal appearance quality inspection method based on enhanced YOLOv7,

[0027] The prediction results of the acquisition model include:

[0028] Parse the target box, category and confidence information from the tensor output by the model;

[0029] Perform non-maximum suppression on the parsed target box, remove redundant detection boxes, and retain the box with the highest confidence;

[0030] Set the confidence threshold and only keep the detection boxes whose confidence is higher than the confidence threshold;

[0031] Mark the detection results on the original image and output the detection results visually.

[0032] In a second aspect, an embodiment of the present invention provides a metal appearance quality detection system based on enhanced YOLOv7, including:

[0033] A data collection and preprocessing module is used to collect aluminum foil surface defect image data, construct an aluminum foil surface defect data set and perform preprocessing to obtain a first data set;

[0034] A model building module, used for building an aluminum foil surface defect detection model based on the first data set and the enhanced YOLOv7 network;

[0035] A model training and evaluation module, used to train the aluminum foil surface defect detection model using the training set in the first data set, and evaluate the model performance through preset evaluation indicators;

[0036] The defect detection and application module is used to use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

[0037] In a third aspect, an embodiment of the present invention provides a computing device, including:

[0038] Memory and processor;

[0039] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the one or more programs are executed by the one or more processors, the one or more processors implement the metal appearance quality detection method based on enhanced YOLOv7 as described in any embodiment of the present invention.

[0040] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the metal appearance quality detection method based on enhanced YOLOv7.

[0041] Beneficial effects of the present invention: The present invention adds a small target detection layer to the detection head of the original YOLOv7 model. The feature map of this layer has a larger size and a smaller receptive field, which better preserves the information of the middle and shallow layers of the image and improves the model's ability to detect small-sized defects; after the feature extraction of the large-sized feature map, a window self-attention module is added to make the model pay more attention to important feature areas, thereby improving the detection accuracy; the CIoU loss function in the original YOLOv7 model is replaced by the SIoU loss function, which speeds up the convergence speed of the model and improves the regression accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0043] Figure 1 It is an overall flow chart of the metal appearance quality detection method based on enhanced YOLOv7 described in the present invention;

[0044] Figure 2 It is an overall structure diagram of an improved YOLOv7 network of a metal appearance quality detection method based on enhanced YOLOv7 according to the present invention;

[0045] Figure 3 It is a schematic diagram of the SwinTransformer module used in the metal appearance quality detection method based on enhanced YOLOv7 described in the present invention;

[0046] Figure 4 It is a schematic diagram of SIoU parameters used in the metal appearance quality detection method based on enhanced YOLOv7 described in the present invention. DETAILED DESCRIPTION

[0047] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0049] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0050] Example 1

[0051] Reference Figure 1, which is the first embodiment of the present invention, and provides a metal appearance quality detection method based on enhanced YOLOv7, comprising:

[0052] S1: Collecting aluminum foil surface defect image data, constructing an aluminum foil surface defect data set and performing preprocessing to obtain a first data set;

[0053] S2: Based on the first data set and the enhanced YOLOv7 network, an aluminum foil surface defect detection model is constructed;

[0054] S3: Use the training set in the first data set to train the aluminum foil surface defect detection model, and evaluate the model performance through preset evaluation indicators.

[0055] S4: Use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

[0056] It should be noted that the detection method implemented by steps S1-S4 not only has extremely high detection accuracy, but also can meet the requirements of real-time detection, significantly improving the accuracy of metal appearance anomaly detection. This method can be widely used in the quality control of metal material production lines, providing strong technical support for quality control and appearance anomaly identification of various metal products, and has broad practical application value and promotion prospects.

[0057] Example 2

[0058] Reference Figure 1-Figure 4 , which is an embodiment of the present invention, provides a metal appearance quality detection method based on enhanced YOLOv7 based on the previous embodiment, including:

[0059] In the embodiment of the present application, collecting the aluminum foil surface defect image data in the above step S1 includes:

[0060] The surface image data of the aluminum foil production line was captured by a high-resolution camera, and the obtained images were segmented into 640×640 sizes to form an original picture set. The original picture set was manually annotated to obtain a data set of different surface defects of aluminum foil, of which 15 types of surface defects of aluminum foil were included, corresponding to: peeling, holes, oil stains, black spots, lines, insect marks, wrinkles, knocks, bulges, foreign matter intrusion, corrosion, oxidation, scratches, bubbles, and aluminum sticking.

[0061] In the embodiment of the present application, the preprocessing in the above step S1 includes:

[0062] The data set was enhanced, including cropping, scaling, rotating, translating, mirroring, changing brightness and other operations on the images in the data set. The enhanced data set was divided into training set, validation set and test set in a ratio of 8:1:1.

[0063] It should be noted that the number of samples in the data set is too small, and overfitting is prone to occur during the training process, which in turn affects the effect of aluminum foil defect detection. Therefore, data enhancement technology is used to expand the data set of aluminum foil surface defects. Data enhancement methods include cropping, scaling, rotation, translation, mirroring, brightness changes, and other operations to generate more training samples. By expanding the data set, the scale of the data set is increased, which can improve the generalization ability and robustness of the model. Finally, the images of the original data set are expanded to 12,518 images, and the expanded data set is divided into training set, verification set, and test set for subsequent model training and evaluation.

[0064] In the embodiment of the present application, constructing the aluminum foil surface defect detection model in the above step S2 includes:

[0065] like Figure 2 As shown in Figure 1, a small target detection layer is added to the detection head of the original YOLOv7 model. YOLOv7 uses multi-scale feature extraction to extract features from different levels of the network to capture feature information at different scales.

[0066] It should be noted that the backbone network in the YOLOv7 network first extracts features from the input image through a series of convolutions and pooling to generate a series of feature maps, and then upsamples the high-level feature maps to the same size as the low-level feature maps through upsampling operations, and then connects them to maintain spatial alignment. In the original YOLOv7 network, the detection head includes three detection layers, and the output feature map sizes are 80×80 pixels, 40×40 pixels, and 20×20 pixels, respectively. The detection layer with the largest output feature map (80×80 pixels) is suitable for detecting small targets due to its small receptive field, and is the small target detection layer. Similarly, the output feature map with the smallest (20×20 pixels) is the large target detection layer. The output feature map size (40×40 pixels) is the medium target detection layer. Compared with the original image (640×640 pixels), the YOLOv7 downsampling multiple is too large, and it is difficult for the deeper feature map to learn the feature information of small targets. Therefore, the present invention adds an ultra-small target detection layer with an output feature map size of 160×160 pixels, so that the network pays more attention to the detection of small targets and improves the detection effect of small targets.

[0067] Add a window self-attention module after feature extraction of large-size feature maps.

[0068] It should be noted that the size and shape of aluminum foil surface defects vary, most of which are small in size and only occupy a small area in the image. At the same time, some defects have a certain degree of similarity with the background and are difficult to be accurately identified, thus affecting the detection results. Therefore, the present invention introduces a moving window attention SwinTransformer module before the head output network of the YOLOv7 model to improve the model's ability to extract features of aluminum foil defects. This allows the model to pay more attention to important feature areas and improve detection accuracy.

[0069] The overall module structure of the SwinTransformer module is as follows Figure 3 As shown in Figure 2, SwinTransformer is based on the Transformer structure, replacing the standard multi-head self-attention module (MSA) with a window multi-head self-attention module (W-MSA) and a shifted window multi-head self-attention mechanism (SW-MSA).

[0070] Specifically, a small target detection layer is added to the detection head of the original YOLOv7 model, a moving window self-attention module is added after the large-size feature map feature extraction, and the CIoU loss function of the original YOLOv7 model is replaced by the SIoU loss function;

[0071] The dimension of the added detection head output is 3×160×160×85, where 160×160 represents the size of the feature map, each point in the feature map corresponds to an anchor point, 3 means that each anchor point has three target boxes, 85 represents the confidence corresponding to 80 categories, 1 is used to indicate the probability of being an object, and the other 4 give the coordinates of the four vertices of the predicted target box.

[0072] The preset parameters of the anchor box of the new detection head are [19, 27, 44, 40, 38, 94];

[0073] It should be noted that the moving window multi-head self-attention mechanism module (SwinTransformer) is a new Transformer module, which is an improvement on the original Transformer. It adopts a layered attention mechanism. Specifically, it divides the input feature map into multiple small blocks, and performs self-attention calculations in each small block. Then, a sliding window and a layered fusion method are used to realize information interaction between blocks. The calculation process of the SwinTransformer module is:

[0074]

[0075] z l =MLP(LN(z l ))+z l ,

[0076]

[0077] Among them, z l-1 It represents the feature map extracted from the backbone network, z l+1 It represents the output after being processed by the window self-attention module. WMSA stands for Windows Multi-head Self-Attention, and SWMSA stands for Shifted Windows Multi-head Self-Attention.

[0078] It should be noted that the reason why the SIoU loss function is used to replace the CIoU loss function of the original YOLOv7 model is that in the YOLOv7 model, the regression loss of the prediction box uses the CIoU loss, but CIoU does not take into account the inconsistency between the prediction box and the true box, which may cause the prediction box to swing back and forth during the training process. The final result is that the convergence speed slows down during the model training process and the output model effect is not good. In view of the above problems, the present invention uses the SIoU loss function to replace the CIoU loss function.

[0079] SIoU consists of four parts: shape loss Ω, angle loss Λ, distance loss Δ, and intersection-over-union loss U. Figure 4 As shown, the specific calculation process of SIoU is:

[0080]

[0081] Among them, w and h are the width and height of the prediction box respectively, w gt ,h gt are the width and height of the real box respectively. σ is the distance between the center point of the real box and the predicted box, c h is the height distance between the center point of the real box and the predicted box, c w is the distance in width between the center point of the real box and the predicted box. θ controls the degree of attention paid to shape loss. In this embodiment, this parameter is set to 3.

[0082] In the embodiment of the present application, the aluminum foil surface defect detection model is trained using the training set in the first data set in the above step S3, and the model performance is evaluated by the preset evaluation index, including:

[0083] The images in the training set are uniformly cropped to 640×640, the input image size of the aluminum foil surface defect detection model is set to 640×640, the training batch size is set to 32, and the number of repeated training (Epoch) is set to 300; the model is trained using the training set images, and the model with the best performance during the training process is selected as the final model. The test set is used to conduct a final evaluation of the model effect. The evaluation indicators include: mean average precision (mAP) and detection frames per second (FPS). Among them, mAP is used to evaluate the accuracy of model detection, and FPS is used to evaluate the detection speed of the model. The specific definition and calculation method of mAP are as follows:

[0084]

[0085] Among them, the precision rate P describes how accurate the model is, that is, how many of the results predicted as positive examples are true positive examples; the recall rate R describes how complete the model is, that is, how many of the true samples are predicted as positive examples by the model. AP represents the average detection accuracy of a single category, which is obtained by calculating the area of ​​the PR curve. mAP is the average detection accuracy of all categories, which is obtained by averaging the AP of all categories.

[0086] In the embodiment of the present application, the above step S4 uses the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be detected, including:

[0087] Preprocess the aluminum foil surface image to be tested: uniformly crop or scale it to 640×640 pixels to match the input size requirement of the model. If a specific color space (such as grayscale, RGB, HSV, etc.) is used during model training, the image to be tested needs to be converted to the same color; normalize the pixel values ​​of the image.

[0088] The preprocessed image is converted into a tensor format suitable for model input, the processed image is input into the model, forward propagation is performed, and the prediction result of the model is obtained.

[0089] Parse the target box, category, and confidence information from the tensor output by the model. The dimension of the model output is [batch_size, num_anchors, 85], where 85 represents the prediction information of each anchor point (4 coordinates, 1 confidence, 80 category probabilities).

[0090] Perform non-maximum suppression on the parsed target box, remove redundant detection boxes, and retain the box with the highest confidence. Set a confidence threshold and only retain detection boxes with confidence higher than the threshold. Mark the detection results on the original image, use a rectangular box to mark the target area, and display the category name and confidence near the box. Visualize the detection results (including target box, category, and confidence).

[0091] From the test results, the improved YOLOv7 is better than the original YOLOv7 model in detection accuracy. On the first data set, the improved model mAP reached 95.4%, which is 3.1% higher than the original YOLOv7 model. Due to the addition of some modules in the improvement process, the model size increased to 82MB, and the FPS decreased to a certain extent, but the FPS can still reach 66, which is fully able to meet the requirements of online detection of aluminum foil production process.

[0092] In summary, the present invention adds a small target detection layer to the detection head of the original YOLOv7 model. The feature map of this layer has a larger size, a smaller receptive field, and better preserves the information of the middle and shallow layers of the image. This improvement improves the model's ability to detect small-sized defects. After the large-size feature map feature extraction, the window self-attention module is added so that the model pays more attention to important feature areas, thereby improving the detection accuracy. Replacing the CIoU loss function in the original YOLOv7 model with the SIoU loss function speeds up the convergence speed of the model and improves the regression accuracy. Through the above improvements, the detection accuracy of the model is further improved while maintaining a relatively high detection speed.

[0093] Example 3

[0094] The above is a schematic scheme of the metal appearance quality detection method based on enhanced YOLOv7 in this embodiment. It should be noted that the technical scheme of the metal appearance quality detection system based on enhanced YOLOv7 and the technical scheme of the metal appearance quality detection method based on enhanced YOLOv7 belong to the same concept. The details of the technical scheme of the metal appearance quality detection system based on enhanced YOLOv7 in this embodiment that are not described in detail can be referred to the description of the technical scheme of the metal appearance quality detection method based on enhanced YOLOv7.

[0095] This embodiment also provides a system for metal appearance quality detection method based on enhanced YOLOv7, including:

[0096] A data collection and preprocessing module is used to collect aluminum foil surface defect image data, construct an aluminum foil surface defect data set and perform preprocessing to obtain a first data set;

[0097] A model building module, used for building an aluminum foil surface defect detection model based on the first data set and the enhanced YOLOv7 network;

[0098] The model training and evaluation module is used to train the aluminum foil surface defect detection model using the training set in the first data set and evaluate the model performance through preset evaluation indicators.

[0099] The defect detection and application module is used to use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

[0100] This embodiment further provides a computing device, which is applicable to the case of a metal appearance quality detection method based on enhanced YOLOv7, including:

[0101] A memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the metal appearance quality detection method based on enhanced YOLOv7 as proposed in the above embodiment.

[0102] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the metal appearance quality detection method based on enhanced YOLOv7 as proposed in the above embodiment is implemented.

[0103] The storage medium proposed in this embodiment and the metal appearance quality detection method based on enhanced YOLOv7 proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0104] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A metal appearance quality detection method based on enhanced YOLOv7, characterized by: include, Collecting aluminum foil surface defect image data, constructing an aluminum foil surface defect data set and performing preprocessing to obtain a first data set; Based on the first data set and the enhanced YOLOv7 network, an aluminum foil surface defect detection model is constructed; Using the training set in the first data set to train the aluminum foil surface defect detection model, and evaluating the model performance through the preset evaluation index; Use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

2. The metal appearance quality detection method based on enhanced YOLOv7 as claimed in claim 1, characterized in that: The construction of the aluminum foil surface defect data set and preprocessing includes: The collected aluminum foil surface defect image data were manually annotated to obtain an aluminum foil surface defect dataset, which includes 15 types of aluminum foil surface defects, namely peeling, holes, oil stains, black spots, lines, insect marks, wrinkles, knocks, bulges, foreign body intrusion, corrosion, oxidation, scratches, bubbles, and aluminum sticking; the aluminum foil surface defect dataset was enhanced and the enhanced dataset was divided into training set, validation set and test set.

3. The metal appearance quality detection method based on enhanced YOLOv7 according to claim 1 or 2, characterized in that: The construction of the aluminum foil surface defect detection model comprises: A small target detection layer is added to the detection head of the original YOLOv7 model, a moving window self-attention module is added after the large-size feature map feature extraction, and the SIoU loss function is used to replace the CIoU loss function of the original YOLOv7 model.

4. The metal appearance quality detection method based on enhanced YOLOv7 as claimed in claim 3, characterized in that: The dimension of the detection head output of the small target detection layer is 3×160×160×85, where 160×160 represents the size of the feature map, each point in the feature map corresponds to an anchor point, 3 represents that each anchor point has three target boxes, 85 represents the confidence corresponding to 80 categories, 1 is used to represent the probability of being an object, and the other 4 give the coordinates of the four vertices of the predicted target box; the preset parameters of the anchor box of the detection head of the small target detection layer are [19, 27, 44, 40, 38, 94].

5. The metal appearance quality detection method based on enhanced YOLOv7 according to claim 1 or 4, characterized in that: The aluminum foil surface defect detection model is trained using the training set in the first data set, and the model performance is evaluated by a preset evaluation index, including: The images in the training set are uniformly cropped to a preset size, the input image size, training batch size, and number of repeated training of the aluminum foil surface defect detection model are set, the model is trained using the training set images, the model with the best performance during the training process is selected as the trained aluminum foil surface defect detection model, and the model effect is evaluated using the test set.

6. The metal appearance quality detection method based on enhanced YOLOv7 as claimed in claim 5, characterized in that: The method of using the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be detected includes: The aluminum foil surface image to be inspected is resized to match the input size requirement of the aluminum foil surface defect detection model; Normalize the pixel values ​​of the image and convert them into a tensor format suitable for model input. Input the processed image into the model for forward propagation to obtain the model's prediction results.

7. The metal appearance quality detection method based on enhanced YOLOv7 according to claim 6, characterized in that: The prediction results of the acquisition model include: Parse the target box, category and confidence information from the tensor output by the model; Perform non-maximum suppression on the parsed target box, remove redundant detection boxes, and retain the box with the highest confidence; Set the confidence threshold and only keep the detection boxes whose confidence is higher than the confidence threshold; Mark the detection results on the original image and output the detection results visually.

8. A system for metal appearance quality detection method based on enhanced YOLOv7, characterized in that: include: A data collection and preprocessing module is used to collect aluminum foil surface defect image data, construct an aluminum foil surface defect data set and perform preprocessing to obtain a first data set; A model building module, used for building an aluminum foil surface defect detection model based on the first data set and the enhanced YOLOv7 network; A model training and evaluation module, used to train the aluminum foil surface defect detection model using the training set in the first data set, and evaluate the model performance through preset evaluation indicators; The defect detection and application module is used to use the trained aluminum foil surface defect detection model to detect the aluminum foil surface image to be inspected.

9. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the metal appearance quality detection method based on enhanced YOLOv7 are implemented.

10. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of a metal appearance quality detection method based on enhanced YOLOv7.

Citation Information

Patent Citations

  • Product surface defect detection method in industrial scene

    CN114359245A

  • PCB defect detection method based on improved YOLOv7

    CN116863242A

  • PCB surface defect detection method and system based on improved yolov7 network

    CN116912659A

  • Target detection method for surface defects of aluminum material

    CN117710309A

  • Hot-rolled strip steel surface defect detection method based on double-detection-head D-YOLO, storage medium and equipment

    CN118429302A