A method, system, device and medium for detecting defects on metal surfaces

By introducing the C2f_SCConv module and the NAM attention mechanism into the YOLOv8 network, the problems of insufficient feature extraction capability and high computational cost of the YOLOv8 model in industrial defect detection are solved, and high-precision and efficient defect detection is achieved.

CN122134663APending Publication Date: 2026-06-02XINJIANG TIANYE GRP +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XINJIANG TIANYE GRP
Filing Date
2026-02-12
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

The existing YOLOv8 model has insufficient feature extraction capabilities in industrial defect detection, and the attention mechanism has high computational overhead, making it difficult to balance detection accuracy and real-time performance.

Method used

In the YOLOv8 network, the C2f module of the backbone network is replaced with the C2f_SCConv module, and a parameterless NAM attention mechanism is introduced after the spatial pyramid pooling module. The SCConv module suppresses feature redundancy, and the NAM module enhances the focus on salient regions.

Benefits of technology

It significantly improves the detection accuracy of complex textures, small targets and low-contrast defects, reduces the false negative and false positive rates, while maintaining the model's lightweight nature and inference efficiency, and adapts to the real-time requirements of industrial scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134663A_ABST
    Figure CN122134663A_ABST
Patent Text Reader

Abstract

This invention provides a method, system, device, and medium for detecting metal surface defects, belonging to the field of defect detection technology. The method includes: preprocessing the image to be detected to obtain tensor data; inputting the tensor data into an improved YOLOv8 network model, which replaces the original C2f module in the backbone network with a C2f_SCConv module to enhance the feature extraction capability for complex textures and small defects; performing multi-scale fusion of the extracted feature maps using a spatial pyramid pooling module, followed by salient region enhancement through an introduced NAM parameterless attention mechanism module; and finally inputting the enhanced feature maps into a detection head to complete defect classification and localization. This invention, employing the above-mentioned method, system, device, and medium for detecting metal surface defects, improves the detection accuracy and robustness of small targets and complex defects without significantly increasing model computational overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and in particular to a method, system, device and medium for detecting defects on metal surfaces. Background Technology

[0002] In the fields of intelligent manufacturing and automated inspection, ensuring product quality highly depends on efficient and accurate surface defect detection technology. With breakthroughs in deep learning technology, object detection methods based on convolutional neural networks (CNNs) have gradually replaced traditional manual visual inspection and machine vision algorithms, becoming the mainstream solution for industrial quality inspection. Among them, the YOLO (You Only Look Once) series of single-stage detection models is highly favored due to its excellent balance between speed and accuracy. YOLOv8, through optimized network structure and training strategies, further improves detection performance and is widely used in various real-time inspection scenarios.

[0003] However, when YOLOv8 is directly applied to high-precision defect detection in complex industrial environments (such as surface defect detection of metal sheets), its performance still faces significant challenges. On the one hand, the C2f module in the backbone network has limited feature capture and resolution capabilities when dealing with common small defects, low-contrast defects, or complex texture interference in industrial images, which can easily lead to missed detections and false detections. On the other hand, general attention mechanisms (such as SE, CBAM, etc.) introduced to enhance the model's perception of key areas can improve detection accuracy, but they are often accompanied by additional learnable parameters and computational overhead, resulting in increased model size and decreased inference efficiency, making it difficult to meet the strict requirements of real-time performance and lightweight deployment in industrial scenarios.

[0004] Therefore, the current research focus is on how to design a lightweight and enhanced feature extraction module that takes into account the special characteristics of industrial defect detection (such as small targets and weak contrast) while maintaining the efficient inference characteristics of the YOLOv8 framework, and integrate an efficient and low-cost attention mechanism, so as to substantially improve the detection accuracy and robustness of the model for complex defects without significantly increasing the computational cost. Summary of the Invention

[0005] The purpose of this invention is to provide a method, system, device and medium for detecting defects on metal surfaces, in order to solve the problems of insufficient feature extraction capability, high computational cost of attention mechanism and difficulty in balancing detection accuracy and real-time performance of the existing YOLOv8 model in industrial defect detection, and to achieve high-precision and high-efficiency detection of small, low-contrast and complex texture defects.

