A small sample strip steel surface defect detection method and system

By employing a perceptual optimization coding strategy and a parallel prompt generation strategy, the feature representation of surface defects in strip steel is enhanced, solving the problems of low contrast and texture preservation in small-sample semantic segmentation, and achieving more accurate detection of surface defects in strip steel.

CN122176303APending Publication Date: 2026-06-09SHANDONG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG UNIV
Filing Date
2026-03-10
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing few-sample semantic segmentation methods struggle to effectively utilize low-level detail features in strip surface defect detection, leading to the loss of key information in feature representation. Furthermore, existing methods perform poorly in handling low contrast and texture preservation, making them unsuitable for strip surface defect segmentation under few-sample constraints.

Method used

A perceptual optimization coding strategy is adopted to enhance the feature representation of surface defects in strip steel. By combining perceptual optimization with prototype and mask-guided learning, shallow features are enhanced, and semantic and spatial cue embeddings are generated in parallel. A defect prediction mask is generated using the mask decoder of SAM, and training is performed by combining binary cross-entropy and Dice loss.

Benefits of technology

It effectively preserves the key texture details and spatial structure information of strip surface defects, improving the accuracy and robustness of small sample strip surface defect detection, especially with a significant 12.00% improvement in mIoU on the SurfaceDefects-4i dataset.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176303A_ABST
    Figure CN122176303A_ABST
Patent Text Reader

Abstract

This invention relates to the field of semantic segmentation technology, and provides a method and system for detecting surface defects on small-sample strip steel. The method includes: for a strip steel surface image, obtaining a defect prediction mask using a strip steel surface defect detection model; the strip steel surface defect detection model employs a perceptual optimization coding strategy, including: using the acquired strip steel surface image as a query image, enhancing both the query image and support images in the support set in the logarithmic domain, and then extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features of the support images using masked average pooling; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, and then performing feature enhancement through convolution. This effectively solves the unique challenges of segmenting surface defects on small-sample strip steel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of semantic segmentation technology, and in particular relates to a method and system for detecting surface defects in small-sample strip steel. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] Semantic segmentation is a fundamental task in computer vision, aiming to assign a category label to each pixel in an image and supporting downstream tasks such as autonomous driving, medical analysis, and defect detection. While existing deep learning-based methods have made significant progress, they heavily rely on large-scale labeled datasets, which are costly and time-consuming to collect, especially in specialized fields like defect detection. To address this data scarcity challenge, few-shot semantic segmentation (FSS) has emerged as a promising paradigm. Few-shot semantic segmentation methods can be categorized into prototype-based methods, affinity-based methods, and base model-based methods.

[0004] Semantic segmentation of surface defects on steel strips faces significant challenges that are quite different from those in natural scenes: First, unlike natural images, images of surface defects on steel strips exhibit a monotonous color distribution, but also suffer from low local contrast and uneven illumination; second, defect areas are often obscured by complex textured backgrounds, and the intensity variations are subtle, making small-scale defect localization difficult; finally, unlike semantic segmentation of natural scenes which relies on high-level semantic features, semantic segmentation of surface defects on steel strips depends on fine-grained structural and textural features, with key discriminative cues existing in local intensity variations and micro-textural patterns.

[0005] However, existing few-shot semantic segmentation methods typically extract features from deep networks, discarding crucial low-level details. This results in feature representations that lose key information and introduce irrelevant information. Current few-shot semantic segmentation methods, such as MAPTNet, mainly employ a prototype-based architecture, extracting prototypes and performing segmentation through pixel-level matching. This approach fails to fully utilize feature representations for strip steel surface defect segmentation, particularly performing poorly in handling low contrast and texture preservation. In recent years, the Segment Anything Model (SAM) from natural scenes has been introduced into industrial scenarios. Based on the pre-trained representations of the powerful SAM segmentation model, existing few-shot semantic segmentation methods, such as VRP-SAM, generate enhanced features and sample sparse cues to guide SAM. However, this method discards rich spatial information and is highly sensitive to feature quality, making it unsuitable for strip steel surface defect segmentation under few-shot constraints. In summary, traditional few-shot semantic segmentation methods struggle to achieve ideal results in strip steel surface defect segmentation. Summary of the Invention

