Fabric surface defect detection method and related apparatus

By combining a pre-trained general unsupervised defect detection model with class matching and center offset discrimination modules, the problems of high memory consumption and difficult deployment of general unsupervised detection methods are solved, and efficient fabric surface defect detection is achieved on resource-constrained devices.

CN119810058BActive Publication Date: 2025-11-21INST OF AUTOMATION CHINESE ACAD OF SCI
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411880405.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-11-21
Estimated Expiration
2044-12-19

AI Technical Summary

Technical Problem

Existing general unsupervised defect detection methods suffer from high memory consumption, high deployment difficulty, and difficulty in achieving real-time detection on resource-limited devices, especially in embedded devices or low-power environments. Furthermore, their detection accuracy is insufficient in multi-category detection scenarios.

Method used

A pre-trained general unsupervised defect detection model is adopted, which combines a category matching module, a patch matching module, and a center offset discrimination module. The defect location result is directly given by the feature discriminator, which reduces memory consumption and computational load, alleviates category interference, and improves detection accuracy.

Benefits of technology

In multi-class anomaly detection scenarios, the model's generalization ability and detection accuracy are improved, memory consumption and computational costs are reduced, and a lightweight inference process is achieved, making it easy to deploy on resource-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810058B_ABST
    Figure CN119810058B_ABST
Patent Text Reader

Abstract

The application belongs to the field of defect detection, and discloses a fabric surface defect detection method and related device, which comprises: obtaining a fabric image to be detected; inputting the fabric image to be detected into a pre-trained general unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected. The general unsupervised defect detection model comprises a feature extractor, a category matching module, a patch matching module, a center offset amount discrimination module and a feature discriminator; the category matching module is used for obtaining target category center feature information from a plurality of preset category center feature information; the patch matching module is used for aligning a plurality of feature blocks of the feature information with a plurality of category center feature blocks in the target category center feature information; the center offset amount discrimination module is used for obtaining an offset amount between each feature block and each aligned category center feature block; and the feature discriminator is used for obtaining the surface defect detection result of the fabric. The surface defect detection accuracy of the fabric is improved, and the deployment difficulty is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of defect detection, and relates to a fabric surface defect detection method and related device. BACKGROUND

[0002] Under the current global market environment, international competition is increasingly fierce and traditional production advantages are gradually disappearing, which puts higher requirements on the technical level and efficiency of manufacturing industry. Product quality is directly related to the market competitiveness and economic benefits of enterprises, especially for traditional manufacturing industries such as textile manufacturing, product surface defect detection is crucial. Such defects are often caused by mechanical failure, improper processing or improper material handling, etc., usually small and difficult to identify with the naked eye. For a long time, fabric defect detection mainly relies on manual visual inspection. This method is not only inefficient, but also the detection accuracy is limited by human subjective judgment and fatigue, which affects product quality and production efficiency. In recent years, defect detection technology based on deep learning has been proposed and widely applied to solve this problem. However, most of the methods rely on supervised learning, which requires a large number of labeled fabric defect images to construct the training set, the labeling cost is high, and the project preparation time is long. In addition, in actual production, new fabric defect types may continue to appear, and traditional supervised learning methods are difficult to quickly adapt and detect these unknown defects.

[0003] The goal of unsupervised defect detection is to identify defect samples and accurately locate their defect regions using only normal samples. This method has a wide range of applications in cases where defects occur infrequently and data collection is difficult. Currently, the mainstream unsupervised defect detection methods can be divided into three categories. The image reconstruction-based method: This method accurately reconstructs the normal area through the reconstruction model, while it is difficult to reconstruct the abnormal area, thereby detecting defects by the difference between the reconstructed image and the original image; the feature embedding-based method: This method uses a pre-trained network to extract features, and compresses normal features into a compact space, so as to identify defect features that are far away from the normal distribution in the feature space; the synthetic anomaly-based method: This method introduces abnormal discrimination information by data augmentation on normal samples at the image or feature level, further improving the accuracy of defect detection. Based on unsupervised defect detection, most methods in the current technical solutions use separate models for different categories of detection. Specifically, in the single-class unsupervised defect detection task, only normal samples of a single category are used in the training stage, and abnormal samples of the same category are detected in the test stage. The separate training method requires a specific weight model for each category, which leads to a significant increase in time and memory consumption as the number of categories increases, and is not suitable for application scenarios with high intra-class diversity. In contrast, a unified model only needs one model with shared weights to perform multiple detection tasks simultaneously. Specifically, in the general unsupervised defect detection task, multiple normal samples of different categories are used in the training stage, and abnormal samples of all known categories are detected in the test stage. Since this paradigm has higher generalization ability, it is more advantageous in actual industrial unsupervised defect detection scenarios. In view of this problem, general unsupervised defect detection methods have gradually attracted widespread attention.