[0006] To achieve the above objectives, the present invention provides a method for detecting defects on metal surfaces, comprising the following steps: Step S1: Preprocess the image to be detected to obtain tensor data; Step S2: Input the tensor data into the improved YOLOv8 network model; Step S3: Use the C2f_SCConv module in the improved YOLOv8 network model to perform multi-layer feature extraction on the input data; Step S4: Input the extracted feature map into the spatial pyramid pooling module for multi-scale feature fusion; Step S5: Utilize the NAM attention mechanism module to perform salient region enhancement on the fused feature map; Step S6: Input the enhanced feature map into the detection head, perform target classification and location regression, and output the defect detection results; The improved YOLOv8 network model replaces the original C2f module in the backbone network with the C2f_SCConv module, and connects the NAM attention mechanism module after the spatial pyramid pooling module.

[0007] Preferably, the C2f_SCConv module is constructed by replacing the multiple Bottleneck modules contained within it with Bottleneck_SCConv modules, which are based on the C2f module as the skeleton. Each Bottleneck_SCConv module integrates an SCConv module, which is used to perform feature reconstruction in the spatial and channel dimensions during feature forward propagation.

[0008] Preferably, the SCConv module consists of a spatial reconstruction unit and a channel reconstruction unit connected in series; the spatial reconstruction unit is used to suppress spatial redundancy information in the feature map through separation and reconstruction operations; the channel reconstruction unit is used to reduce channel dimension redundancy in the feature map through segmentation, transformation and fusion strategies.

[0009] Preferably, the NAM attention mechanism module includes a channel attention submodule and a spatial attention submodule; The channel attention submodule extracts the scaling factor of each channel in the batch normalization layer, normalizes and activates it to generate a channel attention weight vector, which is used to weight each channel of the input feature map. The spatial attention submodule calculates the standard deviation of all channels at each location in the spatial dimension of the input feature map, normalizes the standard deviation, and generates a spatial attention weight map, which is used to weight each spatial location of the input feature map.

[0010] Preferably, the preprocessing in step S1 includes: standardizing the image size, normalizing the pixel values, and adjusting the image format to RGB three-channel.

[0011] Preferably, the defect detection result is the type of defect on the surface of the metal sheet, including at least one of rolled oxide scale, spots, cracks, pitting, inclusions and scratches.

[0012] The present invention also provides a metal surface defect detection system, comprising: The preprocessing module is used to standardize the size, normalize the pixels, and adjust the channel format of the input image to obtain tensor data that meets the network input requirements; The improved YOLOv8 detection network replaces the C2f module in its backbone with the C2f_SCConv module for multi-layer feature extraction of the input tensor. The feature fusion and enhancement module includes a spatial pyramid pooling module and a NAM attention mechanism module connected thereafter, which is used to perform multi-scale fusion and salient region enhancement on the extracted features; The detection output module is used to classify and regress the target location based on the enhanced feature map, and output the defect category, location and confidence information.

[0013] The present invention also provides a computer device, including: a memory and a processor; the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for detecting metal surface defects.

[0014] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method for detecting defects on a metal surface.

[0015] Therefore, the present invention employs the above-described method, system, equipment, and medium for detecting metal surface defects, and the beneficial technical effects are as follows: (1) By replacing the C2f module in the backbone network with the C2f_SCConv module that integrates the SCConv structure, this invention enhances the network's feature extraction and discrimination capabilities for complex textures, small targets, and low-contrast defects. The SCConv module effectively suppresses feature redundancy through spatial and channel reconstruction, strengthens the capture of key local information, and thus significantly reduces the false negative and false positive rates in complex industrial scenarios while maintaining the model's lightweight nature, thereby improving its adaptability to defects of various morphologies.

