Method and apparatus for detecting surface defects of textile, and device and medium

By comparing and filtering the feature library of pre-trained models and good product image sets, and combining traditional algorithms and deep learning, the problem of scarce data and complex types in textile defect detection has been solved, achieving efficient and personalized defect detection and reducing the difficulty of technology implementation.

WO2026123830A1PCT designated stage Publication Date: 2026-06-18CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
Filing Date
2025-09-09
Publication Date
2026-06-18

AI Technical Summary

Technical Problem

Existing technologies for detecting surface defects in textiles rely on manual inspection, which suffers from problems such as scarce defect data, long collection time, and a wide variety of textile types and complex defect types, making it difficult to implement the technology. Furthermore, existing AI systems are unable to achieve efficient and accurate defect detection.

Method used

By employing a pre-trained defect recognition model and a set of good product images, and by comparing the standard feature library with the actual feature library, candidate and defect image sets are selected. The model is then trained using a combination of traditional algorithms and deep learning models to achieve rapid deployment of personalized detection.

🎯Benefits of technology

It enables efficient and personalized textile defect detection under low computing power and data volume conditions, shortens the project deployment cycle, and improves detection accuracy and feasibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025120001_18062026_PF_FP_ABST
    Figure CN2025120001_18062026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present application are a method and apparatus for detecting surface defects of a textile, and a device and a medium. The method comprises: acquiring a pre-trained defect recognition model and a good-product image set; extracting a standard feature library from the good-product image set by means of the defect recognition model; acquiring a textile image, and extracting an actual feature library from the textile image by means of the defect recognition model; comparing the actual feature library with the standard feature library, and on the basis of the comparison result, obtaining a candidate image set and a first defect image set; screening the candidate image set to obtain a second defect image set; on the basis of the first and second defect image sets, training the defect recognition model; and using the trained defect recognition model to perform recognition on the textile image. The method is cost-effective and highly feasible, and enables the recognition and collection of data without it being necessary to rely on a large amount of computing power and massive data sets.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, equipment and media for detecting surface defects in textiles

[0001] This application claims priority to Chinese Patent Application No. 2024118050901, filed on December 9, 2024, entitled "A method, apparatus, device and medium for detecting surface defects in textiles", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of textile surface defect inspection technology, and in particular to a textile surface defect detection method, a textile surface defect detection device, an electronic device, and a computer-readable storage medium. Background Technology

[0003] In related technologies, textile surface defect detection remains largely reliant on manual visual inspection. Challenges persist, including scarce defect data, time-consuming data collection, and the diverse types and materials of textiles, resulting in numerous and varied defect types, making practical implementation difficult. Current AI-based intelligent systems for textile surface defect detection primarily employ three technical approaches: large-scale visual models, AIGC-generated defect data, and a fusion of small models and traditional algorithms. The large-scale model approach is limited by the volume of textile defect data and actual deployment computing power, making engineering implementation challenging. The mainstream defect data generation technology relies on diffusion models, which can only control the location and outline of defects (based on image mask information), but cannot control the generation of defect textures. Furthermore, it introduces additional interference due to image style variations, raising questions about its practical engineering effectiveness. The small-model + traditional algorithm fusion approach is highly dependent on the amount of defect data, making project implementation timelines difficult to manage. Summary of the Invention

[0004] In view of the above problems, embodiments of this application are proposed to provide a method for detecting surface defects of textiles, a device for detecting surface defects of textiles, an electronic device, and a computer-readable storage medium that overcomes or at least partially solves the above problems.

[0005] To address the aforementioned problems, this application discloses a method for detecting surface defects in textiles, comprising:

[0006] Obtain a pre-trained defect recognition model and a set of good product images;

[0007] The defect identification model is used to extract a standard feature library from the set of good product images.

[0008] Acquire images of textile fabrics, and extract actual feature libraries from the textile fabric images using the defect recognition model;

[0009] The actual feature library is compared with the standard feature library, and a candidate image set and a first defect image set are obtained based on the comparison results.

[0010] A second set of defective images is obtained by filtering from the candidate image set;

[0011] The defect recognition model is trained based on the first defect image set and the second defect image set;

[0012] The trained defect recognition model is used to identify textile images.

[0013] In some embodiments, acquiring the textile image includes:

[0014] Deploy image acquisition equipment and calibrate the image acquisition equipment;

[0015] Obtain the corrected image of the textile fabric captured by the image acquisition device.

[0016] In some embodiments, the calibration of the image acquisition device includes:

[0017] The image acquisition device acquires a first preset index of the textile image and a first preset index of the calibration plate image.

[0018] Compare the first preset index of the textile image with the first preset index of the calibration plate image;

[0019] Based on the comparison results, the image acquisition device is refocused;

[0020] After the image acquisition device has focused, the second preset index of the textile image acquired by the image acquisition device and the second preset index of the correction plate image are obtained.

[0021] The second preset index of the textile image is compared with the second preset index of the calibration plate image;

[0022] Based on the comparison results, the image acquisition device is subjected to imaging correction.

[0023] In some embodiments, comparing the actual feature library with the standard feature library and obtaining a candidate image set and a first defect image set based on the comparison result includes:

[0024] If the difference between the actual feature library and the standard feature library is greater than a preset threshold, then the textile image corresponding to the actual feature library is added to the first defect image set;

[0025] If the difference between the actual feature library and the standard feature library is less than or equal to the preset threshold, then the textile image corresponding to the actual feature library is added to the candidate image set.

[0026] In some embodiments, the second set of defective images obtained from the candidate image set includes:

[0027] Contour features are extracted from the textile images in the candidate image set;

[0028] Based on the contour features of the textile image, determine whether the textile image has defects;

[0029] If the textile image has defects, the textile image is added to the second defect image set.

[0030] In some embodiments, training the defect recognition model based on the first defect image set and the second defect image set includes:

[0031] Obtain the labeled coordinates of each image in the first defective image set and the second defective image set;