[0006] To address the technical problems mentioned above, this invention provides a method and system for detecting surface defects in small-sample strip steel. It proposes a perceptual optimization coding strategy that combines perceptual optimization with prototype and mask-guided learning. By unifying defect representation through perceptual optimization and enhancing shallow features using prototype and mask-guided learning, features suitable for segmenting surface defects in small-sample strip steel are encoded.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] The first aspect of the present invention provides a method for detecting surface defects in small sample strip steel, comprising: Acquire images of the strip surface; For the strip surface image, the defect prediction mask is obtained through the strip surface defect detection model; The strip steel surface defect detection model employs a perceptual optimization coding strategy to enhance the feature representation of strip steel surface defects. This strategy includes: using the acquired strip steel surface image as the query image; enhancing both the query image and the support images in the support set in the logarithmic domain; extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features using masked average pooling for the support images; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, followed by feature enhancement through convolution to obtain enhanced support features and enhanced query features.

[0009] Furthermore, the strip surface defect detection model employs a parallel prompt generation strategy to generate semantic prompt embeddings and spatial prompt embeddings in parallel from the enhanced features. This parallel prompt generation strategy includes: introducing a set of learnable queries, interacting with the enhanced support features through cross-attention and self-attention to obtain category-specific information; using cross-attention and self-attention to interact the category-specific information with the enhanced query features to obtain semantic prompts; compressing the enhanced query features into a spatial heatmap through channel averaging, and processing the spatial heatmap through normalization and convolutional blocks to generate spatial prompts; and a SAM prompt encoder processing the semantic and spatial prompts respectively to obtain the semantic prompt embeddings and spatial prompt embeddings.

[0010] Furthermore, the strip surface defect detection model uses the SAM mask decoder to generate a defect prediction mask.

[0011] Furthermore, the strip surface defect detection model is trained using binary cross-entropy loss and Dice loss.

[0012] A second aspect of the present invention provides a small sample strip steel surface defect detection system, comprising: The image acquisition module is configured to acquire images of the strip surface. The defect detection module is configured to: for a strip surface image, obtain a defect prediction mask through a strip surface defect detection model; The strip steel surface defect detection model employs a perceptual optimization coding strategy to enhance the feature representation of strip steel surface defects. This strategy includes: using the acquired strip steel surface image as the query image; enhancing both the query image and the support images in the support set in the logarithmic domain; extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features using masked average pooling for the support images; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, followed by feature enhancement through convolution to obtain enhanced support features and enhanced query features.

[0013] Furthermore, the strip surface defect detection model employs a parallel prompt generation strategy to generate semantic prompt embeddings and spatial prompt embeddings in parallel from the enhanced features. This parallel prompt generation strategy includes: introducing a set of learnable queries, interacting with the enhanced support features through cross-attention and self-attention to obtain category-specific information; using cross-attention and self-attention to interact the category-specific information with the enhanced query features to obtain semantic prompts; compressing the enhanced query features into a spatial heatmap through channel averaging, and processing the spatial heatmap through normalization and convolutional blocks to generate spatial prompts; and a SAM prompt encoder processing the semantic and spatial prompts respectively to obtain the semantic prompt embeddings and spatial prompt embeddings.

[0014] Furthermore, the strip surface defect detection model uses the SAM mask decoder to generate a defect prediction mask.

[0015] Furthermore, the strip surface defect detection model is trained using binary cross-entropy loss and Dice loss.

[0016] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for detecting surface defects in a small sample strip steel as described above.

[0017] A fourth aspect of the present invention provides a computer device including a computer-readable storage medium, a processor, and a computer program stored on the computer-readable storage medium and executable on the processor, wherein the processor executes the program to implement the steps of the method for detecting surface defects in a small sample strip steel as described above.

[0018] Compared with the prior art, the beneficial effects of the present invention are: This invention proposes a perceptual optimization coding strategy that combines perceptual optimization with prototype and mask-guided learning. It unifies defect representation through perceptual optimization and enhances shallow features using prototype and mask-guided learning to encode features suitable for segmenting surface defects of small-sample strip steel.

[0019] This invention proposes a parallel prompt generation strategy that generates semantic and spatial prompts in parallel, preserving rich spatial information while maintaining robustness to feature changes, thus providing comprehensive guidance for the SAM decoder.

[0020] This invention employs BCE loss to ensure pixel-level accuracy, while Dice loss provides additional spatial context by emphasizing region overlap. By combining these two losses, accuracy and spatial consistency are jointly considered, enabling the model to produce more accurate segmentation results. Attached Figure Description