[0016] (2) This invention introduces a parameterless NAM attention mechanism after the SPPF module. By normalizing and weighting the channel and spatial features, it strengthens the focus on areas with significant defects, especially improving the detection capability for blurred edges and small-sized targets. Since NAM does not require the introduction of additional learnable parameters, its computational overhead is extremely low. Therefore, while significantly improving the detection accuracy of the model, it does not significantly increase the inference time or model size.

[0017] (3) The C2f_SCConv and NAM modules proposed in this invention have the characteristics of simple structure and plug-and-play. They can be directly embedded without reconstructing the YOLOv8 main framework. They are not only easy to implement and train, but also provide a reusable lightweight improvement idea for other industrial vision inspection tasks based on the YOLO series. They have good versatility and engineering promotion value. Attached Figure Description

[0018] Figure 1 A schematic diagram illustrating the structure of the improved YOLOv8 network model; Figure 2 This is a schematic diagram of the Space Reconstruction Unit (SRU) structure; Figure 3 This is a schematic diagram of the Channel Reconstruction Unit (CRU) structure; Figure 4 Here is a schematic diagram of the Bottleneck_SCConv module structure; Figure 5 This is a schematic diagram of the C2f_SCConv module structure; Figure 6 This is a schematic diagram of the channel attention module structure; Figure 7 This is a schematic diagram of the spatial attention module structure; Figure 8 This is a flowchart of a method for detecting defects on metal surfaces according to the present invention. Detailed Implementation

[0019] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0020] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.

[0021] Example 1 This embodiment provides a method for detecting defects on metal surfaces, enabling high-precision and high-efficiency detection of surface defects in industrial materials such as metal sheets. Figure 8 As shown, the overall process mainly includes steps such as image preprocessing, feature extraction, feature fusion and enhancement, and detection output. The specific implementation of this embodiment will be described in detail below with reference to the accompanying drawings.

[0022] 1. Improved network structure.

[0023] This embodiment makes two key improvements based on the YOLOv8 model. The overall model structure is as follows: Figure 1 As shown.

[0024] (1) Construction and replacement of the C2f_SCConv module.

[0025] The C2f module, as a key residual feature fusion unit in YOLOv8, possesses excellent cross-stage feature integration capabilities and can effectively capture semantic information at different levels. However, the C2f structure still suffers from insufficient spatial context modeling and limited local response regions when dealing with occlusion, complex textures, and fine-grained targets. Therefore, all C2f modules in the original YOLOv8 backbone network were replaced with a self-designed C2f_SCConv module (structure as follows). Figure 5 (As shown). This module uses the C2f module as its basic framework, replacing several standard Bottleneck modules with Bottleneck_SCConv modules (structure as shown). Figure 4 (As shown). Each Bottleneck_SCConv module integrates an SCConv module.

[0026] The SCConv module consists of Space Reconstruction Units (SRUs, structured as follows) Figure 2 (as shown) and Channel Reconstruction Unit (CRU, structure as shown) Figure 3 (As shown) is a series composition. SRU suppresses spatial redundancy in the input feature map through separation and reconstruction operations; CRU reduces channel dimension redundancy in the feature map through segmentation, transformation, and fusion strategies. Specifically, SRU first processes the input features... Perform group normalization to obtain the first... Response amplitude of each channel And calculate its normalized weights. : ; in, Indicates the number of channels. and These represent the height and width of the feature map, respectively. Indicates the first The response amplitude of each channel.