[0032] Each image and its corresponding labeled coordinate in the first flawed image set and the second flawed image set are scaled to obtain a pyramid layer image and a set of corresponding labeled coordinates for each image.

[0033] Traverse each pyramid layer image, and cut the image of the same size with the labeled coordinates as the center area and the position randomly offset. At the same time, transform the labeled coordinates to the coordinates of the cut sub-images to obtain the processed defective image set.

[0034] The processed set of defective images is divided into a training set and a test set;

[0035] The defect recognition model is trained using the training set and the test set.

[0036] In some embodiments, training the defect recognition model using the training set and the test set includes:

[0037] The training set and the test set are classified according to the type of textile fabric to obtain multiple types of datasets;

[0038] The defect recognition model is trained on different types of datasets.

[0039] A second aspect of this application discloses a textile surface defect detection device, comprising:

[0040] The first acquisition module is configured to acquire a pre-trained defect recognition model and a set of good product images;

[0041] The standard feature extraction module is configured to extract a standard feature library from the good product image set through the defect recognition model;

[0042] The actual feature extraction module is configured to acquire textile images and extract an actual feature library from the textile images using the defect recognition model.

[0043] The comparison module is configured to compare the actual feature library with the standard feature library, and obtain a candidate image set and a first defect image set based on the comparison results;

[0044] The filtering module is configured to filter from the candidate image set to obtain a second set of defective images;

[0045] The training module is configured to train the defect recognition model based on the first defect image set and the second defect image set;

[0046] The recognition module is configured to use the trained defect recognition model to recognize textile images.

[0047] In some embodiments, the actual feature extraction module includes:

[0048] The calibration submodule is configured to deploy an image acquisition device and calibrate the image acquisition device.

[0049] The image acquisition submodule is configured to acquire the corrected image of the textile fabric captured by the image acquisition device.

[0050] In some embodiments, the correction submodule includes:

[0051] The first acquisition unit is configured to acquire a first preset index of the textile image acquired by the image acquisition device and a first preset index of the calibration plate image.

[0052] The first comparison unit is configured to compare a first preset index of the textile image with a first preset index of the correction plate image.

[0053] The focusing unit is configured to focus the image acquisition device based on the comparison result;

[0054] The second acquisition unit is configured to acquire a second preset index of the textile image acquired by the image acquisition device and a second preset index of the correction plate image after the image acquisition device has been focused.

[0055] The second comparison unit is configured to compare a second preset index of the textile image with a second preset index of the correction plate image.

[0056] The correction unit is configured to perform imaging correction on the image acquisition device based on the comparison results.

[0057] In some embodiments, the comparison module includes:

[0058] The first addition submodule is configured to add the textile image corresponding to the actual feature library to the first defect image set if the difference between the actual feature library and the standard feature library is greater than a preset threshold.

[0059] The second addition submodule is configured to add the textile image corresponding to the actual feature library to the candidate image set if the difference between the actual feature library and the standard feature library is less than or equal to the preset threshold.

[0060] In some embodiments, the filtering module includes:

[0061] The feature extraction submodule is configured to extract contour features from the textile images in the candidate image set;

[0062] The defect determination submodule is configured to determine whether there are defects in the textile image based on the contour features of the textile image.

[0063] The third addition submodule is configured to add the textile image to the second defect image set if the textile image has defects.

[0064] In some embodiments, the training module includes:

[0065] The coordinate annotation submodule is configured to obtain the annotation coordinates of each image in the first defective image set and the second defective image set;

[0066] The scaling submodule is configured to scale each image and its corresponding annotation coordinates in the first defective image set and the second defective image set respectively, to obtain the pyramid layer set image and the corresponding annotation coordinate set of each image;

[0067] The cutting submodule is configured to traverse each pyramid layer image, cut the image of the same size with the labeled coordinates as the center area and randomly offset the position, and at the same time transform the labeled coordinates to the coordinates of the cut sub-image to obtain the processed defective image set.

[0068] The classification submodule is configured to divide the processed set of defective images into a training set and a test set;

[0069] The training submodule is configured to train the defect recognition model using the training set and the test set.

[0070] In some embodiments, the training submodule includes:

[0071] The classification unit is configured to classify the training set and the test set according to the type of textile fabric, thereby obtaining datasets of multiple types;

[0072] The training unit is configured to train the defect recognition model based on different types of datasets.

[0073] A third aspect of this application discloses an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the textile surface defect detection method as described above.

[0074] A fourth aspect of this application discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of detecting surface defects in textiles as described above.

[0075] The embodiments of this application have the following advantages:

[0076] This application describes a method for detecting surface defects in textiles. The method involves acquiring a pre-trained defect recognition model and a set of good product images; then, using the defect recognition model, extracting a standard feature library from the good product image set; acquiring textile images and extracting an actual feature library from the textile images using the defect recognition model; comparing the actual feature library with the standard feature library to obtain a candidate image set and a first defect image set; selecting a second defect image set from the candidate image set; training the defect recognition model based on the first and second defect image sets; and using the trained defect recognition model to recognize textile images. This method is low-cost, highly feasible, and does not require high computing power or massive datasets to operate and collect data. It can deploy corresponding personalized, high-precision detection models using a small amount of defect data for different customers and different textile models. It enables hourly iteration and deployment of personalized models for different specifications and models of textiles, greatly optimizing the project deployment cycle. Attached Figure Description

[0077] Figure 1 is a flowchart of the steps of a method for detecting surface defects in textiles provided in an embodiment of this application;

[0078] Figure 2 is a flowchart of another method for detecting surface defects in textiles provided in an embodiment of this application;

[0079] Figure 3 is a schematic diagram of a focus-defocus correction plate for a textile surface defect detection method provided in an embodiment of this application.

[0080] Figure 4 is a schematic diagram of a textile correction plate for a textile surface defect detection method provided in an embodiment of this application;

[0081] Figure 5 is a diagram of the annotation tool interface of a textile surface defect detection method provided in an embodiment of this application;

[0082] Figure 6 is an interface diagram of an incremental self-training tool for a textile surface defect detection method provided in an embodiment of this application;

