Zinc ingot surface defect detection method, device, equipment and medium

Through the improved YOLO V5 model, the problem of low manual detection efficiency is solved, and the automatic identification and removal of zinc ingot surface defects is realized, and the production efficiency and automation level are improved.

CN120259764APending Publication Date: 2025-07-04BEIJING MINING & METALLURGICAL TECH GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510370208.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, the surface quality detection of zinc ingots relies on manual judgment, has low efficiency, high false detection and missed detection rates, and lacks automated detection methods.

Method used

Using the improved YOLO V5 zinc ingot surface defect detection network model, the zinc ingot surface quality detection data set is constructed through image preprocessing, labeling and training to realize automatic identification of zinc ingot surface defects.

Benefits of technology

It improves the real-time processing efficiency and robustness of surface defect detection of zinc ingots, and can accurately identify defects in complex industrial environments, automatically remove waste ingots, and improve production efficiency and automation level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259764A_ABST
    Figure CN120259764A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial detection, and discloses a zinc ingot surface defect detection method, device and equipment and a medium. The method comprises the following steps: acquiring an original zinc ingot image, preprocessing the original zinc ingot image to obtain a preprocessed zinc ingot image, labeling the preprocessed zinc ingot image, and constructing a zinc ingot surface quality detection data set; constructing an improved YOLO V5 zinc ingot surface defect detection network model, and training the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model; and inputting a to-be-detected zinc ingot image into the zinc ingot surface defect target detection network model to obtain a defect category and a defect position in the to-be-detected zinc ingot image. The improved YOLO V5 model has high real-time processing energy efficiency and anti-interference robustness to the industrial complex environment, real-time detection of the surface quality of the zinc ingot is effectively achieved, and the production efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial inspection, and particularly relates to a method, device, equipment and medium for detecting surface defects of zinc ingots. Background Art

[0002] The indicators for evaluating the quality of zinc ingots include surface quality, chemical composition, hardness, etc. Among many quality indicators, surface quality is an important factor affecting the overall quality of zinc ingots. The main types of surface quality defects of zinc ingots are as follows: shrinkage cavity, melting hole, dross, surface protrusion and burr, black spot, etc.

[0003] In industrial production, the surface quality of zinc ingots is mainly judged manually, which is not conducive to reducing the number of on-site production personnel and reducing the labor intensity of operators. There are problems such as low efficiency, high false detection rate and missed detection rate. For the detection of surface defects of zinc ingots and the identification of scrap ingots, there is still no mature product to replace manual labor in the current casting production line. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to overcome the deficiencies in the prior art and provide a method, device, equipment and medium for detecting surface defects of zinc ingots.

[0005] The present invention provides the following technical solutions: In a first aspect, the present invention provides a method for detecting surface defects of zinc ingots, the method comprising: Collecting an original zinc ingot image, preprocessing the original zinc ingot image to obtain a preprocessed zinc ingot image, and annotating the preprocessed zinc ingot image to construct a zinc ingot surface quality detection data set; Constructing an improved YOLO V5 zinc ingot surface defect detection network model, and training the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model; Inputting the zinc ingot image to be detected into the zinc ingot surface defect target detection network model to obtain the defect category and defect position in the zinc ingot image to be detected.

[0006] In an optional embodiment, the preprocessing the original zinc ingot image to obtain a preprocessed zinc ingot image includes: Performing mirror processing and rotation processing on the original zinc ingot image to obtain a first zinc ingot image; Randomly cropping and scaling and splicing every preset number of images in the first zinc ingot image to obtain a second zinc ingot image; Adjusting the values of the hue channel, saturation channel and lightness channel of the second zinc ingot image to obtain the preprocessed zinc ingot image.

[0007] In an alternative embodiment, the preprocessed zinc ingot images are labeled to construct a zinc ingot surface quality detection data set, including: Determine the local feature regions in the preprocessed zinc ingot images that meet the preset visual saliency requirements, and perform minimum bounding rectangle annotation on the local feature regions; When heterogeneous surface defect features presented by the same waste ingot entity in the preprocessed zinc ingot images, establish all feature classification annotations; Perform partition label annotation on the partition strips between adjacent zinc ingots in the preprocessed zinc ingot images to obtain the zinc ingot surface quality detection data set.