[0027] Next, nonlinear mapping and gated activation are applied to the normalized weights, dividing the channels into two categories: information-rich and information-redundant, corresponding to binary weight masks respectively. and By element-wise multiplication ( The input features are separated into two parts: ; ; in, This indicates a feature that contains relatively rich spatial information. This indicates a feature with weak spatial information and high redundancy.

[0028] During the reconstruction phase, SRU does not directly discard redundant features, but instead... and Further divided into sub-feature blocks, denoted as follows: and Then, through element-wise addition ( Achieve information complementarity: ; ; in, and These represent two reconstructed feature branches, each incorporating both information-rich and information-redundant features to enhance information flow and avoid feature isolation. Finally, the two reconstructed branches are merged using a channel concatenation operation to obtain the spatially refined features. : ; Through the aforementioned separation and cross-reconstruction mechanism, SRU can effectively suppress spatial redundancy while maintaining feature integrity and enhancing the discriminative and expressive power of intermediate features.

[0029] In CRU, spatial refinement features of SRU output. The process employs a split-transform-fusion workflow. First, in the splitting stage, based on a preset ratio... The feature channels are divided into two parts, corresponding to... and One channel, and through Convolution performs channel compression on the two feature sets to reduce subsequent computational overhead. Then, in the transformation phase, the upper branch features... Treated as an information-intensive branch, it simultaneously applies group-wise convolution (GWC) and point-wise convolution (PWC) to model the local spatial structure and inter-channel dependencies in parallel, and generates highly expressive features through element-wise addition. Characteristics of the lower branch Lightweight pointwise convolution is used for feature transformation, and the transformed features are concatenated with the original features to achieve feature reuse and generate supplementary features. During the integration phase, CRU respectively... and Perform global average pooling to obtain channel-level statistical description vectors. and ,in and The channel response intensities of the two branches in the global spatial domain were characterized separately to reflect the overall importance of the corresponding features. Subsequently, and Input the SoftMax function to generate adaptive fusion weights and This allows for dynamic adjustment of the contribution ratio of the two types of features in the final output. Finally, the features are fused using a weighted summation method. and The channel refinement feature output is obtained. Through the aforementioned channel splitting, heterogeneous transformation, and adaptive fusion mechanisms, CRU can effectively suppress channel redundancy and enhance feature representation capabilities while significantly reducing the number of parameters and computational complexity.

[0030] The fused output features exhibit stronger texture preservation and edge response capabilities in the spatial dimension. By incorporating SCConv into the feature extraction path, the C2f_SCConv module significantly enhances its feature modeling capabilities for complex textures and minute defects while maintaining a lightweight design.

[0031] (2) Introduction and integration of NAM attention mechanism.

[0032] Following the Spatial Pyramid Pooling (SPPF) module, a NAM (Normalization-based Attention Module) attention mechanism module is integrated. This module contains a channel attention submodule (structured as follows). Figure 6 (as shown) and spatial attention submodule (structure as shown) Figure 7 (As shown).

[0033] Channel attention submodule: for input features Batch normalization (BN) is performed, and a corresponding scaling factor is introduced for each channel in the BN layer. This parameter reflects the contribution of different channels to feature representation during training. Subsequently, for... Normalization is performed, and channel weight vectors are generated using the Sigmoid activation function. This weight vector is applied to the original feature map through channel-wise multiplication, achieving adaptive recalibration of the channel dimensions, and ultimately obtaining the channel-enhanced feature map. This process does not require the introduction of additional learnable parameters; it can effectively highlight key channel features simply by utilizing the statistical information already present in Batch Normalization (BN).

[0034] Spatial attention submodule: for input features First, the standard deviation across channels is calculated spatially to measure the dispersion of the characteristic response at that location. Then, the resulting standard deviation plot is normalized, and a spatial weight plot is generated using the Sigmoid function. The corresponding spatial weighting coefficients also represent the importance of different positions. These weights are applied to the input feature map through element-wise multiplication, resulting in a spatially enhanced feature map. It effectively enhances the response in defective areas, edge areas, and small target areas.

[0035] The NAM module requires no learnable parameters and has extremely low computational overhead, achieving a good balance between accuracy improvement and inference efficiency.

[0036] 2. Defect detection process.

[0037] The complete workflow of this method is as follows: Figure 8 As shown, the specific steps are as follows: Image preprocessing: Preprocessing the input image of the metal sheet surface. This includes normalizing the image size. The pixels are normalized (e.g., normalized to the range [0, 1]), and the single-channel grayscale image is adjusted to RGB three-channel format by copying the channel, finally obtaining tensor data that meets the network input requirements.

[0038] Feature extraction: The preprocessed tensor data is input into the improved YOLOv8 backbone network. The network uses multiple cascaded C2f_SCConv modules to perform deep feature extraction on the input data, fully capturing multi-level and multi-scale semantic information related to defects in the image.

[0039] Feature Fusion and Enhancement: The extracted deep feature maps are fed into the SPPF module, which performs multi-scale feature fusion through max pooling operations at different scales to enrich the contextual information of the features. Subsequently, the fused feature maps enter the NAM attention mechanism module. The NAM module generates attention weights based on channel and spatial statistics to enhance salient defect regions in the feature maps and suppress irrelevant background information.

[0040] Detection Output: The enhanced feature map is input into the detection head module. The detection head contains multiple convolutional layers responsible for object classification (determining whether it belongs to a certain type of defect) and bounding box regression (precisely labeling the defect location) of the feature map. Finally, the model outputs the detection result containing the defect category, confidence score, and bounding box coordinates, and maps it back to the original image size, completing the entire detection process.

[0041] The invention will be further illustrated below with specific examples.

[0042] To verify the effectiveness of the method in this embodiment, experiments were conducted on the steel plate surface defect dataset (NEU-DET). This dataset contains 1800 images. The image is a pixel-level grayscale image covering six typical defects: rolled-in scale, patches, cracks, pitted surface, inclusions, and scratches, with 300 samples for each category.

[0043] The experiment was conducted on a hardware environment equipped with an NVIDIA GeForce RTX 4060 GPU, and the software environment consisted of Python 3.10, CUDA 12.7, and PyTorch 2.5.1. The training parameters were set as follows: 300 training epochs, a batch size of 16, AdamW as the optimizer, an initial learning rate of 0.01, and a uniform input image size of 640×640.

[0044] The dataset was randomly divided into training, validation, and test sets in a 7:2:1 ratio. The improved YOLOv8 model proposed in this embodiment was used for training and evaluation. The ablation experiment results are shown in Table 1. The gradual introduction of the C2f_SCConv module and the NAM attention mechanism both resulted in performance improvements. Ultimately, the average accuracy (mAP@0.5) of the fully improved model reached 81.7%, an improvement of 2.3 percentage points compared to the original YOLOv8 model (79.4%), demonstrating the effectiveness of the improvement strategy in this embodiment.

[0045] Table 1 Ablation Experiment Results

[0046] This model achieved an accuracy of 81.7%, which is 2.3 percentage points higher than YOLOv8n and outperforms mainstream models such as Faster-RCNN, YOLOv5s, and YOLOv10.

[0047] Table 2 Comparison results of different models

[0048] Example 2 A metal surface defect detection system, comprising: The preprocessing module is used to standardize the size, normalize the pixels, and adjust the channel format of the input image to obtain tensor data that meets the network input requirements; The improved YOLOv8 detection network replaces the C2f module in its backbone with the C2f_SCConv module for multi-layer feature extraction of the input tensor. The feature fusion and enhancement module includes a spatial pyramid pooling module and a NAM attention mechanism module connected thereafter, which is used to perform multi-scale fusion and salient region enhancement on the extracted features; The detection output module is used to classify and regress the target location based on the enhanced feature map, and output the defect category, location and confidence information.

[0049] If the aforementioned functions are implemented as software functional units 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 this invention, or the part that contributes to the prior art, or a part of the 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0050] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0051] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0052] It is worth noting that all contents not described in detail in this invention are existing technologies and are well known to those skilled in the art.