[0083] Figure 7 is a structural block diagram of a textile surface defect detection device provided in an embodiment of this application. Detailed Implementation

[0084] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, this application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0085] One of the core concepts of this application is that, without requiring large computing resources such as computing power and large amounts of data, and without incurring time costs, a one-stop, rapidly deployable intelligent system for detecting surface defects in textiles is proposed using a pre-trained model + full-link toolchain technical approach. This system can quickly deploy corresponding personalized, high-precision detection models for different customers and different textile models using a small amount of defect data.

[0086] Referring to Figure 1, a flowchart of a method for detecting surface defects in textiles according to an embodiment of this application is shown. The method may specifically include the following steps:

[0087] Textile surface defect detection technology plays a crucial role in improving product quality and production efficiency in the modern textile industry. In particular, machine vision detection, which uses cameras and image processing algorithms to automatically detect defects on textile surfaces, is increasingly being used in textile defect detection. This includes traditional image processing-based detection using edge detection, morphological operations, threshold segmentation, and other traditional image processing techniques, as well as deep learning models such as Convolutional Neural Networks (CNNs) for automatic learning and defect recognition. Deep learning-based detection is gradually replacing traditional manual inspection methods.

[0088] Step 101: Obtain the pre-trained defect recognition model and the set of good product images;

[0089] Textile defect detection data collection is fundamental to building an efficient defect detection system. High-quality data collection can significantly improve model training effectiveness and detection accuracy. However, textile data collection typically faces industry challenges such as long lead times, limited data volumes, and high labor costs.

[0090] In some instances of this application, a CNN model pre-trained on ImageNet is first used as the backbone weights of the model to obtain a pre-trained defect recognition model.

[0091] ImageNet is a large-scale image classification dataset containing over 14 million images across more than 1,000 categories. Widely used for training and evaluating image classification models, ImageNet is a crucial benchmark dataset in the field of deep learning.

[0092] Pre-trained CNN models refer to convolutional neural network models that have been pre-trained on the ImageNet dataset. Convolutional Neural Networks (CNNs) are deep learning models particularly well-suited for processing data with a grid-like structure, such as images and videos. CNNs extract features from input data through components such as convolutional layers, pooling layers, and fully connected layers, and perform tasks such as classification, detection, and segmentation. Typical CNN model structures include multiple convolutional layers, pooling layers, and fully connected layers, such as LeNet, AlexNet, VGG, and ResNet. CNN models typically have a hierarchical structure, with shallow convolutional layers extracting low-level features (such as edges and textures) and deep convolutional layers extracting high-level features (such as object parts or the whole object). These models have learned rich feature representations on the ImageNet dataset and can serve as base models for various downstream tasks.

[0093] Backbone weights refer to the weight parameters of the backbone network, which determine the model's feature extraction capability and performance. Using pre-trained backbone weights can significantly improve model performance, especially with limited data. Methods such as pre-trained weights, weight transfer, and weight fine-tuning can significantly improve model performance and generalization ability.

[0094] The pre-trained defect recognition model obtained in this way only requires a small amount of good product image data to start a rapid cold start, and continuously collects real-world textile images to identify defects while acquiring image data. Good product image sets are readily available in existing databases, and only a small amount of good product image data is needed, thus allowing the system to be operational online in a short period.

[0095] Step 102: Extract a standard feature library from the set of good product images using the defect recognition model;

[0096] The acquired good product image set data is used as the training set. The shallow features of the good product image set images are processed by strategies such as recombination, merging, and downsampling to obtain a standard feature library, which serves as a standard reference for the defect recognition model to identify defects and anomalies in the future.

[0097] Shallow feature extraction refers to extracting shallow features from raw data, such as pixel values ​​of images, word frequencies of text, and statistics of time series. When selecting features, select those that have an important impact on the task and remove redundant and irrelevant features.

[0098] Feature recombination includes feature combination and feature transformation. Feature combination combines multiple shallow features to generate new features. For example, combining the pixel values ​​of an image with edge detection results generates new image features. Feature transformation involves transforming features, such as logarithmic transformation, square transformation, normalization, etc., to enhance the expressive power of the features.

[0099] Feature merging includes feature concatenation and feature fusion. Feature concatenation refers to concatenating multiple feature vectors column by column to generate a longer feature vector. For example, concatenating the color features and texture features of an image together. Feature fusion uses methods such as weighted average, maximum value, and minimum value to merge multiple features into one feature.

[0100] Feature downsampling first uses dimensionality reduction methods (such as PCA, t-SNE, UMAP, etc.) to reduce the dimensionality of high-dimensional features, and then samples the features, such as random sampling, hierarchical sampling, etc., to reduce the number of features.

[0101] Creating a standard feature library involves storing the recombined, merged, and downsampled feature sets in a standardized library for easy use in subsequent tasks. A standard feature library simplifies the feature engineering process, reduces repetitive work, and improves development efficiency. It allows for region-by-region comparison of images of textiles to be inspected, identifying anomalous areas and obtaining a set of defect data images.

[0102] Step 103: Obtain a textile image and extract the actual feature library from the textile image using the defect recognition model;

[0103] The defect recognition model is enabled to collect online data in real time. The collected real-time textile image data is processed according to the standard feature library production method in step 102, and shallow features are recombined, merged, downsampled and other strategies are used to obtain the actual feature library.

[0104] Fabric surface defect detection faces persistent challenges, including scarce defect data, time-consuming data collection, and the diverse types and materials of textiles, resulting in a wide variety of defect types. This makes practical implementation of the technology difficult. Shallow features, typically basic characteristics of the original data such as edges, textures, and colors, while simple, often lack sufficient expressive power to describe complex data patterns. Recombination, merging, and downsampling strategies can combine these shallow features into higher-level features, thereby improving their expressive power. Through feature recombination, merging, and downsampling, more expressive feature sets can be generated, improving model performance and generalization ability.

[0105] Step 104: Compare the actual feature library with the standard feature library, and obtain the candidate image set and the first defect image set based on the comparison results;