[0008] In an alternative embodiment, the improved YOLO V5 zinc ingot surface defect detection network model includes a Backbone main network, a Neck neck structure, and a Head detection head; The Backbone main network includes a plurality of CBS modules, a plurality of cross-stage local modules, and a pyramid pooling module. Among them, the CBS module includes a convolutional module, a batch normalization module, and an activation function; The Neck neck structure includes a plurality of CBS modules, a plurality of C3C modules, a plurality of tensor splicing operation modules, a plurality of upsampling operation modules, and a cross-stage local module. Among them, the C3C module includes one of the cross-stage local modules and a convolutional attention module, and the convolutional attention module includes a channel attention sub-module and a spatial attention sub-module connected in sequence; The Head detection head includes a first prediction module, a second prediction module, a third prediction module, and a fourth prediction module.

[0009] In an alternative embodiment, a plurality of cross-stage local modules in the Backbone main network are connected to a plurality of tensor splicing operation modules in the Neck neck structure, the pyramid pooling module in the Backbone main network is connected to one CBS module in the Neck neck structure, a plurality of C3C modules in the Neck neck structure are respectively connected to the first prediction module, the second prediction module, and the third prediction module in the Head detection head, and the cross-stage local module in the Neck neck structure is connected to the fourth prediction module in the Head detection head.

[0010] In an alternative embodiment, training the improved YOLOV5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model, including: Using a preset loss function and based on the zinc ingot surface quality detection data set, train the improved YOLO V5 zinc ingot surface defect detection network model to obtain the optimal target parameters and target weights for waste ingot detection; Load the optimal target parameters and the target weights into the improved YOLO V5 zinc ingot surface defect detection network model to obtain the zinc ingot surface defect target detection network model.

[0011] In an alternative embodiment, the step of inputting the zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect position in the zinc ingot image to be measured includes: Detect the defect category and defect position in the zinc ingot image to be measured through the zinc ingot surface defect target detection network model to generate a plurality of initial prediction frames; Eliminate redundant prediction frames in each of the initial prediction frames through non-maximum suppression to obtain a plurality of prediction frames after elimination; Calculate the confidence of each of the prediction frames after elimination, retain the target prediction frame with the highest confidence, and determine the defect category and defect position in the zinc ingot image to be measured through the target prediction frame.

[0012] In a second aspect, the present invention provides a zinc ingot surface defect detection device, and the device includes: A processing module, configured to collect an original zinc ingot image, preprocess the original zinc ingot image to obtain a preprocessed zinc ingot image, and label the preprocessed zinc ingot image to construct a zinc ingot surface quality detection data set; A training module, configured to construct an improved YOLO V5 zinc ingot surface defect detection network model, and train the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model; A detection module, configured to input a zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect position in the zinc ingot image to be measured.

[0013] In a third aspect, an embodiment of the present disclosure provides a computer device, which includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the zinc ingot surface defect detection method described in the first aspect are implemented.

[0014] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the zinc ingot surface defect detection method described in the first aspect are implemented.

[0015] Advantages of the present application: The zinc ingot surface defect detection method provided by the embodiment of the present application collects the original zinc ingot image, preprocesses the original zinc ingot image to obtain the preprocessed zinc ingot image, and labels the preprocessed zinc ingot image to construct a zinc ingot surface quality detection data set; constructs an improved YOLO V5 zinc ingot surface defect detection network model, and trains the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model; inputs the zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect position in the zinc ingot image to be measured. By using the improved YOLO V5 model, the present application has high real-time processing energy efficiency and anti-interference robustness to industrial complex environments, can better achieve the purpose of real-time detection of the zinc ingot surface quality, and can automatically remove waste ingots in cooperation with the industrial control system, improving the factory automation level, reducing the labor intensity, and improving the production efficiency.

[0016] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes the following detailed description. Brief Description of the Drawings

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts. In each drawing, similar components are numbered similarly.

[0018] Figure 1 Shows a flowchart of a zinc ingot surface defect detection method provided by an embodiment of the present application; Figure 2 Shows a schematic structural diagram of an improved YOLO V5 zinc ingot surface defect detection network model provided by an embodiment of the present application; Figure 3 Shows a schematic diagram of the principle of a convolutional attention module provided by an embodiment of the present application; Figure 4 Shows a schematic structural diagram of a zinc ingot surface defect detection device provided by an embodiment of the present application; Figure 5 Shows a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed Description of the Embodiments