[0053] Therefore, this invention employs the aforementioned method, system, device, and medium for metal surface defect detection. It enhances feature representation capabilities by introducing a C2f_SCConv module fused with SCConv into the YOLOv8 backbone network, and integrates a parameter-free NAM attention mechanism after the SPPF module. This lightweight approach improves the model's performance in focusing on and recognizing significant defect regions. The combination of the C2f-SCConv structure and the NAM attention mechanism aims to simultaneously improve feature representation capabilities and critical region perception capabilities without significantly increasing model computational complexity, thus meeting the dual requirements of accuracy and real-time performance in industrial defect detection.

[0054] The C2f-SCConv module, by introducing the spatial and channel reconstruction mechanism of SCConv, effectively suppresses redundant information during the feature extraction stage, enhancing the ability to discriminate complex textures, small and low-contrast defects, thereby obtaining more refined and stable feature representations. The NAM attention mechanism, after feature fusion, adaptively weights channels and spatial positions based on normalized statistical information, highlighting salient defect regions and suppressing background interference without introducing additional learnable parameters. The synergistic effect of these two mechanisms achieves an organic unity between feature representation enhancement and salient region reinforcement, significantly improving the accuracy and robustness of defect detection while maintaining model lightweightness and inference efficiency.

[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for detecting defects on metal surfaces, characterized in that, Includes the following steps: Step S1: Preprocess the image to be detected to obtain tensor data; Step S2: Input the tensor data into the improved YOLOv8 network model; Step S3: Use the C2f_SCConv module in the improved YOLOv8 network model to perform multi-layer feature extraction on the input data; Step S4: Input the extracted feature map into the spatial pyramid pooling module for multi-scale feature fusion; Step S5: Use the NAM attention mechanism module to perform salient region enhancement on the fused feature map; Step S6: Input the enhanced feature map into the detection head, perform target classification and location regression, and output the defect detection results; The improved YOLOv8 network model replaces the original C2f module in the backbone network with the C2f_SCConv module, and connects the NAM attention mechanism module after the spatial pyramid pooling module.

2. The method for detecting metal surface defects according to claim 1, characterized in that, The C2f_SCConv module is based on the C2f module, and its multiple Bottleneck modules are replaced with Bottleneck_SCConv modules. Each Bottleneck_SCConv module integrates an SCConv module, which is used to perform feature reconstruction in the spatial and channel dimensions during feature forward propagation.

3. The method for detecting metal surface defects according to claim 2, characterized in that, The SCConv module consists of a spatial reconstruction unit and a channel reconstruction unit connected in series. The spatial reconstruction unit is used to suppress spatial redundancy information in the feature map through separation and reconstruction operations. The channel reconstruction unit is used to reduce channel dimension redundancy in the feature map through segmentation, transformation and fusion strategies.

4. The method for detecting metal surface defects according to claim 1, characterized in that, The NAM attention mechanism module includes a channel attention submodule and a spatial attention submodule; The channel attention submodule extracts the scaling factor of each channel in the batch normalization layer, normalizes and activates it to generate a channel attention weight vector, which is used to weight each channel of the input feature map. The spatial attention submodule calculates the standard deviation of all channels at each location in the spatial dimension of the input feature map, normalizes the standard deviation, and generates a spatial attention weight map, which is used to weight each spatial location of the input feature map.

5. The method for detecting metal surface defects according to claim 1, characterized in that, The preprocessing in step S1 includes: standardizing the image size, normalizing the pixel values, and adjusting the image format to RGB three-channel.

6. The method for detecting metal surface defects according to claim 1, characterized in that, The defect detection result is the type of defect on the surface of the metal sheet, including at least one of the following: rolled oxide scale, spots, cracks, pitting, inclusions, and scratches.

7. A metal surface defect detection system, characterized in that, include: The preprocessing module is used to standardize the size, normalize the pixels, and adjust the channel format of the input image to obtain tensor data that meets the network input requirements; The improved YOLOv8 detection network replaces the C2f module in its backbone with the C2f_SCConv module for multi-layer feature extraction of the input tensor. The feature fusion and enhancement module includes a spatial pyramid pooling module and a NAM attention mechanism module connected thereafter, which is used to perform multi-scale fusion and salient region enhancement on the extracted features; The detection output module is used to classify and regress the target location based on the enhanced feature map, and output the defect category, location and confidence information.

8. A computer device, comprising: Memory and processor; The memory stores a computer program, characterized in that when the processor executes the computer program, it implements the steps of the metal surface defect detection method according to any one of claims 1-7.

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