[0106] The features extracted from the online real-time acquired textile images are compared region by region with a standard feature library according to the actual feature library. Images determined to have defects are assigned to the first defect image set, while those determined to be defect-free are assigned to the candidate image set. Images determined to be defect-free by the defect detection model are not classified as good products because this detection method needs to maintain a low false positive rate; a high number of false positives would affect the online operation of the system, but it tolerates false negatives. Therefore, some images not judged as defect-free may not actually be defect-free and could be missed detections; these are assigned to the candidate image set for further inspection and judgment.

[0107] Step 105: Filter from the candidate image set to obtain a second set of defective images;

[0108] After the defect recognition model collects and judges a certain amount of online image data, a certain amount of online defect data can be obtained and included in the first defect image set. However, some defect data is also missed. For the missed image data, it is necessary to perform another detection and filtering to obtain a certain amount of defect data. Because there are many images of good products in the existing database, but relatively few images of defects, this step can obtain more defect image data and include it in the second defect image set.

[0109] Step 106: Train the defect recognition model based on the first defect image set and the second defect image set;

[0110] Generally, the training process for textile defect detection models typically involves steps such as data preparation, model selection, model training, model evaluation, and model optimization. The most challenging aspect of data collection is gathering images of textiles containing different types of defects (such as broken yarns, oil stains, holes, color differences, etc.). This problem has already been addressed by obtaining sample data of defect image sets through the previous steps. Next, data annotation is performed using image annotation tools (such as LabelImg, VGG Image Annotator, etc.) to mark the location and type of defects. Image enhancement involves processing the images, such as rotation, scaling, translation, and brightness adjustment, to increase data diversity. Data segmentation divides the dataset into training, validation, and test sets, with proportions set to 70%, 15%, 15%, etc.

[0111] Regarding model selection, traditional machine learning models such as Support Vector Machines (SVM) and Random Forests, or deep learning models such as Convolutional Neural Networks (CNN), U-Net, YOLO, and Faster R-CNN, can generally be used for model training. In some embodiments of this application, the preceding steps have already yielded the desired defect recognition model.

[0112] Next, model training is performed. The general training process includes: initializing model parameters; inputting training data and calculating output; calculating loss based on output and true labels; calculating gradient and updating model parameters; iterative training, repeating the above steps until the model converges or reaches the predetermined number of training rounds.

[0113] Step 107: Use the trained defect recognition model to identify the textile image.

[0114] The trained defect recognition model is used to determine defects in actual textile images, thereby identifying defects. If the trained model needs optimization, it can be further optimized by collecting data while recognizing actual images from different manufacturers and categories.

[0115] Referring to Figure 2, a flowchart of another method for detecting surface defects in textiles provided in this application is shown. The method may specifically include the following steps:

[0116] Step 201: Obtain the pre-trained defect recognition model and the set of good product images;

[0117] In some examples of this application, unsupervised cold start online real-time data acquisition is first employed. Unsupervised cold start, simply put, is equivalent to industrial anomaly detection, typically a binary classification problem. It involves classifying each region of a textile image into binary categories to identify abnormal areas. Unsupervised cold start online real-time data acquisition refers to the real-time acquisition and processing of online data using unsupervised learning methods without pre-labeled data to achieve system initialization and startup. This method is commonly used in recommendation systems, anomaly detection, and user behavior analysis scenarios.

[0118] In some instances of this application, the system first uses a CNN model pre-trained on ImageNet as the backbone weights of the model, and selects a small number of good images as the training set to obtain a pre-trained defect recognition model.

[0119] Step 202: Extract a standard feature library from the set of good product images using the defect recognition model;

[0120] The acquired good product image set data is used as the training set. The shallow features of the good product image set images are processed by strategies such as recombination, merging, and downsampling to obtain a standard feature library, which serves as a standard reference for the defect recognition model to identify defects and anomalies in the future.

[0121] Step 203: Obtain a textile image and extract the actual feature library from the textile image using the defect recognition model;

[0122] In some embodiments of this application, step 203 includes the following sub-steps:

[0123] Sub-step S11: Deploy the image acquisition device and calibrate the image acquisition device;

[0124] Imaging quality is crucial for ensuring that the inspection system can accurately and reliably identify and classify defects in textile surface defect detection. Imaging quality is affected by a variety of factors, including the light source, camera, lens, and environmental conditions.

[0125] In this embodiment, multiple sets of devices are used, which can be applied to different textile manufacturers. Each device has two to four cameras. The deployed image acquisition devices are industrial cameras. The imaging quality of the industrial cameras and the consistency of images from multiple industrial cameras directly affect the detection effect of subsequent link algorithms. In order to squeeze out the optimal performance of the hardware imaging system, this system proposes an imaging quality assessment tool. This tool uses image quality assessment quantification indicators to ensure image clarity and consistency from two different dimensions.

[0126] In one embodiment of this application, sub-step S11 further includes the following sub-step:

[0127] Sub-step S111: Obtain the first preset index of the textile image acquired by the image acquisition device and the first preset index of the calibration plate image;

[0128] First, we measure whether the industrial camera is in focus using quantitative indicators. We select Brenner gradient, Tenengrad gradient, Laplacian gradient, variance function, etc. as indicators to measure image sharpness, which are the first preset indicators.

[0129] Brenner gradient is a simple method for evaluating image sharpness by calculating the difference between adjacent pixels to measure image sharpness.

[0130] Tenengrad gradient is an image sharpness evaluation method based on the Sobel operator. It measures image sharpness by calculating the gradient magnitude. Tenengrad gradient is sensitive to edges and can detect edge information in images well. Its computational complexity is moderate. Compared with Brenner gradient, it is slightly more computationally complex, but still relatively fast. It is suitable for more complex image sharpness evaluation tasks.

[0131] The Laplacian gradient is an image sharpness assessment method based on the Laplacian operator, which measures image sharpness by calculating the second derivative of the image. The Laplacian gradient is sensitive to detail and can detect detailed information in images well; however, it has higher computational complexity compared to the previous two methods. It is suitable for tasks requiring high-precision image sharpness assessment.