[0004] However, the general unsupervised defect detection method still has several significant shortcomings, which limit its application in actual industrial scenarios. First, the general unsupervised defect detection method still has high memory consumption. Since the model needs to learn and store general feature information, it may cause memory overflow or resource shortage when running on edge devices with limited memory resources, making it difficult to meet the real-time detection requirements. Second, the deployment of this method is difficult. The general unsupervised detection model usually relies on complex feature embedding or generation networks, resulting in a large model architecture. Special handling of computational resources and model compression is required during deployment, increasing the difficulty of applying the model to industrial devices, especially in embedded devices or low-power environments. The deployment of complex models faces significant challenges, affecting their widespread application. SUMMARY

[0005] The purpose of the present application is to overcome the shortcomings of the prior art and provide a fabric surface defect detection method and related device.

[0006] To achieve the above object, the present application adopts the following technical solutions to achieve the above object:

[0007] In a first aspect, the present application provides a fabric surface defect detection method, comprising: obtaining a fabric image to be detected; inputting the fabric image to be detected into a pre-trained general unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected; wherein the general unsupervised defect detection model comprises a feature extractor, a category matching module, a patch matching module, a center offset amount discrimination module, and a feature discriminator; the feature extractor is used to obtain feature information of the fabric image; the category matching module is used to obtain category center feature information with the highest similarity to the feature information from pre-set category center feature information as target category center feature information; the patch matching module is used to divide the feature information into a plurality of feature blocks and align the plurality of feature blocks with a plurality of category center feature blocks in the target category center feature information; the center offset amount discrimination module is used to obtain offset amounts between each feature block and each aligned category center feature block; and the feature discriminator is used to obtain the surface defect detection result of the fabric according to the offset amounts between each feature block and each aligned category center feature block.

[0008] Optionally, the step of obtaining category center feature information with the highest similarity to the feature information from pre-set category center feature information as target category center feature information comprises: obtaining category center feature information with the shortest Euclidean distance to the feature information from pre-set category center feature information as target category center feature information.

[0009] Optionally, the pre-trained general unsupervised defect detection model is obtained by the following method: obtaining a training image sample; wherein the training image sample is a fabric image of a defect-free fabric; inputting the training image sample into the general unsupervised defect detection model and obtaining offset amounts between each feature block of the training image sample and each aligned category center feature block through the center offset amount discrimination module; superimposing perturbations on each feature block to obtain each perturbed feature block of the training image sample and obtaining offset amounts between each perturbed feature block of the training image sample and each aligned category center feature block through the center offset amount discrimination module; obtaining a surface defect detection result of the training image sample according to the offset amounts between each feature block of the training image sample and each aligned category center feature block through the feature discriminator; obtaining a perturbed surface defect detection result of the training image sample according to the offset amounts between each perturbed feature block of the training image sample and each aligned category center feature block through the feature discriminator; updating model parameters of the general unsupervised defect detection model according to the surface defect detection result and the perturbed surface defect detection result of the training image sample; and iterating the above steps until a pre-set condition is met to obtain the pre-trained general unsupervised defect detection model.

[0010] Optionally, the preset category center feature information is obtained by: obtaining feature information of fabric images of defect-free fabrics of each category in the training image samples by a feature extractor, and taking the mean value of the feature information of the fabric images of the defect-free fabrics of each category according to the category to obtain the category center feature information of the fabric images of the defect-free fabrics of each category.

[0011] Optionally, the superimposing the disturbance on each feature block to obtain each disturbed feature block of the training image sample comprises: traversing each feature block of each training image sample, and performing the following steps: obtaining the length of the offset between the current feature block of the training image sample and the aligned category center feature block to obtain a first length; and obtaining the length of the preset Gaussian noise to obtain a second length; based on a preset scaling factor, linearly scaling the ratio of the first length and the second length with the fixed point 1 as the center to obtain an adjustment coefficient; adjusting the variance of the preset Gaussian noise according to the adjustment coefficient to obtain the disturbance of the current feature block and superimposing it on the current feature block to obtain the current disturbed feature block of the training image sample.