[0019] Embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present invention and should not be construed as a limitation of the present invention.

[0020] It should be noted that the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, "a plurality of" means two or more unless otherwise specifically defined.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the description of the template herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0022] Embodiment 1 As Figure 1 shown, it is a flowchart of a method for detecting surface defects of zinc ingots in an embodiment of the present application. The method for detecting surface defects of zinc ingots provided by the embodiment of the present application includes the following steps: Step S110, collect the original zinc ingot image, preprocess the original zinc ingot image to obtain the preprocessed zinc ingot image, and label the preprocessed zinc ingot image to construct a dataset for detecting the surface quality of zinc ingots.

[0023] First, collect the original zinc ingot image. The original zinc ingot image needs to contain interference from various environmental factors to increase the diversity of dataset samples. In this embodiment, a total of 1462 images are collected from the site, with a size of 1920×1080. The specific quantity and size are not limited in this embodiment.

[0024] Then, preprocess the collected original zinc ingot images. In this embodiment, three data augmentation methods are adopted to expand the data sample size of the waste ingot images: (1) Mirror (horizontal or vertical flip) and rotate the original zinc ingot images to increase the spatial diversity of objects in the images, alleviate the overfitting of the model to the object orientation, scale, and position, and obtain the first zinc ingot images; (2) Randomly crop and scale and splice every preset number of images (e.g., 4 images) in the first zinc ingot images, enabling the model to learn objects with multiple scales and multiple scenarios in one image, and obtain the second zinc ingot images; (3) Adjust the values of the hue channel, saturation channel, and brightness channel of the second zinc ingot images to simulate images under different lighting, weather, and color conditions, which helps the model adapt to various lighting conditions and improve the generalization ability of the model. Finally, obtain the preprocessed zinc ingot images.

[0025] Next, label the preprocessed zinc ingot images. Usually, mark the positions of the waste ingots by drawing rectangular boxes to construct a zinc ingot surface quality detection dataset: (1) During the labeling process, adopt the principle of feature saliency priority, determine the local feature regions in the preprocessed zinc ingot images that meet the preset visual saliency requirements, and only perform the minimum bounding rectangle selection and labeling on the local feature regions that meet the preset visual saliency requirements. This method can reduce the labeling workload and ensure that the model can learn the most important features at the same time; (2) When there are heterogeneous surface defect features (such as burrs, dross, ingot partition grooves, secondary damage, good ingots, and waste ingots, etc.) presented by the same waste ingot entity in the preprocessed zinc ingot images, establish all feature classification labels, which helps the model more accurately identify and understand different defect types of waste ingots; (3) Perform "partition" label annotation on the partition strips between adjacent zinc ingots in the preprocessed zinc ingot images, which helps the model understand the spatial relationship between zinc ingots while identifying waste ingots. Furthermore, by calculating the Euclidean distance between the partition strip and the lower edge position of the image, it can be determined which zinc ingots need to be processed immediately. This method can automatically identify the zinc ingots that need to be processed first and improve production efficiency. Finally, obtain the zinc ingot surface quality detection dataset.

[0026] Preferably, the zinc ingot surface quality detection dataset can be further allocated into a training set, a validation set, and a test set according to a preset ratio (e.g., 8:1:1), which helps the subsequent training and validation of the model.

[0027] The above step S110 adopts data augmentation methods, effectively expands the dataset sample size, improves the generalization ability of the model, and finely labels the preprocessed zinc ingot images, providing high-quality training data for model training.

[0028] Step S120: Construct an improved YOLO V5 zinc ingot surface defect detection network model, and train the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model.