[0132] Referring to Figure 3, a schematic diagram of a focus-defocus correction plate for a textile surface defect detection method provided in this application is shown. Using this focus-defocus correction plate as the object to be photographed, an industrial camera is used to acquire its image, and the Brenner gradient, Tenengrad gradient, Laplacian gradient, variance, and other indices of the image are calculated. Simultaneously, the standard correction plate pattern corresponds to the Brenner gradient, Tenengrad gradient, Laplacian gradient, variance, and other indices.

[0133] Sub-step S112: Compare the first preset index of the textile image with the first preset index of the correction plate image;

[0134] The calculated Brenner gradient, Tenengrad gradient, Laplacian gradient, variance, and other indicators of the textile image are compared one by one with the corresponding indicators (benchmark indicators) of the standard correction plate pattern. If the mean absolute value of the deviation of all indicators is less than 2% and the maximum absolute value of the deviation is less than 5%, then the industrial camera is considered to have good focusing and the image clarity meets the requirements.

[0135] Sub-step S113: Based on the comparison result, focus the image acquisition device;

[0136] All industrial cameras on the equipment should be focused using the above method, and the image consistency should be confirmed after the focus is confirmed.

[0137] Sub-step S114: After the image acquisition device has been focused, acquire the second preset index of the textile image acquired by the image acquisition device and the second preset index of the correction plate image.

[0138] Referring to Figure 4, a schematic diagram of a textile correction plate is shown in an embodiment of this application for a method of detecting surface defects in textiles. After ensuring that the industrial camera is focused and the image is clear through the above steps, the same textile correction plate is used as the subject for the focused industrial camera, and its image is acquired. The second preset index is calculated for each. There can be multiple second preset indices, including quantitative indices such as histogram, color difference (CIE2000), mean square error, and peak signal-to-noise ratio.

[0139] Simultaneously, an industrial camera that has already been focused is used to acquire images of the collected textiles, and the values ​​of corresponding second preset indicators, such as histogram, color difference (CIE2000), mean square error, peak signal-to-noise ratio, and other quantitative indicators, are calculated.

[0140] Sub-step S115: Compare the second preset index of the textile image with the second preset index of the correction plate image;

[0141] If, after comparing the second preset index of the textile image with the second preset index of the textile correction plate image one-to-one, the mean absolute value of all index deviations is less than 2% and the maximum absolute value of deviation is less than 5%, then the imaging consistency of the industrial camera is considered to meet the requirements.

[0142] Sub-step S116: Based on the comparison results, perform imaging correction on the image acquisition device.

[0143] By verifying both focus and imaging consistency, two comparison methods can be used to ensure that each industrial camera is in good focus and that the imaging consistency between different industrial cameras meets the requirements. Meeting the imaging consistency requirement means evaluating the imaging quality consistency of different cameras using the same correction plate (such as a checkerboard or grid plate) as a reference object to evaluate and compare the imaging quality of multiple cameras, ensuring that these cameras have consistent imaging quality.

[0144] Sub-step S12: Obtain the corrected image of the textile captured by the image acquisition device.

[0145] Evaluating the consistency of imaging quality across different cameras using the same calibration plate ensures consistency in imaging quality across multi-camera systems, improving overall system performance. In multi-camera systems, consistent imaging quality is crucial for tasks such as image stitching and 3D reconstruction, and this method allows for effective calibration and debugging. In production environments, this method enables quality control of different batches of cameras, ensuring product consistency and reliability.

[0146] Once the defect recognition model is activated, the image acquisition device, namely the industrial camera, which has been confirmed to have focused and image consistency, begins to collect textile image data online in real time. The collected real-time textile image data is then processed according to the standard feature library creation method in step 202, using strategies such as recombination, merging, and downsampling of shallow features to obtain the actual feature library.

[0147] Step 204: Compare the actual feature library with the standard feature library, and obtain the candidate image set and the first defect image set based on the comparison results;

[0148] In some embodiments of this application, step 204 includes the following sub-steps:

[0149] Sub-step S21: If the difference between the actual feature library and the standard feature library is greater than a preset threshold, then add the textile image corresponding to the actual feature library to the first defect image set.

[0150] The collected textile images may be large. In order to detect comprehensively, the actual feature library obtained by processing the collected textile images is compared with the standard feature library region by region. When the difference is greater than a preset threshold, the region is determined to be an abnormal region. The textile image corresponding to the image containing the abnormal region is added to the first defect image set. The first defect image set is an important sample data for subsequent model training.

[0151] Sub-step S22: If the difference between the actual feature library and the standard feature library is less than or equal to the preset threshold, then the textile image corresponding to the actual feature library is added to the candidate image set.

[0152] In addition to textile images corresponding to the actual feature library whose difference from the standard feature library is less than or equal to a preset threshold, which need to be added to the candidate image set, there may also be some textile images that were missed. These missed textile images also need to be added to the candidate image set. Because there are fewer defective image data samples than good product image data, the candidate image set needs to be re-examined to obtain defective image data.

[0153] Unsupervised cold start online real-time data acquisition allows for rapid cold start with only a small amount of good product data, enabling the system to run online in a short period and acquire some textile data with real defects. However, while maintaining a low false detection rate, unsupervised detection models tolerate missed detections; these missed defect data are randomly distributed across a massive amount of textile photos.

[0154] Step 205: Filter from the candidate image set to obtain a second set of defective images;

[0155] Even though filtering out defective images from a candidate image set is an extremely labor-intensive step, taking a roll of woven fabric 2 meters wide and 100 meters long as an example, two industrial cameras, each capturing two images at 0.125-meter intervals, would require collecting 1600 images. With the equipment operating at 60 meters per minute, running for 8 hours a day, covering 28,000 meters, and collecting over 460,000 images, manually reviewing each one would be extremely difficult. Therefore, a combination of traditional algorithm-based automatic initial defect screening followed by manual review is adopted for the final selection.