[0012] Optionally, the iteration of the above steps until the preset condition is met comprises: iteration of the above steps until a preset iteration number is reached, or the detection accuracy of the universal unsupervised defect detection model under the current model parameter on the preset test set is greater than a preset detection accuracy threshold.

[0013] In a second aspect, the present application provides a fabric surface defect detection system, comprising: an image acquisition module for acquiring a fabric image to be detected; a defect detection module for inputting the fabric image to be detected into a pre-trained universal unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected; wherein the universal unsupervised defect detection model comprises a feature extractor, a category matching module, a patch matching module, a center offset discrimination module and a feature discriminator; the feature extractor is used to obtain feature information of the fabric image; the category matching module is used to obtain the category center feature information with the highest similarity to the feature information from the preset category center feature information as the target category center feature information; the patch matching module is used to divide the feature information into a plurality of feature blocks, and align the plurality of feature blocks with a plurality of category center feature blocks in the target category center feature information; the center offset discrimination module is used to obtain the offset between each feature block and each aligned category center feature block; and the feature discriminator is used to obtain the surface defect detection result of the fabric according to the offset between each feature block and each aligned category center feature block.

[0014] Optionally, the pre-trained general unsupervised defect detection model is obtained by: obtaining training image samples; wherein the training image samples are defect-free fabric images; inputting the training image samples into the general unsupervised defect detection model, and obtaining the offset between each feature block of the training image samples and the aligned category center feature block through the center offset discrimination module; superimposing perturbations on each feature block to obtain each perturbed feature block of the training image samples, and obtaining the offset between each perturbed feature block of the training image samples and the aligned category center feature block through the center offset discrimination module; obtaining the surface defect detection result of the training image samples according to the offset between each feature block of the training image samples and the aligned category center feature block through the feature discriminator; obtaining the perturbed surface defect detection result of the training image samples according to the offset between each perturbed feature block of the training image samples and the aligned category center feature block through the feature discriminator; updating the model parameters of the general unsupervised defect detection model according to the surface defect detection result and the perturbed surface defect detection result of the training image samples; iterating the above steps until a preset condition is met to obtain the pre-trained general unsupervised defect detection model.

[0015] In a third aspect, the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the fabric surface defect detection method when executing the computer program.

[0016] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to implement the steps of the fabric surface defect detection method.

[0017] Compared with the prior art, the present application has the following beneficial effects:

[0018] The fabric surface defect detection method of the present application is based on a pre-trained general unsupervised defect detection model to realize surface defect detection of the fabric to be detected. Among them, the general unsupervised defect detection model aims at the problem that the detection accuracy is reduced due to the large difference in feature distribution of different categories. Through the combination of the category matching module and the patch matching module, the model's ability to capture fine-grained features is improved. By introducing a novel center offset discrimination module, the offset of the feature information of the fabric image to be detected relative to the category center feature information of the corresponding category is determined for detection, which relieves the category interference of the model during detection, thereby effectively improving the generalization ability and detection accuracy of the model in the multi-category anomaly detection scene, and improving the surface defect detection accuracy of the fabric. At the same time, a simple unsupervised defect detection network architecture is adopted, which directly gives the defect positioning result by the feature discriminator. In the detection process, only a small amount of information such as the preset category center feature information needs to be queried, and the entire center feature information does not need to be recalculated, which reduces the memory consumption and computational load, reduces the computing cost and realizes the lightweight inference process, effectively speeds up the defect detection reasoning speed, and reduces the deployment difficulty of the model, facilitating the deployment on resource-constrained devices.

[0019] Further, for the problem of sparse distribution of features in space, in the pre-training process, by using a preset scaling factor, the ratio of the first module length to the second module length is linearly scaled with fixed point 1 as the center to obtain an adjustment coefficient, and the preset Gaussian noise is adjusted according to the adjustment coefficient to obtain the current perturbation feature block of the training image sample, so that the abnormal image maintains a proper distance from the normal images of each category in the feature space, thereby ensuring the generalization ability of the model. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 The fabric surface defect detection method flowchart of the present application embodiment.