[0029] In an alternative embodiment, design a fine-grained anchor box parameter group, and use the K-means algorithm for Anchor dimension clustering to determine the Anchor parameters. The specific steps are as follows: (1) Normalize the labeled bounding boxes in the training set, which means scaling the width and height of the labeled boxes relative to the width and height of the input image, and extract the set of width-height feature vectors , where , and are the width and height of the input image respectively; (2) Use the K-means algorithm to initialize the clustering centers, and optimize the initial center selection through the probability density distribution to avoid local optimal solutions; (3) Construct an improved K-means clustering algorithm based on the intersection over union (IoU), and its distance metric function is defined as , where is the labeled box, is the current clustering center; (4) Perform the iterative clustering process: assign each labeled box to the clustering cluster with the largest IoU, and update the clustering center based on the median of the width and height of the samples within the cluster until convergence; (5) Finally, the parameters generated by the clustering centers are the Anchor parameters. These parameters represent the typical distribution of the width and height of the labeled boxes in the data set and are used in subsequent detection tasks. The model will predict the bounding boxes of the targets based on these Anchor parameters, and adjust the position and size of the Anchor parameters to obtain the final prediction boxes.

[0030] First of all, it should be noted that in the field of industrial object detection, YOLO V5 (You Only Look Once version 5) is a single-stage object detection algorithm based on deep learning. With its high efficiency, real-time performance, lightweight architecture and multi-scale detection ability, it has shown significant advantages in the field of industrial object detection. In the field of zinc ingot surface defect detection, the challenges faced by the application of YOLO V5 are as follows: First, the lighting conditions, background noise and physical environment interference (such as vibration, dust, etc.) in industrial scenarios will significantly affect the quality of image acquisition, resulting in blurred or lost target features, thus reducing the robustness of the detection algorithm. Second, industrial defects usually have the characteristics of diversity and small targets. Traditional algorithms are difficult to accurately capture the features of tiny defects in complex backgrounds. Especially in high-resolution images, small targets only account for a very small number of pixels, making it difficult to extract and locate features. Third, the defect samples in industrial datasets are usually scarce and unevenly distributed, resulting in difficulty in fully learning defect features during the model training process, further limiting the detection accuracy.

[0031] In this embodiment, the improved YOLO V5 zinc ingot surface defect detection network model is as Figure 2 shown, and specifically includes three parts: the Backbone main network, the Neck neck structure, and the Head detection head. The Backbone main network is the feature extractor of the model, responsible for layer-by-layer extracting multi-scale and multi-semantic abstract features from the input image, including multiple CBS modules, multiple cross-stage local modules (C3), and a spatial pyramid pooling module (SPPF). Among them, the CBS module includes a convolutional module (Conv), a batch normalization module (BN), and an activation function (SiLU); the Neck neck structure is located between the Backbone main network and the Head detection head, responsible for aggregating and optimizing multi-scale features, including multiple CBS modules, multiple C3C modules, multiple tensor splicing operation modules, multiple upsampling operation modules, and a cross-stage local module. Among them, the C3C module includes one of the cross-stage local modules and a convolutional attention module. The convolutional attention module includes a channel attention sub-module and a spatial attention sub-module connected in sequence; the Head is the core module of object detection, including the first prediction module, the second prediction module, the third prediction module, and the fourth prediction module, responsible for converting the multi-scale feature map output by the Neck into the final detection result, including bounding box coordinates, class probabilities, and confidence levels.

[0032] Multiple cross-stage local modules in the Backbone backbone network are connected to multiple tensor concatenation operation modules in the Neck neck structure. The pyramid pooling module in the Backbone backbone network is connected to a CBS module in the Neck neck structure. Multiple C3C modules in the Neck neck structure are respectively connected to the first prediction module, the second prediction module, and the third prediction module in the Head detection head. The cross-stage local module in the Neck neck structure is connected to the fourth prediction module in the Head detection head.

[0033] Specifically, as Figure 2 shown, in the Backbone backbone network part, the size of the original image is converted to 640×640 with 3 channels and input into the Backbone backbone network part. The Backbone backbone network extracts features layer by layer through multiple CBS modules, and the number of channels and size of the feature maps change gradually, such as gradually transitioning from a 640×640 feature map with 3 channels to a 20×20 feature map with 1024 channels. During the feature extraction process, a pyramid pooling module is used to enhance the model's perception ability of features at different scales, expand the receptive field, which helps to capture a larger range of context information and is of great significance for detecting defect targets of different sizes.

[0034] Specifically, as Figure 2 shown, in the Neck neck structure part, feature maps at different levels from the Backbone backbone network are fused through an upsampling operation module and a tensor concatenation operation module. For example, the high-semantic feature map in the deep layer is upsampled and concatenated with the high-resolution feature map in the shallow layer to achieve the complementarity of features at different scales. Each concatenated feature map is further fused and optimized through a cross-stage local module, and the cross-stage local module can effectively extract features at different scales and maintain the richness of the feature maps.