[0021] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0022] Figure 1 This is a flowchart of a small sample strip steel surface defect detection method according to Embodiment 1 of the present invention; Figure 2 This is a qualitative comparison chart of representative defect categories in the FSSD-12 dataset according to Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the structure of a computer device according to Embodiment 4 of the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0024] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0025] Terminology Explanation: Semantic segmentation is a computer vision task that accurately classifies each pixel of an image into a predefined semantic category.

[0026] Few-shot learning is a machine learning paradigm that uses only a very small number of labeled samples to identify or segment new categories.

[0027] Segmentation Model for All Objects (SAM): This is a model that can identify and segment any object based on prompts.

[0028] Example 1 This embodiment provides a method for detecting surface defects in small sample strip steel.

[0029] The shallow structural cues that are crucial for strip surface defect segmentation in existing work have not been fully utilized. This embodiment provides a small-sample strip surface defect detection method, which aims to solve problems such as low contrast, uneven illumination, strong texture and slender defects. Under the constraint of small samples, these cues are preserved to improve robustness, and a small-sample semantic segmentation model for strip surface defect segmentation is explored.

[0030] This embodiment provides a method for detecting surface defects in small-sample strip steel, which aims to effectively encode feature representations and provide prompts to guide SAM in segmenting surface defects in small-sample strip steel.

[0031] This embodiment provides a method for detecting surface defects in small-sample strip steel. It proposes a novel perceptual parallel prompting framework based on SAM (Signal-Aware Imaging). Two core strategies address the unique challenges of segmenting surface defects in small-sample strip steel: First, a perceptual optimization coding strategy is developed to enhance local contrast and preserve key texture details. Specifically, perceptual optimization is performed using a multi-scale Retinex algorithm computed pixel-by-pixel to unify defect representation. Then, fine-grained texture information is extracted from the shallow layers of the ResNet50 backbone network, and shallow feature enhancement is guided by prototype constraints and pseudo-mask supervision to capture fine-grained texture features while preserving key edge and structural details. Second, a parallel prompting generation strategy is introduced. The query features enhanced by the perceptual optimization coding strategy and supporting features are processed in parallel to generate semantic and spatial prompt embeddings, respectively. This provides comprehensive guidance for the SAM decoder while maintaining robustness to feature changes. These prompts are then input into the frozen SAM prompt encoder and decoder to generate the final segmentation mask for the query image. Unlike existing methods that rely solely on sparse cues, this strategy generates two types of cues in parallel from augmented features, thereby achieving complete spatial structure inference and effectively addressing the unique challenge of segmenting surface defects on small-sample strip steel.

[0032] This embodiment provides a method for detecting surface defects in small sample strip steel, including: Step 1: Obtain the surface image of the strip steel as the query image and configure the corresponding supporting images; Step 2: Input the query image and support image into the strip surface defect detection model, and obtain the defect prediction mask based on SAM segmentation through perceptual optimization coding and parallel prompting strategy.

[0033] like Figure 1 As shown, the strip steel surface defect detection model includes: a perception-optimized coding strategy, a parallel prompt generation strategy, a SAM image encoder, a prompt encoder, and a decoder.

[0034] (1) Perceptual optimization coding strategy.

[0035] Unlike high-level semantic features that dominate segmentation in natural images, strip steel surface defect segmentation relies heavily on low-level texture and edge information due to the subtle nature of the defects and the fine-grained surface variations. Furthermore, uneven illumination and low local contrast further obscure the fine-grained defect texture, making accurate localization difficult. To address these challenges, this embodiment proposes a perceptual optimized coding strategy to enhance the feature representation of strip steel surface defects in small samples.

[0036] (101) Multi-scale Retinex is used for perceptual optimization, and the input images in the support set and query set are optimized. and Lighting normalization is performed separately, and the reflection characteristics are enhanced by subtracting the estimated lighting components in the logarithmic domain, thereby suppressing uneven lighting while improving local contrast and texture details.

[0037] In the logarithmic domain, for each RGB channel, the scale The single-scale response is calculated as follows: ; in, It is a Gaussian kernel. This represents a convolution operation, where x represents a channel. Indicates the input image or Three scales The multiscale responses are combined to capture different spatial frequencies, then mapped back to the linear domain and normalized. Range; Enhanced image This preprocessing is then fed into the image encoder and the SAM image encoder; this preprocessing is applied in the same manner to the support images during both the training and inference phases. and query images K is the number of supported images.

[0038] (102) The image encoder constructed using the first four layers of ResNet50 is used to encode the enhanced support image and query image respectively to extract shallow and deep features.