[0021] Figure 2 The perturbation feature block synthesis principle diagram of the present application embodiment.

[0022] Figure 3 The fabric surface defect detection system structure block diagram of the present application embodiment. DETAILED DESCRIPTION

[0023] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.

[0024] It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting, unless the context clearly indicates otherwise. It will be further understood that the use of relational terms such as first and second, and the like are used solely to distinguish one from another entity without necessarily implying a relationship or order between such entities. Much of the detail of the embodiments described in this detailed description are therefore optional.

[0025] The application will be further described in detail with reference to the drawings.

[0026] Referring to Figure 1 In an embodiment of the present application, a fabric surface defect detection method is provided, specifically a fabric surface general unsupervised multi-class defect detection method based on memory center perception. The method can effectively solve the common inter-class interference and feature sparse distribution problems in multi-class fabric surface anomaly detection by innovative module design to improve the generalization ability and detection accuracy of the model.

[0027] Specifically, the fabric surface defect detection method comprises the following steps:

[0028] S1: Obtain a fabric image to be detected.

[0029] S2: Input the fabric image to be detected into a pre-trained general unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected.

[0030] The general unsupervised defect detection model comprises a feature extractor, a class matching module, a patch matching module, a center offset amount discrimination module, and a feature discriminator. The feature extractor is used to obtain feature information of the fabric image. The class matching module is used to obtain class center feature information with the highest similarity to the feature information from pre-set class center feature information as target class center feature information. The patch matching module is used to divide the feature information into a plurality of feature blocks and align the plurality of feature blocks with a plurality of class center feature blocks in the target class center feature information. The center offset amount discrimination module is used to obtain offset amounts between each feature block and each aligned class center feature block. The feature discriminator is used to obtain a surface defect detection result of the fabric according to the offset amounts between each feature block and each aligned class center feature block.

[0031] The fabric surface defect detection method of the application is based on a pre-trained general unsupervised defect detection model to realize surface defect detection of a fabric to be detected. The general unsupervised defect detection model is combined with a category matching module and a patch matching module to improve the model's ability to capture fine-grained features in view of the problem of large differences in feature distribution of different categories leading to reduced detection accuracy. A novel center offset discrimination module is introduced to determine the offset of the feature information of the fabric image to be detected relative to the category center feature information of the corresponding category for detection, thereby relieving the category interference of the model during detection, effectively improving the generalization ability and detection accuracy of the model in a multi-category anomaly detection scenario, and improving the accuracy of fabric surface defect detection. At the same time, a simple unsupervised defect detection network architecture is adopted, which directly gives the defect positioning result by the feature discriminator, and only needs to query a small amount of information such as the preset category center feature information during the detection process, without the need to recalculate all the center feature information, thereby reducing the memory consumption and computational load, reducing the computing cost and realizing a lightweight inference process, effectively speeding up the defect detection reasoning speed and reducing the deployment difficulty of the model, facilitating the deployment on resource-constrained devices.

[0032] Explanatorily, the surface defect detection result of the fabric is generally whether each feature block of the fabric image has a defect, which is determined by the defect probability of each feature block output by the feature discriminator according to the offset between each feature block and each aligned category center feature block. Further, the detection result of whether each region of each feature block of the fabric image has a defect is output to realize defect positioning detection.

[0033] Explanatorily, the similarity of the feature information obtained by the category matching module and the category center feature information is calculated by global similarity, and the fabric image is sequentially assigned to the most matching category center.

[0034] Explanatorily, the patch matching module divides the feature information of the fabric image into multiple small blocks, i.e., feature blocks, and compares and aligns each feature block with the feature block of the category center feature information of the corresponding category, thereby realizing more fine-grained feature matching. This patch-level matching can effectively enhance the diversity of intra-class features, ensuring that the model captures fine features more accurately during feature generation and anomaly detection.

[0035] In a possible implementation, the step of obtaining, from the preset several category center feature information, the category center feature information with the highest similarity with the feature information as the target category center feature information includes: obtaining, from the preset several category center feature information, the category center feature information with the shortest Euclidean distance with the feature information as the target category center feature information.

[0036] Illustratively, the feature extractor is configured to extract multi-level feature information of the fabric image, which contains detailed descriptions of different levels and regions of the fabric image.