[0035] Preferably, at the output end of each cross-stage local module (C3), a convolutional block attention module (CBAM) is cascaded to form a C3C module. The convolutional block attention module includes a channel attention sub-module and a spatial attention sub-module, and performs double attention weighting processing on the feature map output by the cross-stage local module through an adaptive feature refinement mechanism, as Figure 3 shown: ① Channel attention sub-module: Global average pooling (GAP) and global max pooling (GMP) are respectively performed on the input feature map F to generate channel description vectors. Through a multi-layer perceptron (MLP) with shared weights, a channel attention weight matrix (M C ) is generated to emphasize important channel features, suppress unimportant channel features, and enhance the model's focusing ability on target features. Mathematically, it is expressed as:

[0036] In the formula, represents the Sigmoid activation function.

[0037] ② Spatial attention sub-module: The channel-weighted feature map is aggregated along the channel dimension by taking the mean and maximum values. After concatenating the aggregation results, they are processed by a 7×7 convolution, and then activated by the Sigmoid function to generate a spatial attention weight M S ∈R 1×H×W , which is used to emphasize important spatial positions in the feature map and further improve the model's ability to capture target features under complex backgrounds and noise interference. Mathematically, it is expressed as:

[0038] In the formula, represents a convolutional layer with a convolution kernel size of 7×7, represents the stacking operation on the channel dimension.

[0039] ③ The convolutional attention module multiplies the channel attention weight and the spatial attention weight element-wise with the original feature map to obtain a feature map F' processed by double attention weighting, thereby improving the overall detection accuracy and robustness of the model. Mathematically, it is expressed as:

[0040] In the formula, represents the element-wise multiplication operation.

[0041] (3) Specifically, as Figure 2As shown in the figure, in the Head detection head part, the original YOLO V5 has three prediction heads (P3, P4, P5). Based on this, a dedicated prediction head for tiny object detection (P2) is newly added in this application, and a four-level heterogeneous feature output layer including P2, P3, P4, and P5 is constructed, namely the first prediction module (Detect 1), the second prediction module (Detect 2), the third prediction module (Detect 3), and the fourth prediction module (Detect 4) in the figure. The P2 prediction head is located at the shallow feature extraction node of the feature pyramid network, which can extract the high-resolution feature map of the shallow layer of the backbone network, retain the spatial fine-grained features of the target object, and its output feature map has a higher spatial sampling density, which can effectively enhance the texture capture ability of pixel-level tiny targets and is of great significance for detecting tiny defects on the surface of zinc ingots. The four-level prediction heads form a collaborative detection system through the cross-scale connection mechanism of the feature pyramid. Among them, the P2 layer focuses on small-scale features and is suitable for detecting tiny defects; the P3-P5 layers progressively aggregate medium and macroscopic semantic information and can detect defect targets of different sizes.

[0042] Preferably, before the output of each P2 prediction head, it will go through the CBS module for feature transformation to convert the multi-scale feature map output by the Neck into a feature representation suitable for detection, providing more accurate bounding box coordinates, class probabilities, confidence levels, etc. for the final detection result. Finally, after aligning the resolutions of the feature maps output by the four prediction heads through transposed convolution and then performing tensor splicing along the channel dimension, the effective expansion of the dynamic range of the target size of the detection model is realized, and the recognition recall rate and localization accuracy of tiny targets in complex scenarios are significantly improved.

[0043] After constructing the improved YOLO V5 zinc ingot surface defect detection network model, the constructed zinc ingot surface quality detection dataset (including the training set, validation set, and test set) is used to train the improved YOLO V5 zinc ingot surface defect detection network model. During the training process, the model continuously adjusts its internal parameters (i.e., weights and biases) through the backpropagation algorithm to minimize the preset loss function , which comprehensively considers the intersection over union loss , the center point distance loss and the aspect ratio loss . By optimizing these loss terms, the model can more accurately predict the position and category of zinc ingot surface defects. The preset loss function is as follows:

[0044] In the formula, is the intersection over union of the predicted box and the ground truth box, is the center point b of the predicted box and the center point of the ground truth box The square of the Euclidean distance between is the width of the predicted bounding box and the width of the ground truth bounding box The Euclidean distance between is the height of the predicted bounding box and the height of the ground truth bounding box The Euclidean distance between is the length of the diagonal of the smallest closed rectangle containing the predicted bounding box and the ground truth bounding box, and are the width and height of the smallest closed rectangle containing the predicted bounding box and the ground truth bounding box.

[0045] During the training process, the performance of the model is regularly evaluated using the validation set (evaluation metrics include recall, precision, mean average precision, etc.), and hyperparameters such as the learning rate and batch size are adjusted according to the evaluation results to further optimize the model performance. After sufficient training and validation, the parameters and weights corresponding to the best performance of the model on the validation set are determined as the optimal target parameters and target weights, and these optimal parameters and weights represent the best configuration of the model for the current dataset and task.

[0046] Exemplarily, the optimal target parameters can be: Epochs: 200, Batch_size: 8, lr0: 0.001, lrf: 0.01, momentum: 0.937. The specific parameter types and values can be determined according to the actual situation, and the embodiments of the present application do not limit this.

[0047] Finally, the determined optimal target parameters and target weights are loaded into the improved YOLO V5 zinc ingot surface defect detection network model to obtain the zinc ingot surface defect target detection network model. This model has been optimized for the zinc ingot surface quality detection task and is ready for online detection.

[0048] In the above step S120, by improving the YOLO V5 network model, the detection accuracy and robustness of zinc ingot surface defects are improved. Multi-scale feature fusion is achieved by using a feature pyramid and a cross-stage local module to enhance the model's detection ability for targets of different sizes. By introducing the CBAM attention module, the model's ability to focus on target features under complex backgrounds and noise interference is enhanced.

[0049] In step S130, the zinc ingot image to be tested is input into the zinc ingot surface defect target detection network model to obtain the defect categories and defect positions in the zinc ingot image to be tested.

[0050] Understandably, during the online detection stage of zinc ingots, when the image of the zinc ingot to be measured obtained on-site is input into the trained target detection network model for surface defects of zinc ingots, the model can automatically detect and identify various defects on the zinc ingot, including their positions and categories. This is achieved by generating multiple initial prediction boxes, which not only mark the positions of the defects in the image but also carry information about the defect categories.

[0051] Through post-processing steps such as Non-Maximum Suppression (NMS), redundant prediction boxes in each initial prediction box are removed to obtain multiple post-processed prediction boxes, which can further refine the prediction results and ensure that each defect is detected only once. After calculating the confidence levels of the post-processed prediction boxes, the target prediction box with the highest confidence level is retained, thereby determining the defect categories and defect positions in the image of the zinc ingot to be measured.

[0052] The above step S130 uses the trained target detection network model for surface defects of zinc ingots to achieve real-time detection of zinc ingot images. According to the detection results, the industrial control system can automatically perform operations such as removing defective ingots, improving production efficiency.

[0053] The method for detecting surface defects of zinc ingots provided by the embodiments of the present application includes collecting an original zinc ingot image, preprocessing the original zinc ingot image to obtain a preprocessed zinc ingot image, and annotating the preprocessed zinc ingot image to construct a surface quality detection dataset for zinc ingots; constructing an improved YOLO V5 target detection network model for surface defects of zinc ingots, and training the improved YOLO V5 target detection network model for surface defects of zinc ingots according to the surface quality detection dataset for zinc ingots to obtain a target detection network model for surface defects of zinc ingots; inputting the image of the zinc ingot to be measured into the target detection network model for surface defects of zinc ingots to obtain the defect categories and defect positions in the image of the zinc ingot to be measured. The present application uses an improved YOLO V5 model, which has high real-time processing energy efficiency and anti-interference robustness in industrial complex environments, can better achieve the purpose of real-time detection of the surface quality of zinc ingots, and can automatically remove defective ingots in cooperation with the industrial control system, improving the automation level of the factory, reducing labor intensity, and improving production efficiency.