[0039] To preserve the fine-grained strength and microtexture clues of the dominant surface defect segmentation of the strip, a fusion of shallow features was employed. .

[0040] For both the supporting image and the query image, the first shallow layer features are obtained from layer1 (the first layer, stride 4). Obtain the second shallow layer features from layer2 (second layer, stride 8). .

[0041] For the query image, extract deep features from layers 3-4 (the third and fourth layers). For supporting images, extract deep features from layers 3-4 (the third and fourth layers). .

[0042] For both the supporting image and the query image, multi-scale shallow features are fused in the following way to obtain fused shallow features (or simply shallow features): ; Where C represents the target channel dimension. Matching the resolution of layer 2, This indicates a bilinear upsampling operation. This indicates a channel-level concatenation operation. This represents the convolution operation. The dimension represents the feature dimension, where C represents the number of feature channels, and H and W represent the height and width, respectively.

[0043] (103) For supporting images, semantic guidance is provided by masked average pooling. Calculate a category-specific prototype from fused shallow features: ; in, This indicates support for the fusion of shallow features in the image. This represents the annotation mask for the i-th supporting image.

[0044] (104) Based on the deep features of the supporting image and the query image, a pseudo-mask is generated by calculating cosine similarity. : ; in, This represents element-wise multiplication. Calculate cosine similarity. This indicates that the image supports deep features. This indicates a mask that supports image annotations. This indicates the deep features of the queried image.

[0045] (105) The shallow features are concatenated with the prototype and the corresponding mask, and then feature enhancement is performed through convolution: ; ; in, This indicates a splicing operation. This represents the fused shallow features of the query image; by combining multi-scale Retinex optimization with prototype and mask-guided shallow feature enhancement, the perceptual coding optimization strategy enhances local contrast and texture details while preserving shallow fine-grained information. This design achieves a balance between low-level texture preservation and high-level semantic guidance, resulting in enhanced features. It can capture key texture details and category-specific contextual information simultaneously, providing support for subsequent hint generation.

[0046] (2) Parallel prompt generation strategy.

[0047] Existing few-shot semantic segmentation methods based on SAM typically only generate semantic cues, leading to the spatial cue branch degenerating into a constant embedding. While the SAM image encoder captures general visual features, relying solely on semantic cues fails to provide explicit spatial structure guidance, resulting in incomplete segmentation. In contrast, combining semantic and spatial cues simultaneously enables comprehensive guidance. To leverage these two cue types, a parallel cue generation strategy is proposed, which generates semantic and spatial cue embeddings in parallel from augmented features, enabling the model to infer complete spatial structure while maintaining robustness to feature variations.

[0048] (201) Given the enhanced support features and enhanced query features from the perceptual coding optimization strategy First, we introduce a set of learnable queries. ,in, These queries are performed using cross-attention to determine the number of visual cues. and self-attention Interact with enhanced support features to obtain category-specific information: ; in, The knowledge of the defect categories to be segmented is encoded.

[0049] (202) Employing cross-attention and self-attention Interacting category-specific information with enhanced query features to obtain foreground information: ; in, As a semantic cue for the query, category-specific semantic guidance from supporting images is encoded.

[0050] (203) To provide spatial structure guidance, spatial hints are generated from enhanced query features.

[0051] First, multi-channel enhanced query features are compressed into a single-channel spatial heatmap by channel averaging: ; The heatmap was then normalized. To match the input resolution of the cue encoder of SAM, and then through convolutional blocks Encoding space hints: ; in, It provides spatial structure guidance derived from the query image itself, making it robust to variations in the quality of the supporting annotations; the convolutional block consists of a 2×2 convolution, layer normalization, activation function, 2×2 convolution, layer normalization, activation function and 1×1 convolution connected in sequence.

[0052] (204) The SAM cue encoder processes semantic cues and spatial cues respectively to obtain semantic cue embeddings and spatial cue embeddings.

[0053] (3) Final segmentation mask Mask decoder by SAM The decoder generates image embeddings from the SAM frozen encoder (with the enhanced support image and query image as input). SAM prompt encoder Semantic hints are processed separately. and space prompts The resulting semantic and spatial hint embeddings are: ; By generating semantic and spatial cues in parallel, the parallel cue generation strategy simultaneously... Combining semantic guidance, through By incorporating spatial structure, this parallel design enables the model to infer the complete spatial structure from limited support annotations, while maintaining robustness to changes in feature granularity, achieving more accurate segmentation than relying solely on either type of cue.