[0037] Illustratively, the preset category center feature information can be pre-stored in the memory, and the acquisition of the corresponding category center feature information is realized by calling in use. The category matching module queries the pre-stored category center feature information in the memory to determine the category to which the input fabric image belongs, so that the input fabric image can be accurately found to the closest category center feature information for subsequent anomaly detection.

[0038] In one possible implementation, the pre-trained general unsupervised defect detection model is obtained by: obtaining training image samples; wherein the training image samples are fabric images of defect-free fabrics; inputting the training image samples into the general unsupervised defect detection model, and obtaining the offset between each feature block of the training image samples and the aligned category center feature block through the center offset discrimination module; obtaining each perturbed feature block of the training image samples by superimposing perturbations on each feature block, and obtaining the offset between each perturbed feature block of the training image samples and the aligned category center feature block through the center offset discrimination module; obtaining the surface defect detection result of the training image samples according to the offset between each feature block of the training image samples and the aligned category center feature block through the feature discriminator; obtaining the perturbed surface defect detection result of the training image samples according to the offset between each perturbed feature block of the training image samples and the aligned category center feature block through the feature discriminator; updating the model parameters of the general unsupervised defect detection model according to the surface defect detection result and the perturbed surface defect detection result of the training image samples; and iterating the above steps until a preset condition is met to obtain the pre-trained general unsupervised defect detection model.

[0039] Illustratively, during the training process, the preset category center feature information stored in the memory is used to realize the classification of the training image samples. The preset category center feature information stored in the memory can be updated in real time according to newly obtained training image samples.

[0040] Optionally, the preset category center feature information is obtained by: obtaining the feature information of the fabric images of defect-free fabrics of each category in the training image samples through the feature extractor, and taking the mean value of the feature information of the fabric images of defect-free fabrics of each category to obtain the category center feature information of the fabric images of defect-free fabrics of each category.

[0041] Illustratively, the category center feature information is defined as the mean value of the feature information of the fabric images of defect-free fabrics of each category, which can more accurately represent the features of the fabric images of each category of fabric.

[0042] In a possible implementation, the superimposing the perturbation on each feature block to obtain each perturbed feature block of the training image sample comprises: traversing each feature block of each training image sample, and performing the following steps: obtaining a first module length of an offset between a current feature block of the training image sample and an aligned category center feature block; and obtaining a second module length of the preset Gaussian noise; performing linear scaling with fixed point 1 as the center on a ratio of the first module length and the second module length based on a preset scaling factor to obtain an adjustment coefficient; and adjusting a variance of the preset Gaussian noise according to the adjustment coefficient to obtain a perturbation of the current feature block and superimposing the perturbation on the current feature block to obtain a current perturbed feature block of the training image sample.

[0043] Illustratively, in this strategy, the feature information of the fabric image of the defect-free fabric is first input, and is matched with the category center feature information of the corresponding category. The category center feature information corresponding to the feature information of the input fabric image of the defect-free fabric can be accurately found through the similarity comparison, that is, the Euclidean distance between the feature information of the input fabric image of the defect-free fabric and the preset category center feature information is calculated, and the closest category center feature information is found on this basis, and then the adjusted Gaussian noise is added to the closest category center feature information.

[0044] Specifically, the variance of the Gaussian noise sets the generation range of the perturbed feature block, so that the perturbed feature block maintains a proper distance distribution with the normal feature block in the feature space, thereby forming a reasonable abnormal boundary. Because the normal features of different categories have different modes of feature distribution, the perturbed feature block directly superimposed with the Gaussian noise of a fixed variance may be aliasing with the normal feature block. Therefore, the strategy of center distance constraint variance is designed to adaptively generate perturbed feature blocks with variable variance, thereby alleviating the aliasing problem.

[0045] This strategy of center distance constraint variance ensures that the features of different categories remain relatively independent by regulating the distance between the perturbed feature block and the normal feature block, and avoids the features of the abnormal fabric image “close” to the features of the normal fabric image of a certain category, thereby reducing the detection error and inter-class interference.

[0046] In addition, the strategy of center distance constraint variance can also ensure that the generated perturbed feature block does not deviate too far from the normal feature block, and remains within a reasonable range, thereby effectively improving the accuracy of abnormal detection and the model generalization performance.