[0054] Embodiment 2 As Figure 4 shown, it is a schematic structural diagram of a device 400 for detecting surface defects of zinc ingots in the embodiments of the present application. The device includes: A processing module 410, configured to collect an original zinc ingot image, preprocess the original zinc ingot image to obtain a preprocessed zinc ingot image, and annotate the preprocessed zinc ingot image to construct a surface quality detection dataset for zinc ingots; A training module 420, configured to construct an improved YOLO V5 zinc ingot surface defect detection network model, and train the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set, so as to obtain a zinc ingot surface defect target detection network model; A detection module 430, configured to input an image of a zinc ingot to be detected into the zinc ingot surface defect target detection network model, so as to obtain the defect category and defect position in the image of the zinc ingot to be detected.

[0055] The zinc ingot surface defect detection device provided by the embodiment of the present application can implement each process of the zinc ingot surface defect detection method corresponding to Embodiment 1, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0056] The zinc ingot surface defect detection device provided by the embodiment of the present application has high real-time processing energy efficiency and anti-interference robustness to industrial complex environments by using an improved YOLO V5 model, can better achieve the purpose of real-time detection of the surface quality of zinc ingots, and can automatically remove defective ingots in cooperation with an industrial control system, improving the automation level of the factory, reducing the labor intensity, and improving the production efficiency.

[0057] Embodiment 3 The embodiment of the present application further provides a computer device. Specifically, please refer to Figure 5 , Figure 5 which is the basic structure block diagram of the computer device in this embodiment.

[0058] The computer device 5 includes a memory 51, a processor 52, and a network interface 53 that are communicatively connected to each other through a system bus. It should be noted that only the computer device 5 having a memory 51, a processor 52, and a network interface 53 is shown in the figure, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented. Among them, those skilled in the art of the present technology can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0059] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touchpad, a voice control device, etc.

[0060] The memory 51 includes at least one type of readable storage medium, which includes flash memory, hard disk, multimedia card, card-type memory (such as SD or D-slot compatibility test memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 51 may be an internal storage unit of the computer device 5, such as the hard disk or memory of the computer device 5. In other embodiments, the memory 51 may also be an external storage device of the computer device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the computer device 5. Of course, the memory 51 may also include both the internal storage unit and the external storage device of the computer device 5. In this embodiment, the memory 51 is generally used to store the operating system and various application software installed on the computer device 5, such as computer-readable instructions for the slot compatibility test method. In addition, the memory 51 may also be used to temporarily store various data that have been output or will be output.

[0061] In some embodiments, the processor 52 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other zinc ingot surface defect detection chips. The processor 52 is generally used to control the overall operation of the computer device 5. In this embodiment, the processor 52 is used to run the computer-readable instructions stored in the memory 51 or process data, such as running the computer-readable instructions for the slot compatibility test method.

[0062] The network interface 53 may include a wireless network interface or a wired network interface, and this network interface 53 is generally used to establish a communication connection between the computer device 5 and other electronic devices.

[0063] The computer device provided in this embodiment can execute the above-mentioned zinc ingot surface defect detection method. Here, the zinc ingot surface defect detection method may be the zinc ingot surface defect detection methods in the above various embodiments.

[0064] Embodiment 4 This embodiment also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the zinc ingot surface defect detection method in the embodiment are implemented.

[0065] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disc, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of the computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a Smart Media Card (SMC for short), a Secure Digital (SD for short) card, a Flash Card, etc. Of course, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer-readable storage medium is generally used to store the operating system and various application software installed on the computer device. In addition, the computer-readable storage medium can also be used to temporarily store various data that have been output or will be output.

[0066] In several embodiments provided by the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architectures, functions, and operations of the device, method, and computer program product according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the block may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structure diagram and / or flowchart, as well as the combination of blocks in the structure diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0067] In addition, each functional module or unit in each embodiment of the present invention may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0068] When the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium may be a non-volatile storage medium or a volatile storage medium. For example, the storage medium may be: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc., which are all media that can store program codes.

[0069] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention.

Claims

1. A method for detecting surface defects of zinc ingots, characterized in that, The method includes: Collecting the original zinc ingot image, preprocessing the original zinc ingot image to obtain the preprocessed zinc ingot image, and annotating the preprocessed zinc ingot image to construct a zinc ingot surface quality detection dataset; Constructing an improved YOLO V5 zinc ingot surface defect detection network model, and training the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection dataset to obtain a zinc ingot surface defect target detection network model; Inputting the zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect position in the zinc ingot image to be measured.