[0156] In some embodiments of this application, step 205 includes the following sub-steps:

[0157] Sub-step S31: Extract contour features from the textile images in the candidate image set;

[0158] Traditional algorithms for detecting surface defects in textiles mainly rely on image processing and pattern recognition techniques. These algorithms typically include several steps such as image preprocessing, feature extraction, feature selection, and classification.

[0159] Image preprocessing includes: grayscale conversion, which converts the color image to grayscale to reduce computational complexity; filtering, which smooths the image using mean filters (e.g., 3x3, 5x5) to remove noise; smoothing the image using Gaussian filters to preserve edge information; and removing salt-and-pepper noise using median filters; and edge detection, which uses the Sobel operator to detect horizontal and vertical edges in the image, and the Canny operator to detect edges and perform edge concatenation and thinning.

[0160] Feature extraction includes: Gray-level co-occurrence matrix (GLCM), which calculates the GLCM of gray levels in the image to extract texture features, such as energy, contrast, correlation, and entropy. Local binary mode (LBP) analysis compares each pixel in the image with its neighboring pixels to generate a binary mode, with features including an LBP histogram describing local texture features. Gabor filter analysis uses Gabor filters to extract texture features of the image at different scales and orientations, with features describing the image's texture information based on the Gabor filter response.

[0161] Feature selection includes: Principal Component Analysis (PCA), which projects the original features into a low-dimensional space through linear transformation, preserving key information; and Linear Discriminant Analysis (LDA), which projects the original features into a low-dimensional space through linear transformation, maximizing inter-class distance and minimizing intra-class distance.

[0162] The classification methods include: Support Vector Machine (SVM) method, which separates samples of different classes by finding the optimal hyperplane; K-Nearest Neighbor (KNN) method, which selects the K nearest neighbors for classification based on the distance between samples in the feature space; and Random Forest method, which improves classification performance by constructing multiple decision trees and performing ensemble learning.

[0163] In some instances of this application, traditional algorithms require extracting basic image contour features such as gradient changes, frequency domain changes, and grayscale jumps from the candidate image set for subsequent selection by automated tools.

[0164] Sub-step S32: Determine whether there are defects in the textile image based on the contour features of the textile image;

[0165] The process involves selecting images using automated tools based on traditional algorithms, followed by a second review. Only images deemed defective by human review are considered truly defective. For example, in step 205, over 460,000 images of a woven fabric roll (2 meters wide and 100 meters long) are collected. From these massive images, several thousand images with the largest feature jumps are selected as potential defect data. These images are then manually reviewed one by one to confirm the final defective result.

[0166] Sub-step S33: If the textile image has defects, then add the textile image to the second defect image set.

[0167] The textile images corresponding to the defect data that were screened out by the traditional algorithm for initial defect screening and manual review were added to the second defect image set, which is also an important sample data for subsequent model training.

[0168] Step 206: Obtain the labeled coordinates of each image in the first defective image set and the second defective image set; scale each image and its corresponding labeled coordinates in the first and second defective image sets respectively to obtain a pyramid layer image and a corresponding set of labeled coordinates for each image; traverse each pyramid layer image, and cut the image into the same size with the labeled coordinates as the center area and a random offset position, while converting the labeled coordinates to the coordinates of the cut sub-images to obtain the processed defective image set; divide the processed defective image set into a training set and a test set; use the training set and the test set to train the defect recognition model;

[0169] Textile defects are typically very small, especially warp and weft defects, which are usually caused by damage to a single yarn. The industry typically uses high-resolution cameras to capture these images. However, the high-resolution images of small defect areas cannot be directly fed into the model for training; the data preprocessing method significantly impacts the model's final detection performance.

[0170] Using a pyramid-shaped image processing method, centered on the defect area, to preprocess high-resolution images is an effective way to improve the efficiency and accuracy of defect detection. Image pyramids are a multi-scale representation method that generates images of different resolutions through layer-by-layer downsampling, facilitating defect detection at various scales.

[0171] On each layer of the pyramid image, regions potentially containing defects are detected. First, a feature extraction algorithm is used to extract features from each layer of the pyramid image; that is, feature points are detected on each layer, and then these detected feature points are described to generate feature vectors. Next, defect region localization is performed. A classification algorithm is used to classify the feature vectors to locate regions that may contain defects. Feature classification involves inputting the feature vectors into a classifier to determine whether they contain defects. Region localization then locates regions that may contain defects based on the classification results.

[0172] After detecting defective areas, the image is segmented around these areas to generate sub-images containing the defects. The segmentation method involves determining the cutting center point based on the center coordinates of the defective area; then, sub-images of fixed sizes are cut out centered on this center point; the segmented sub-images undergo enhancement processing, such as contrast and brightness adjustment, to improve the visibility of the defects. Finally, defect detection and classification are performed on the segmented sub-images to identify the specific defect types.

[0173] In some real-time examples of this application, the specific operations can be as follows: First, scale each image proportionally while maintaining different aspect ratios to obtain the pyramid layer image set for that image; second, scale the labeled information (coordinates) proportionally to obtain the labeled information set for the pyramid layer image set; third, traverse each pyramid layer image set, obtain its labeled coordinates, and cut the image into segments of the same size with the labeled coordinates as the center area and a random offset position, while converting the labeled information coordinates to the coordinates of the cut sub-images; finally, traverse all training and test set images and repeat the previous three steps.

[0174] In some embodiments of this application, step 206 includes the following sub-steps:

[0175] Sub-step S41: Classify the training set and the test set according to the type of textile fabric to obtain multiple types of datasets;

[0176] Textiles come in a wide variety of types and materials and are frequently replaced (production scheduling is unpredictable). However, textiles within the same major category share similar basic characteristics. Therefore, this system abstracts and merges datasets for major textile categories, such as knitted and woven fabrics; it also abstracts and merges defect categories with similar defect characteristics to create large-category datasets. This allows the previously collected data sample image sets to be categorized into multiple types of datasets according to different major classifications.

[0177] Sub-step S42 involves training the defect recognition model based on different types of datasets.