[0047] For example, when updating the model parameters of the general unsupervised defect detection model according to the surface defect detection results of the training image samples and the perturbed surface defect detection results, the normal sample discrimination loss of the model is obtained according to the surface defect detection results of the training image samples, and the abnormal sample discrimination loss of the model is obtained according to the perturbed surface defect detection results of the training image samples. Wherein, the normal sample discrimination loss and the abnormal sample discrimination loss can adopt cross-entropy loss function, then the superimposed discrimination loss is obtained by comprehensively considering the normal sample discrimination loss and the abnormal sample discrimination loss, and the model parameters of the general unsupervised defect detection model are updated according to the superimposed discrimination loss.

[0048] In a possible implementation, the iteration of the above steps until the preset condition is met includes: iteration of the above steps until a preset iteration number is reached, or the detection accuracy of the general unsupervised defect detection model under the current model parameters on the preset test set is greater than a preset detection accuracy threshold.

[0049] Compared with the existing method, the fabric surface defect detection method has the following outstanding substantial features and significant progress: 1. For the problem of large difference in feature distribution of different categories, a center offset discrimination module is introduced to learn the offset of the sample relative to the center of each category, which alleviates the category interference of the model during detection, thereby improving the detection accuracy; 2. For the problem of sparse distribution of features in space, the strategy of center distance constraint variance is used to effectively constrain the perturbation, so that the abnormal samples maintain a proper distance from the normal samples of each category in the feature space, thereby ensuring the generalization ability; 3. By designing a lightweight model, the memory consumption and computational load are reduced, which is convenient for deployment on resource-limited devices, and realizes low-cost and high-efficiency defect detection.

[0050] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the apparatus embodiment, please refer to the method embodiment of the present application.

[0051] Referring to Figure 3 In another embodiment of the present application, a fabric surface defect detection system is provided, which can be used to implement the fabric surface defect detection method described above. Specifically, the fabric surface defect detection system includes an image acquisition module and a defect detection module.

[0052] The system comprises the following modules: an image acquisition module for acquiring an image of the fabric to be detected; a defect detection module for inputting the image of the fabric to be detected into a pre-trained general unsupervised defect detection model to obtain the surface defect detection result of the fabric; the general unsupervised defect detection model includes a feature extractor, a category matching module, a patch matching module, a center offset discrimination module, and a feature discriminator; the feature extractor for acquiring feature information of the fabric image; the category matching module for acquiring the category center feature information with the highest similarity from a number of preset category center feature information, and using it as the target category center feature information; the patch matching module for dividing the feature information into several feature blocks and aligning the feature blocks with several category center feature blocks in the target category center feature information; the center offset discrimination module for acquiring the offset between each feature block and the aligned category center feature blocks; and the feature discriminator for obtaining the surface defect detection result of the fabric based on the offset between each feature block and the aligned category center feature blocks.

[0053] In one possible implementation, the pre-trained general unsupervised defect detection model is obtained through the following steps: acquiring training image samples; wherein the training image samples are images of defect-free fabric; inputting the training image samples into the general unsupervised defect detection model, and obtaining the offset between each feature block of the training image sample and the aligned center feature blocks of each category through a center offset discrimination module; superimposing perturbations on each feature block to obtain perturbed feature blocks of the training image sample, and obtaining the offset between each perturbed feature block of the training image sample and the aligned center feature blocks of each category through a center offset discrimination module; obtaining the surface defect detection result of the training image sample based on the offset between each feature block of the training image sample and the aligned center feature blocks of each category through a feature discriminator; obtaining the perturbed surface defect detection result of the training image sample based on the offset between each perturbed feature block of the training image sample and the aligned center feature blocks of each category through a feature discriminator; updating the model parameters of the general unsupervised defect detection model based on the surface defect detection result and the perturbed surface defect detection result of the training image sample; iterating the above steps until a preset condition is met to obtain the pre-trained general unsupervised defect detection model.

[0054] All relevant content of each step involved in the aforementioned embodiments of the fabric surface defect detection method can be referenced to the functional description of the corresponding functional module of the fabric surface defect detection system in the embodiments of the present invention, and will not be repeated here.