[0054] (4) Loss function.

[0055] Binary cross-entropy (BCE) loss and Dice loss are used to supervise the training of the entire pipeline, querying the final predicted mask of the image. With the real mask The loss between them is defined as: ; in, and These are the BCE loss and the Dice loss, respectively. The BCE loss ensures pixel-level accuracy, while the Dice loss provides additional spatial context by emphasizing region overlap. By combining these two losses, accuracy and spatial consistency are jointly considered, enabling the model to produce more accurate segmentation results.

[0056] This embodiment provides a method for detecting surface defects on small-sample strip steel, which includes two core strategies: a perceptual optimization encoding strategy, which combines perceptual optimization with prototype and mask-guided learning, unifies defect representation through perceptual optimization, and uses prototype and mask-guided learning to enhance shallow features to encode features suitable for segmentation of surface defects on small-sample strip steel; and a parallel prompt generation strategy, which generates semantic and spatial prompts in parallel, preserving rich spatial information while maintaining robustness to feature changes, providing comprehensive guidance for the SAM decoder.

[0057] This embodiment presents a method for detecting surface defects in strip steel with few samples. It proposes a novel perceptual parallel prompting framework to address the task of semantic segmentation of strip steel surface defects with few samples. Specifically, this framework is based on the SAM model and addresses domain challenges through two core strategies: First, a perceptual optimization encoding strategy is developed to enhance local contrast and preserve key texture details for strip steel surface defect segmentation; second, a parallel prompting generation strategy is introduced, which simultaneously generates semantic and spatial prompts, providing comprehensive guidance to the SAM decoder while maintaining robustness to feature variations. Extensive experiments on three benchmark datasets of strip steel surface defects with few samples demonstrate that the perceptual parallel prompting framework of this embodiment effectively solves the segmentation difficulties caused by image contrast, uneven illumination, and subtle textures in strip steel surface defect images under few sample conditions. It achieves state-of-the-art performance on all three benchmark datasets, with a significant 12.00% improvement in mIoU, particularly on the SurfaceDefects-4i dataset.

[0058] Figure 2 The presentation shows a qualitative comparison of the proposed method with MAPTNet and VRP-SAM on representative defect categories of the FSSD-12 dataset. From top to bottom, each row displays: green for the supporting image's ground truth mask, yellow for the query image's ground truth mask, and red for each method's prediction results. The results demonstrate that the proposed method consistently produces more accurate masks than other methods in a variety of challenging scenarios: noisy backgrounds in columns 1-2, low-contrast regions in column 3, complex structures (such as inclusions) in columns 4 and 6, and subtle details (such as scratches) in column 5. These visualizations confirm that the proposed method achieves superior segmentation performance on strip surface defects under various challenging conditions in industrial settings.

[0059] Example 2 This embodiment provides a small sample strip steel surface defect detection system, including: The image acquisition module is configured to acquire images of the strip surface. The defect detection module is configured to: for a strip surface image, obtain a defect prediction mask through a strip surface defect detection model; The strip steel surface defect detection model employs a perceptual optimization coding strategy to enhance the feature representation of strip steel surface defects. This strategy includes: using the acquired strip steel surface image as the query image; enhancing both the query image and the support images in the support set in the logarithmic domain; extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features using masked average pooling for the support images; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, followed by feature enhancement through convolution to obtain enhanced support features and enhanced query features.

[0060] Furthermore, the strip surface defect detection model employs a parallel prompt generation strategy to generate semantic prompt embeddings and spatial prompt embeddings in parallel from the enhanced features. This parallel prompt generation strategy includes: introducing a set of learnable queries, interacting with the enhanced support features through cross-attention and self-attention to obtain category-specific information; using cross-attention and self-attention to interact the category-specific information with the enhanced query features to obtain semantic prompts; compressing the enhanced query features into a spatial heatmap through channel averaging, and processing the spatial heatmap through normalization and convolutional blocks to generate spatial prompts; and a SAM prompt encoder processing the semantic and spatial prompts respectively to obtain the semantic prompt embeddings and spatial prompt embeddings.

[0061] Furthermore, the strip surface defect detection model uses the SAM mask decoder to generate a defect prediction mask.

[0062] Furthermore, the strip surface defect detection model is trained using binary cross-entropy loss and Dice loss.

[0063] It should be noted that each module in this embodiment corresponds one-to-one with each step in Embodiment 1, and their specific implementation processes are the same, so they will not be repeated here.