[0178] Training models on each major category dataset yields pre-trained "large" defect recognition models for different major categories. However, since each textile manufacturer's customers have different batch sizes and specifications, to adapt the defect recognition models to the textile inspection needs of each manufacturer's customers, the pre-trained "large" defect recognition models need to be incrementally trained into personalized models. Furthermore, for scenarios where textile manufacturers frequently switch fabric sizes and specifications, rapid deployment of personalized models within hours is also required.

[0179] This application embodiment can use a pre-trained defect recognition "large" model trained on different large category data machines as the initial backbone weight of the personalized model for each fabric model. It can collect a small amount of defect data of textiles under the model required by the manufacturer's customers, and realize hourly personalized model deployment with one click through annotation tools and incremental self-training tools. The model has a small amount of data and can quickly achieve overfitting (high model accuracy) for the fabric model, but at the same time, it has poor compatibility with other fabric models.

[0180] Referring to Figure 5, which shows the interface of the annotation tool for a textile surface defect detection method provided in this application embodiment, experienced fabric inspectors can quickly complete the annotation of a small amount of defect data by using the tool's one-click pre-annotation function and annotation area correction for new specifications of fabric models.

[0181] Regarding the incremental training strategy with few samples, Figure 6 shows the interface of an incremental self-training tool for a textile surface defect detection method provided in this application embodiment. The tool uses a pre-trained defect recognition "large" model as the initial backbone weight for the personalized model of each fabric model, and collects a small amount of defect data of textiles of the model required by the manufacturer's customers. It can realize one-click hourly model iteration and deployment.

[0182] Step 207: Use the trained defect recognition model to recognize the textile image.

[0183] The trained defect recognition model can not only identify textile images from different manufacturers, but also enable one-click deployment of personalized, high-precision models within hours by only maintaining and updating the pre-trained "large" model and toolchain.

[0184] This application describes a method for detecting surface defects in textiles. The method involves acquiring a pre-trained defect recognition model and a set of good product images; then, using the defect recognition model, extracting a standard feature library from the good product image set; acquiring textile images and extracting an actual feature library from the textile images using the defect recognition model; comparing the actual feature library with the standard feature library to obtain a candidate image set and a first defect image set; selecting a second defect image set from the candidate image set; training the defect recognition model based on the first and second defect image sets; and using the trained defect recognition model to recognize textile images. This method is low-cost, highly feasible, and does not require high computing power or massive datasets to operate and collect data. It can deploy corresponding personalized, high-precision detection models using a small amount of defect data for different customers and different textile models. It enables hourly iteration and deployment of personalized models for different specifications and models of textiles, greatly optimizing the project deployment cycle.

[0185] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.

[0186] Referring to Figure 7, a structural block diagram of a textile surface defect detection device provided in an embodiment of this application is shown, which may specifically include the following modules:

[0187] The first acquisition module 701 is configured to acquire a pre-trained defect recognition model and a set of good product images;

[0188] The standard feature extraction module 702 is configured to extract a standard feature library from the good product image set through the defect recognition model;

[0189] The actual feature extraction module 703 is configured to acquire a textile image and extract an actual feature library from the textile image using the defect recognition model.

[0190] The comparison module 704 is configured to compare the actual feature library with the standard feature library, and obtain a candidate image set and a first defect image set based on the comparison result;

[0191] The filtering module 705 is configured to filter from the candidate image set to obtain a second defect image set;

[0192] The training module 706 is configured to train the defect recognition model based on the first defect image set and the second defect image set;

[0193] The recognition module 707 is configured to use the trained defect recognition model to recognize textile images.

[0194] In some embodiments of this application, the actual feature extraction module includes:

[0195] The calibration submodule is configured to deploy an image acquisition device and calibrate the image acquisition device.

[0196] The image acquisition submodule is configured to acquire the corrected image of the textile fabric captured by the image acquisition device.

[0197] In some embodiments of this application, the correction submodule includes:

[0198] The first acquisition unit is configured to acquire a first preset index of the textile image acquired by the image acquisition device and a first preset index of the calibration plate image.

[0199] The first comparison unit is configured to compare a first preset index of the textile image with a first preset index of the correction plate image.

[0200] The focusing unit is configured to focus the image acquisition device based on the comparison result;

[0201] The second acquisition unit is configured to acquire a second preset index of the textile image acquired by the image acquisition device and a second preset index of the correction plate image after the image acquisition device has been focused.

[0202] The second comparison unit is configured to compare a second preset index of the textile image with a second preset index of the correction plate image.

[0203] The correction unit is configured to perform imaging correction on the image acquisition device based on the comparison results.

[0204] In some embodiments of this application, the comparison module includes:

[0205] The first addition submodule is configured to add the textile image corresponding to the actual feature library to the first defect image set if the difference between the actual feature library and the standard feature library is greater than a preset threshold.

[0206] The second addition submodule is configured to add the textile image corresponding to the actual feature library to the candidate image set if the difference between the actual feature library and the standard feature library is less than or equal to the preset threshold.

[0207] In some embodiments of this application, the filtering module includes:

[0208] The feature extraction submodule is configured to extract contour features from the textile images in the candidate image set;

[0209] The defect determination submodule is configured to determine whether there are defects in the textile image based on the contour features of the textile image.

[0210] The third addition submodule is configured to add the textile image to the second defect image set if the textile image has defects.

[0211] In some embodiments of this application, the training module includes:

[0212] The coordinate annotation submodule is configured to obtain the annotation coordinates of each image in the first defective image set and the second defective image set;

[0213] The scaling submodule is configured to scale each image and its corresponding annotation coordinates in the first defective image set and the second defective image set respectively, to obtain the pyramid layer set image and the corresponding annotation coordinate set of each image;

[0214] The cutting submodule is configured to traverse each pyramid layer image, cut the image of the same size with the labeled coordinates as the center area and randomly offset the position, and at the same time transform the labeled coordinates to the coordinates of the cut sub-image to obtain the processed defective image set.