[0055] The division of the modules in the embodiments of the present application is illustrative, and is merely a logical function division, and in actual implementation, another division manner can be used, and in addition, each function module in each embodiment of the present application can be integrated in one processor, or can be a separate physical existence, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module.

[0056] In still another embodiment of the present application, a computer device is provided, which comprises a processor and a memory, the memory is used to store a computer program, the computer program comprises program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, and are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions in the computer storage medium to implement a corresponding method flow or a corresponding function; the processor in the embodiments of the present application can be used for the operation of the fabric surface defect detection method.

[0057] In still another embodiment of the present application, the present application further provides a storage medium, specifically a computer readable storage medium (Memory), which is a memory device in the computer device, and is used to store programs and data. It can be understood that the computer readable storage medium here can include the built-in storage medium in the computer device, and of course can also include the expansion storage medium supported by the computer device. The computer readable storage medium provides a storage space, and the storage space stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and the instructions can be one or more computer programs (including program codes). It should be noted that the computer readable storage medium here can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory. One or more instructions stored in the computer readable storage medium can be loaded and executed by the processor to implement the corresponding steps of the fabric surface defect detection method in the above embodiments.

[0058] Those skilled in the art will appreciate that embodiments of the application can be readily used as a method, apparatus, or computer program product. Accordingly, the application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.

[0059] The application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart Figure 1 one or more functions specified in the flowchart block or blocks. Figure 1 means for performing each of the functions specified in the flowchart block or blocks.

[0060] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flowchart Figure 1 one or more functions specified in the flowchart block or blocks. Figure 1 means for performing each of the functions specified in the flowchart block or blocks.

[0061] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart Figure 1 one or more functions specified in the flowchart block or blocks. Figure 1 means for performing each of the functions specified in the flowchart block or blocks.

[0062] Finally, it should be noted that the above-described embodiments are merely intended for describing and illustrating, not limiting, the technical solution of the present application. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the specific embodiments of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the present application, and any modification or equivalent replacement should be covered within the protection scope of the claims of the present application.

Claims

1. A fabric surface defect detection method characterized by, The method comprises: obtaining a fabric image to be detected; inputting the fabric image to be detected into a pre-trained general unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected; wherein the general unsupervised defect detection model comprises a feature extractor, a category matching module, a patch matching module, a center offset judgment module, and a feature discriminator; the feature extractor is used to obtain feature information of the fabric image; the category matching module is used to obtain category center feature information with the highest similarity to the feature information from pre-set category center feature information as target category center feature information; the patch matching module is used to divide the feature information into a plurality of feature blocks and align the plurality of feature blocks with a plurality of category center feature blocks in the target category center feature information; the center offset judgment module is used to obtain offsets between each feature block and each aligned category center feature block; and the feature discriminator is used to obtain the surface defect detection result of the fabric according to the offsets between each feature block and each aligned category center feature block; the pre-trained general unsupervised defect detection model is obtained by the following method: obtaining training image samples; wherein the training image samples are fabric images of defect-free fabrics; inputting the training image samples into the general unsupervised defect detection model and obtaining offsets between each feature block of the training image samples and each aligned category center feature block through the center offset judgment module; superimposing perturbations on each feature block to obtain each perturbed feature block of the training image samples and obtaining offsets between each perturbed feature block of the training image samples and each aligned category center feature block through the center offset judgment module; obtaining a surface defect detection result of the training image samples through the feature discriminator according to the offsets between each feature block of the training image samples and each aligned category center feature block; obtaining a perturbed surface defect detection result of the training image samples through the feature discriminator according to the offsets between each perturbed feature block of the training image samples and each aligned category center feature block; updating model parameters of the general unsupervised defect detection model according to the surface defect detection result and the perturbed surface defect detection result of the training image samples; iterating the above steps until a pre-set condition is met to obtain the pre-trained general unsupervised defect detection model; the pre-set category center feature information is obtained by the following method: obtaining feature information of fabric images of each category of defect-free fabrics in the training image samples through the feature extractor and taking the mean of the feature information of the fabric images of each category of defect-free fabrics according to the category to obtain category center feature information of the fabric images of each category of defect-free fabrics; the step of superimposing perturbations on each feature block to obtain each perturbed feature block of the training image samples comprises: iterating each feature block of each training image sample to perform the following steps: obtaining the length of the offset between the current feature block of the training image sample and the aligned category center feature block to obtain a first length; and obtaining the length of the pre-set Gaussian noise to obtain a second length; based on a pre-set scaling factor, linearly scaling the ratio of the first length and the second length with fixed point 1 as the center to obtain an adjustment coefficient; The variance of the preset Gaussian noise is adjusted according to the adjustment coefficient to obtain a disturbance quantity of the current feature block and superimposed on the current feature block to obtain a current disturbed feature block of the training image sample.