2. The zinc ingot surface defect detection method according to claim 1, wherein, The preprocessing of the original zinc ingot image to obtain the preprocessed zinc ingot image includes: Performing mirror processing and rotation processing on the original zinc ingot image to obtain a first zinc ingot image; Randomly cropping and scaling and splicing every preset number of images in the first zinc ingot image to obtain a second zinc ingot image; Adjusting the values of the hue channel, saturation channel and lightness channel of the second zinc ingot image to obtain the preprocessed zinc ingot image.

3. The zinc ingot surface defect detection method according to claim 1, characterized in that The annotating of the preprocessed zinc ingot image to construct a zinc ingot surface quality detection dataset includes: Determining the local feature regions in the preprocessed zinc ingot image that meet the preset visual saliency requirements, and performing minimum bounding rectangle selection and annotation on the local feature regions; When there are heterogeneous surface defect features presented by the same waste ingot entity in the preprocessed zinc ingot image, establishing all feature classification annotations; Performing partition label annotation on the partition strips between adjacent zinc ingots in the preprocessed zinc ingot image to obtain the zinc ingot surface quality detection dataset.

4. The zinc ingot surface defect detection method according to claim 1, characterized in that, The improved YOLO V5 zinc ingot surface defect detection network model includes a Backbone main network, a Neck neck structure and a Head detection head; The Backbone main network includes multiple CBS modules, multiple cross-stage local modules and a pyramid pooling module, wherein the CBS module includes a convolutional module, a batch normalization module and an activation function; The Neck neck structure includes multiple CBS modules, multiple C3C modules, multiple tensor splicing operation modules, multiple upsampling operation modules and a cross-stage local module, wherein the C3C module includes one cross-stage local module and a convolutional attention module, and the convolutional attention module includes a channel attention sub-module and a spatial attention sub-module connected in sequence; The Head detection head includes a first prediction module, a second prediction module, a third prediction module and a fourth prediction module.

5. The zinc ingot surface defect detection method according to claim 4, characterized in that A plurality of cross-stage local modules in the Backbone backbone network are connected to a plurality of tensor splicing operation modules in the Neck neck structure. The pyramid pooling module in the Backbone backbone network is connected to a CBS module in the Neck neck structure. A plurality of C3C modules in the Neck neck structure are respectively connected to a first prediction module, a second prediction module, and a third prediction module in the Head detection head. The cross-stage local module in the Neck neck structure is connected to a fourth prediction module in the Head detection head.

6. The zinc ingot surface defect detection method according to claim 1, characterized in that, Training the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model, including: Using a preset loss function and according to the zinc ingot surface quality detection data set, training the improved YOLO V5 zinc ingot surface defect detection network model to obtain the optimal target parameters and target weights for waste ingot detection; Loading the optimal target parameters and the target weights into the improved YOLO V5 zinc ingot surface defect detection network model to obtain the zinc ingot surface defect target detection network model.

7. The zinc ingot surface defect detection method according to claim 1, characterized in that, Inputting the zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect location in the zinc ingot image to be measured, including: Detecting the defect category and defect location in the zinc ingot image to be measured through the zinc ingot surface defect target detection network model to generate a plurality of initial prediction frames; Removing redundant prediction frames in each of the initial prediction frames through non-maximum suppression to obtain a plurality of prediction frames after removal; Calculating the confidence levels of each of the prediction frames after removal, retaining the target prediction frame with the highest confidence level, and determining the defect category and defect location in the zinc ingot image to be measured through the target prediction frame.

8. A zinc ingot surface defect detection device, characterized in that, The device includes: A processing module for collecting an original zinc ingot image, preprocessing the original zinc ingot image to obtain a preprocessed zinc ingot image, and labeling the preprocessed zinc ingot image to construct a zinc ingot surface quality detection data set; A training module for constructing an improved YOLO V5 zinc ingot surface defect detection network model and training the improved YOLO V5 zinc ingot surface defect detection network model according to the zinc ingot surface quality detection data set to obtain a zinc ingot surface defect target detection network model; A detection module for inputting the zinc ingot image to be measured into the zinc ingot surface defect target detection network model to obtain the defect category and defect location in the zinc ingot image to be measured.

9. A computer device, characterized in that, Including a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the zinc ingot surface defect detection method according to any one of claims 1-7 are implemented.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the zinc ingot surface defect detection method according to any one of claims 1-7 are implemented.