[0215] The classification submodule is configured to divide the processed set of defective images into a training set and a test set;

[0216] The training submodule is configured to train the defect recognition model using the training set and the test set.

[0217] In some embodiments of this application, the training submodule includes:

[0218] The classification unit is configured to classify the training set and the test set according to the type of textile fabric, thereby obtaining datasets of multiple types;

[0219] The training unit is configured to train the defect recognition model based on different types of datasets.

[0220] This application describes a textile surface defect detection device. It acquires a pre-trained defect recognition model and a set of good product images; then, the defect recognition model extracts a standard feature library from the good product image set; it acquires textile images and extracts an actual feature library from the textile images using the defect recognition model; it compares the actual feature library with the standard feature library, and obtains a candidate image set and a first defect image set based on the comparison results; it selects a second defect image set from the candidate image set; it trains the defect recognition model based on the first and second defect image sets; and it uses the trained defect recognition model to recognize textile images. This method is low-cost, highly feasible, and does not require high computing power or massive datasets to operate and collect data. It can deploy corresponding personalized, high-precision detection models using a small amount of defect data for different customers and different textile models; it can achieve hourly iteration and deployment of personalized models for different specifications and models of textiles, greatly optimizing the project deployment cycle.

[0221] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0222] This application also provides an electronic device, including:

[0223] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described embodiments of the textile surface defect detection method and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0224] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described textile surface defect detection method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0225] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0226] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0227] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.

[0228] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.

[0229] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.

[0230] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.

[0231] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0232] The above provides a detailed description of a method and apparatus for detecting surface defects in textiles. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for detecting surface defects in textiles, comprising: Obtain a pre-trained defect recognition model and a set of good product images; The defect identification model is used to extract a standard feature library from the set of good product images. Acquire images of textile fabrics, and extract actual feature libraries from the textile fabric images using the defect recognition model; The actual feature library is compared with the standard feature library, and a candidate image set and a first defect image set are obtained based on the comparison results. A second set of defective images is obtained by filtering from the candidate image set; The defect recognition model is trained based on the first defect image set and the second defect image set; The trained defect recognition model is used to identify textile images.

2. The method according to claim 1, wherein, The acquisition of textile images includes: Deploy image acquisition equipment and calibrate the image acquisition equipment; Obtain the corrected image of the textile fabric captured by the image acquisition device.

3. The method according to claim 2, wherein, The calibration of the image acquisition device includes: The image acquisition device acquires a first preset index of the textile image and a first preset index of the calibration plate image. Compare the first preset index of the textile image with the first preset index of the calibration plate image; Based on the comparison results, the image acquisition device is refocused; After the image acquisition device has focused, the second preset index of the textile image acquired by the image acquisition device and the second preset index of the correction plate image are obtained. The second preset index of the textile image is compared with the second preset index of the calibration plate image; Based on the comparison results, the image acquisition device is subjected to imaging correction.

4. The method according to claim 1, wherein, The step of comparing the actual feature library with the standard feature library, and obtaining a candidate image set and a first defect image set based on the comparison results, includes: If the difference between the actual feature library and the standard feature library is greater than a preset threshold, then the textile image corresponding to the actual feature library is added to the first defect image set; If the difference between the actual feature library and the standard feature library is less than or equal to the preset threshold, then the textile image corresponding to the actual feature library is added to the candidate image set.

5. The method according to claim 1, wherein, The second set of defective images obtained from the candidate image set includes: Contour features are extracted from the textile images in the candidate image set; Based on the contour features of the textile image, determine whether the textile image has defects; If the textile image has defects, the textile image is added to the second defect image set.

6. The method according to claim 1, wherein, The step of training the defect recognition model based on the first defect image set and the second defect image set includes: Obtain the labeled coordinates of each image in the first defective image set and the second defective image set; Each image and its corresponding labeled coordinate in the first flawed image set and the second flawed image set are scaled to obtain a pyramid layer image and a set of corresponding labeled coordinates for each image. Traverse each pyramid layer image, and cut the image of the same size with the labeled coordinates as the center area and the position randomly offset. At the same time, transform the labeled coordinates to the coordinates of the cut sub-images to obtain the processed defective image set. The processed set of defective images is divided into a training set and a test set; The defect recognition model is trained using the training set and the test set.

7. The method according to claim 6, wherein, The step of training the defect recognition model using the training set and the test set includes: The training set and the test set are classified according to the type of textile fabric to obtain multiple types of datasets; The defect recognition model is trained on different types of datasets.

8. The method according to claim 1, wherein, The process of obtaining the pre-trained defect recognition model includes: A convolutional neural network (CNN) model pre-trained on the ImageNet dataset is used, and its weights are used as the backbone network weights of the defect recognition model.

9. The method according to claim 3, wherein, The first preset index includes at least one selected from the group consisting of: Brenner gradient, Tenengrad gradient, Laplacian gradient, and variance function.

10. The method according to claim 6, characterized in that, The step of training the defect recognition model based on the first defect image set and the second defect image set further includes: Multi-scale scaling is performed on images in the first and second defective image sets to generate an image pyramid; and The image is segmented using the labeled coordinates of each layer of the image pyramid as the center to obtain sub-images for training.

11. A device for detecting surface defects in textiles, comprising: The first acquisition module is configured to acquire a pre-trained defect recognition model and a set of good product images; The standard feature extraction module is configured to extract a standard feature library from the good product image set through the defect recognition model; The actual feature extraction module is configured to acquire textile images and extract an actual feature library from the textile images using the defect recognition model. The comparison module is configured to compare the actual feature library with the standard feature library, and obtain a candidate image set and a first defect image set based on the comparison results; The filtering module is configured to filter from the candidate image set to obtain a second set of defective images; The training module is configured to train the defect recognition model based on the first defect image set and the second defect image set; The recognition module is configured to use the trained defect recognition model to recognize textile images.

12. An electronic device, comprising: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the textile surface defect detection method as described in any one of claims 1-10.

13. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the textile surface defect detection method as described in any one of claims 1-10.