2. The fabric surface defect detection method of claim 1, wherein, The step of obtaining the class center feature information with the highest similarity to the feature information from the preset class center feature information as the target class center feature information includes: The step of obtaining the class center feature information with the shortest Euclidean distance to the feature information from the preset class center feature information as the target class center feature information.

3. The fabric surface defect detection method of claim 1, wherein, The step of iterating the above steps until a preset condition is met includes: The step of iterating the above steps until a preset iteration number is reached, or the detection accuracy of the general unsupervised defect detection model under the current model parameter on the preset test set is greater than a preset detection accuracy threshold.

4. A fabric surface defect detection system characterized by, The step of obtaining the class center feature information with the highest similarity to the feature information from the preset class center feature information as the target class center feature information includes: An image acquisition module is configured to acquire a fabric image to be detected; A defect detection module is configured to input the fabric image to be detected into a pre-trained general unsupervised defect detection model to obtain a surface defect detection result of the fabric to be detected. The general unsupervised defect detection model includes a feature extractor, a class matching module, a patch matching module, a center offset determination module, and a feature discriminator. The feature extractor is configured to obtain feature information of the fabric image. The class matching module is configured to obtain class center feature information with the highest similarity to the feature information from a plurality of preset class center feature information as target class center feature information. The patch matching module is configured to divide the feature information into a plurality of feature blocks and align the plurality of feature blocks with a plurality of class center feature blocks in the target class center feature information. The center offset determination module is configured to obtain an offset between each feature block and each aligned class center feature block. The feature discriminator is configured to obtain a surface defect detection result of the fabric according to the offset between each feature block and each aligned class center feature block. The pre-trained general unsupervised defect detection model is obtained by the following method: Obtain a training image sample; wherein the training image sample is a defect-free fabric image; Input the training image sample into the general unsupervised defect detection model, and obtain the offset between each feature block of the training image sample and each aligned class center feature block through the center offset determination module. Superimpose a disturbance on each feature block to obtain each disturbed feature block of the training image sample, and obtain the offset between each disturbed feature block of the training image sample and each aligned class center feature block through the center offset determination module. Obtain a surface defect detection result of the training image sample through the feature discriminator according to the offset between each feature block of the training image sample and each aligned class center feature block. Obtain a disturbed surface defect detection result of the training image sample through the feature discriminator according to the offset between each disturbed feature block of the training image sample and each aligned class center feature block. Update the model parameters of the general unsupervised defect detection model according to the surface defect detection result and the disturbed surface defect detection result of the training image sample. Iterate the above steps until a preset condition is met to obtain the pre-trained general unsupervised defect detection model. The preset category center feature information is obtained by the following method: The feature extractor is used to obtain feature information of fabric images of defect-free fabrics of each category in the training image samples, and the feature information of the fabric images of the defect-free fabrics of each category is averaged according to the category to obtain category center feature information of the fabric images of the defect-free fabrics of each category; The superimposition of the disturbance on each feature block to obtain each disturbance feature block of the training image samples comprises: Each feature block of each training image sample is traversed, and the following steps are performed: The modulus of the offset between the current feature block of the training image sample and the aligned category center feature block is obtained to obtain a first modulus, and the modulus of the preset Gaussian noise is obtained to obtain a second modulus; Based on a preset scaling factor, the ratio of the first modulus and the second modulus is linearly scaled with the fixed point 1 as the center to obtain an adjustment coefficient; According to the adjustment coefficient, the variance of the preset Gaussian noise is adjusted to obtain a disturbance of the current feature block and superimposed to the current feature block to obtain a current disturbance feature block of the training image sample.

5. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the fabric surface defect detection method according to any one of claims 1 to 3.

6. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 5. The computer program is executed by the processor to realize the steps of the fabric surface defect detection method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Non-supervision defect detection method and system based on slice matching and medium

    CN116958153A