[0064] Example 3 This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the small sample strip surface defect detection method described in Embodiment 1 above.

[0065] Example 4 This embodiment provides a computer device, such as... Figure 3As shown, the system includes a computer-readable storage medium 1003, a processor 1001, a communication interface 1002, and a computer program stored on the computer-readable storage medium 1003 and executable on the processor 1001. The processor 1001, communication interface 1002, and computer-readable storage medium 1003 can be connected via a bus or other means. The communication interface 1002 is used to receive and transmit data. When the processor 1001 executes the program, it implements the steps in the small sample strip steel surface defect detection method described in Embodiment 1 above.

[0066] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for detecting surface defects in small sample strip steel, characterized in that, include: Acquire images of the strip surface; For the strip surface image, a defect prediction mask is obtained through the strip surface defect detection model; The strip steel surface defect detection model employs a perceptual optimization coding strategy to enhance the feature representation of strip steel surface defects. This strategy includes: using the acquired strip steel surface image as the query image; enhancing both the query image and the support images in the support set in the logarithmic domain; extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features using masked average pooling for the support images; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, followed by feature enhancement through convolution to obtain enhanced support features and enhanced query features.

2. The method for detecting surface defects in small sample strip steel as described in claim 1, characterized in that, The strip surface defect detection model employs a parallel prompt generation strategy to generate semantic prompt embeddings and spatial prompt embeddings in parallel from the enhanced features. This strategy includes: introducing a set of learnable queries, interacting with the enhanced support features through cross-attention and self-attention to obtain category-specific information; using cross-attention and self-attention to interact the category-specific information with the enhanced query features to obtain semantic prompts; compressing the enhanced query features into a spatial heatmap through channel averaging, and processing the spatial heatmap through normalization and convolutional blocks to generate spatial prompts; and using a SAM prompt encoder to process the semantic and spatial prompts respectively to obtain the semantic prompt embeddings and spatial prompt embeddings.

3. The method for detecting surface defects in small sample strip steel as described in claim 1, characterized in that, The strip surface defect detection model uses the SAM mask decoder to generate a defect prediction mask.

4. The method for detecting surface defects in small sample strip steel as described in claim 1, characterized in that, The strip surface defect detection model is trained using binary cross-entropy loss and Dice loss.

5. A small-sample strip steel surface defect detection system, characterized in that, include: The image acquisition module is configured to acquire images of the strip surface. The defect detection module is configured to: for a strip surface image, obtain a defect prediction mask through a strip surface defect detection model; The strip steel surface defect detection model employs a perceptual optimization coding strategy to enhance the feature representation of strip steel surface defects. This strategy includes: using the acquired strip steel surface image as the query image; enhancing both the query image and the support images in the support set in the logarithmic domain; extracting shallow and deep features using an image encoder; calculating a category-specific prototype from the shallow features using masked average pooling for the support images; generating a pseudo-mask based on the deep features of the support and query images using cosine similarity calculation; and concatenating the shallow features, prototype, and pseudo-mask for both the support and query images, followed by feature enhancement through convolution to obtain enhanced support features and enhanced query features.

6. The small sample strip steel surface defect detection system as described in claim 5, characterized in that, The strip surface defect detection model employs a parallel prompt generation strategy to generate semantic prompt embeddings and spatial prompt embeddings in parallel from the enhanced features. This strategy includes: introducing a set of learnable queries, interacting with the enhanced support features through cross-attention and self-attention to obtain category-specific information; using cross-attention and self-attention to interact the category-specific information with the enhanced query features to obtain semantic prompts; compressing the enhanced query features into a spatial heatmap through channel averaging, and processing the spatial heatmap through normalization and convolutional blocks to generate spatial prompts; and using a SAM prompt encoder to process the semantic and spatial prompts respectively to obtain the semantic prompt embeddings and spatial prompt embeddings.

7. The small sample strip steel surface defect detection system as described in claim 5, characterized in that, The strip surface defect detection model uses the SAM mask decoder to generate a defect prediction mask.

8. The small sample strip steel surface defect detection system as described in claim 5, characterized in that, The strip surface defect detection model is trained using binary cross-entropy loss and Dice loss.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the method for detecting surface defects in small sample strip steel as described in any one of claims 1-4.

10. A computer device comprising a computer-readable storage medium, a processor, and a computer program stored on the computer-readable storage medium and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the method for detecting surface defects in small sample strip steel as described in any one of claims 1-4.