Unsupervised silk fabric defect detection method based on fusion multi-head attention reconstruction network

By integrating a multi-head attention reconstruction network into the detection framework, the problems of difficulty in capturing subtle textures and redundant attention heads in silk fabric defect detection are solved, achieving more efficient defect detection and localization.

CN121353152APending Publication Date: 2026-01-16MINJIANG UNIVERSITY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510042940.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

Existing unsupervised deep learning methods struggle to effectively capture subtle textures in silk fabric defect detection, and redundant attention heads affect detection accuracy. Furthermore, the training process is unstable, and data scarcity impacts the quality of generated results.

Method used

A detection framework based on a fusion multi-head attention reconstruction network is adopted. A pre-trained visual Transformer is used as the feature encoder, combined with the bottleneck layer of MeanDropout and the fusion multi-head attention decoder. MeanDropout reduces the model's dependence on repetitive features, dynamically selects appropriate subtle features, and is trained using global cosine loss and contrastive constraint loss.

Benefits of technology

It improves the accuracy and stability of defect detection in silk fabrics, enhances the focus on subtle textures, reduces the influence of redundant attention points, and improves the ability to locate defect areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121353152A_ABST
    Figure CN121353152A_ABST
Patent Text Reader

Abstract

The invention relates to an unsupervised silk fabric defect detection method based on a fusion multi-head attention reconstruction network, and belongs to the technical field of fabric defect detection. According to the method, a silk fabric defect detection framework based on a fusion multi-head attention reconstruction network is provided, and the framework is composed of a Transform pre-training encoder, a bottleneck layer with Mean Dropout and a fusion attention decoder. Specifically, the method comprises the following steps: firstly, using a pre-trained visual Transform (ViT) as a feature encoder, and extracting discriminant features of a silk fabric image as a reconstruction object; then, the extracted features are input into a bottleneck layer with Mean Dropout, so that the dependence of the model on repeated features is reduced; in addition, a decoder integrating a multi-head attention mechanism (HMA) and an LLamaMLP is provided to guide the attention head to dynamically select proper fine features; and finally, the improved decoder combines the multi-layer features into a whole to perform loose reconstruction, namely, layer-to-layer and point-by-point reconstruction is not forced, so that the reconstruction constraint is relaxed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of fabric defect detection technology, specifically relating to an unsupervised method for detecting defects in silk fabrics based on a fusion multi-head attention reconstruction network. Background Technology

[0002] Silk fabrics have always been one of the products most closely related to human life[1]. However, in the production process of silk fabrics, various defects will inevitably be generated, which will directly affect the final overall quality and service life of silk fabric products. Therefore, defect detection of silk fabrics is an indispensable part of industrial production. Traditional supervised deep learning methods[2][3] acquire deep features by building multi-layer networks. However, due to the low probability and diverse forms of defects or abnormal samples in silk fabrics, it is difficult to obtain large-scale labeled abnormal data in the production process. Supervised deep learning methods have many limitations in practical applications. Unsupervised deep learning methods use defect-free samples during training, which overcomes the limitations of supervised deep learning methods. For example, Zhang et al.[4] proposed a two-step cascaded amplification network for silk fabric defect detection. Jing et al.[5] proposed a model based on the improved YOLOv3. However, due to the relatively fine defect area of ​​silk fabrics, the difference between normal samples and defect samples is not large, which makes the above methods insensitive to defect areas, ultimately causing the defect area localization to fail.

[0003] Therefore, it is very important to improve the attention to subtle textures in the task of detecting defects in silk fabrics. In recent years, the Transformer[6] model has become one of the leading deep learning architectures. Its self-attention mechanism can effectively capture long-distance dependencies and help to learn the complex relationships between different parts of an image. At the same time, more research has begun to focus on the attention weight problem in order to improve the attention mechanism's attention to different features. For example, Michel et al.[7] studied the effect of extensive pruning of attention heads in various environments, while Dosovitskiy et al.[8] introduced a random pruning method to quantify the effectiveness of each attention head.

[0004] Most advanced unsupervised anomaly detection methods currently utilize networks pre-trained on large-scale datasets (e.g., ImageNet) to extract discriminative and informative feature representations. Examples include feature reconstruction [9]

[10]

[11] and feature distillation methods

[12] . Gong et al. [9] used generative models such as autoencoders and generative adversarial networks to encode and reconstruct normal data. Liu et al.

[10] proposed introducing an inverter into a deep convolutional generative adversarial network. However, training reconstruction methods usually requires a large amount of high-quality data to generate realistic samples. Data scarcity may affect the quality of the generated results. In addition, the training process of the generator and discriminator may be unbalanced, leading to a mismatch in the model's learning progress, resulting in problems such as training instability and mode collapse.

[0005] Transformer has achieved great development and success in natural language processing and computer vision. For a long time, the success of Transformer has been attributed to the multi-head attention mechanism. However, recent studies have shown that there are redundant attention heads in the multi-head attention mechanism that over-focus on some features, which affects the final judgment of the model. For example, Michel et al. [7] studied the effect of extensive pruning of attention heads in various environments. Dosovitskiy et al. [8] introduced a method to quantify the effectiveness of each attention head. This further illustrates that there are redundant attention heads in the attention mechanism. Summary of the Invention

[0006] The purpose of this invention is to establish a dynamic attention sharing mechanism suitable for silk fabric detection tasks, so as to reduce redundant feature attention without affecting accuracy and improve the attention mechanism's attention to key subtle textures. Therefore, an unsupervised silk fabric defect detection method based on a fused multi-head attention reconstruction network is provided. A silk fabric defect detection framework based on a fused multi-head attention reconstruction network is proposed, which consists of a Transformer pre-trained encoder, a bottleneck layer with MeanDropout, and a fused attention decoder. Specifically, firstly, a pre-trained Visual Transformer (ViT) is used as a feature encoder to extract discriminative features from silk fabric images as the reconstruction object. Then, unlike existing reconstruction methods that use complex noise-adding schemes, this method inputs the extracted features into a bottleneck layer with MeanDropout, thereby reducing the model's dependence on repetitive features. Furthermore, to enhance the ability of the attention head in the Transformer to capture subtle textures, this invention proposes a decoder that combines a multi-head attention mechanism (HMA) and LLamaMLP to guide the attention head to dynamically select appropriate subtle features. Finally, the improved decoder combines the multi-layer features into a whole for loose reconstruction, that is, it does not force layer-to-layer and point-by-point reconstruction, thereby relaxing the reconstruction constraints.

[0007] To achieve the above objectives, the technical solution of the present invention is: an unsupervised silk fabric defect detection method based on a fusion multi-head attention reconstruction network. The present invention proposes a silk fabric defect detection framework based on a fusion multi-head attention reconstruction network, which consists of a Transformer pre-trained feature encoder, a bottleneck layer with MeanDropout, and a fusion attention decoder.

[0008] In one embodiment of the present invention, the method specifically includes:

[0009] A pre-trained visual Transformer (ViT) is used as a feature encoder to extract discriminative features from silk fabric images as the reconstruction object.

[0010] The extracted features are input into a bottleneck layer with MeanDropout to obtain a multi-layer feature combination;

[0011] We propose a fusion attention decoder that combines multi-layer features into a whole for loose reconstruction, which does not force layer-to-layer or point-by-point reconstruction, thus relaxing the reconstruction constraints.

[0012] In one embodiment of the present invention, the feature encoder is specifically implemented as follows:

[0013] Given a training image x train The feature extraction process of the feature encoder is defined as follows:

[0014] e=φ(x train )

[0015] Where φ represents the pre-trained DINOv2 network with registers, and e represents the features extracted by the pre-trained DINOv2 network, which is based on Transformer.

[0016] In one embodiment of the present invention, the bottleneck layer with MeanDropout uses Mean Dropout as a feature noise addition scheme. Mean Dropout uses the mean to fill in the dropped elements, reducing the model's dependence on specific subtle features. The bottleneck layer with MeanDropout is represented as follows:

[0017]

[0018] Where e represents the feature extracted by the pre-trained DINOv2 network, p represents the probability of retaining the feature, and mean(e) means that the feature with probability (1-p) is replaced by the average value.

[0019] In one embodiment of the present invention, the fusion attention decoder is a decoder that combines the multi-head attention mechanism HMA and LLamaMLP.

[0020] In one embodiment of the present invention, the fused multi-head attention mechanism (HMA) treats the attention heads as experts, and the expert heads can adaptively assign different weights to features, thereby enhancing attention to subtle texture features; specifically, HMA consists of h = {H 1 H 2 ,...,H h The routes consist of} and Top-K activation heads; formally, for each T×d in Dimensional labeling and each T'×d in Dimensional labeling The output of HMA is a weighted sum of the outputs of K selected heads:

[0021]

[0022] Among them, H i Let g represent the i-th attention head. i G represents the routing score, which is only calculated when the i-th attention head is activated. i Talent is not zero; It is the final projection matrix;

[0023] At the same time, HMA designates a subset of attention headers as shared headers that are always active, reducing redundancy among other dynamic routing headers by integrating common knowledge within the shared headers.

[0024] Finally, a two-phase routing strategy is used to dynamically balance the weights between the shared header and the route header. In this strategy, the route score is determined by the score of each header and a score associated with the header type. Specifically, given... The t-th input token Then the routing score g i Defined as:

[0025]

[0026] Where β = if(W r x t ) i ∈Top-K({(W r x t ) i |h s +1≤i≤h s}) indicates that feature points with an activation head smaller than the attention head are selected, h s Indicates the number of shared headers. Let represent the projection matrices of the shared header and the routing header, respectively. The activation function Softmax maps the output to the range of 0-1. The coefficients α1 and α2 balance the contributions of the shared header and the routing header, and are defined as follows:

[0027] [α1,α2]=Softmax(W h x t )

[0028] in, For a trainable projection matrix, d in For x t Size.

[0029] In one embodiment of the present invention, the loose reconstruction of combining multi-layer features into a whole means adding up all feature maps of the layers of interest in the multi-layer feature combination as a whole for loose reconstruction, i.e., group-to-group constraints.

[0030] In one embodiment of the present invention, the silk fabric defect detection framework based on a fusion multi-head attention reconstruction network uses hard mining global cosine loss as the reconstruction loss function, let f E and f D Represent the feature maps of the encoder and decoder, respectively, and the global cofactor.

[0031] The string loss is expressed as follows:

[0032]

[0033] in, This means taking the cosine value of the input. Indicates the flattening operation, f D (h,w) represents the feature point at (h,w), sg(·) 0.1 This means reducing the gradient to one-tenth of its original value. This means selecting 90% of the feature points with smaller cosine distances within a batch.

[0034] In one embodiment of the present invention, considering the subtlety and repetitiveness of the features of silk fabrics, an additional contrast constraint loss is added to narrow the distance between similar features. The contrast constraint loss function is expressed as follows:

[0035]

[0036] Among them, y i The label representing whether sample i belongs to the same category, d 2 The square of the distance between the feature vectors of sample i is represented by N, the number of samples is represented by N, and margin is a boundary parameter used to control the distance between samples of the same class and the distance between samples of different classes.

[0037] The final overall loss is the average of the sum of the global cosine loss and the contrastive constraint loss:

[0038]

[0039] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor, wherein when the processor executes the computer program instructions, it can implement the steps of the method described above.

[0040] Compared to existing technologies, this invention offers the following advantages: To enhance the defect detection capability of silk fabrics, this invention proposes a silk fabric defect detection framework based on a fusion multi-head attention reconstruction network. This framework consists of a Transformer pre-trained encoder, a bottleneck layer with MeanDropout, and a fusion attention decoder. Unlike existing reconstruction methods that use complex noise-adding schemes, this invention inputs the extracted features into the bottleneck layer with MeanDropout, thereby reducing the model's dependence on repetitive features. Furthermore, to enhance the ability of the attention heads in the Transformer to capture subtle textures, a decoder combining a fusion multi-head attention mechanism (HMA) and LLamaMLP is designed to guide the attention heads in dynamically selecting appropriate subtle features. Finally, the improved decoder combines the multi-layer features into a whole for loose reconstruction, i.e., it does not force layer-to-layer or point-by-point reconstruction, thus relaxing the reconstruction constraints. Attached Figure Description

[0041] Figure 1 This is a comparison chart of multi-head attention and fused-head attention.

[0042] Figure 2 This is the network model architecture of the method of the present invention.

[0043] Figure 3 To reconstruct the constraint scheme.

[0044] Figure 4 This is a visualization of the model's performance on the test dataset. Detailed Implementation

[0045] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings.

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

[0047] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0048] This invention proposes an unsupervised defect detection method for silk fabrics based on a fused multi-head attention reconstruction network. The framework consists of a Transformer pre-trained feature encoder, a bottleneck layer with MeanDropout, and a fused attention decoder. Specifically, this paper first uses a pre-trained Visual Transformer (ViT) as the feature encoder to extract discriminative features from the silk fabric image as the reconstruction object. Then, unlike existing reconstruction methods that use complex noise addition schemes, this invention inputs the extracted features into a bottleneck layer with MeanDropout, thereby reducing the model's dependence on repetitive features. Furthermore, to enhance the ability of the attention head in the Transformer to capture subtle textures, this invention proposes a decoder that combines a fused multi-head attention mechanism (HMA) and LLamaMLP to guide the attention head to dynamically select appropriate subtle features. Finally, the improved decoder combines the multi-layer features into a whole for loose reconstruction, i.e., it does not force layer-to-layer or point-by-point reconstruction, thus relaxing the reconstruction constraints. Figure 1 A comparison is given between multi-head attention and the fusion multi-head attention mechanism (HMA) proposed in this paper.

[0049] The technical solution of the present invention will be described in detail below.

[0050] 1 Feature Encoder

[0051] Large-scale labeled anomaly data is difficult to obtain during the production of silk fabrics, and manual annotation is time-consuming and laborious because silk fabric defects are usually subtle. Therefore, unsupervised methods are used, employing only normal images during training. Current mainstream approaches use encoders pre-trained on large-scale datasets as the foundation and starting point for specific visual tasks, especially ViTs and their combinations, to generate general features applicable to both image-level visual tasks (image classification, instance retrieval) and pixel-level visual tasks (depth estimation, semantic segmentation).

[0052] Recent articles

[13]

[14] have found that in anomaly detection tasks, self-supervised models outperform domain-specific ImageNet features in terms of robustness and generality. This work further utilizes the latest Transformer foundation, DINOv2 with registers

[15] , as the encoder for extracting features from silk fabric images. Given a training image x train The feature extraction process is defined as follows:

[0053] e=φ(x train )

[0054] Where φ represents the pre-trained DINOv2 network with registers, and e represents the features extracted by the pre-trained network.

[0055] 2 Bottleneck Layer

[0056] Due to the repetitive nature of silk fabric features, mainstream reconstruction methods [16-18] are prone to over-reliance on these repetitive features by the decoder, which generalizes its reconstruction capabilities to anomalous samples, leading to anomaly detection failure.

[0057] Unlike the methods described above, this framework employs Mean Dropout as a feature noise-adding scheme in its bottleneck layer. Mean Dropout uses the mean to fill in the dropped elements, reducing the model's dependence on specific subtle features and preventing the decoder from being able to reconstruct unseen anomalous samples due to excessive power. In this invention, the role of Mean Dropout can be interpreted as adding feature noise and pseudo-anomalies, rather than alleviating overfitting. Although the decoder needs noisy features during training, the model encourages the recovery of normal features from the encoder. Without introducing any new modules, this paradigm forces the decoder to recover normal features given a test image with anomalous features, thereby mitigating the same mapping:

[0058]

[0059] Here, p represents the probability of retaining a feature. Mean Dropout replaces features with a probability of (1-p) with their average value.

[0060] 3 Reconstruction Decoder

[0061] Previous studies [7][8] have noted the presence of redundant attention heads in the attention mechanism, which operate independently and do not provide additional assistance in learning the features of silk fabrics. Therefore, a dynamic attention head routing mechanism can be established, which adaptively assigns appropriate weights to features by attention heads, in order to reduce redundant attention heads and improve the model's attention to subtle features without affecting accuracy.

[0062] In recent years, Hybrid Expert (MoE) models have become a popular approach for scaling the parameters of large language models. Inspired by this, Fusion Multi-Head Attention (HMA) treats the attention heads as experts, which can adaptively assign different weights to features, thereby enhancing attention to subtle textural features. Specifically, HMA consists of h = {H...} 1 H 2 ,...,H h The routes consist of} and the Top-K activation heads. Formally, for each T×d in Dimensional labeling and each T'×d in Dimensional labeling The output of HMA is a weighted sum of the outputs of K selected heads:

[0063]

[0064] Among them, g i This represents the routing score. g is only calculated when the i-th attention head is activated. i It is not zero. This is the final projection matrix. This design offers two key advantages for silk fabric defect detection tasks: First, due to the reproducibility of features in normal silk fabric samples, HMA enables each token to select the most relevant attention head, improving inference efficiency while maintaining accuracy. Second, compared to standard summation in multi-head attention, weighted summation in multi-head attention enhances the flexibility of the attention mechanism, unlocking its performance potential.

[0065] Meanwhile, some attention heads may capture common knowledge in different contexts, such as repetitive features of different textures. Inspired by Dai et al.

[19] , HMA designates a subset of attention heads as shared heads that are always active. By integrating common knowledge within shared heads, redundancy among other dynamic routing heads is reduced.

[0066] Finally, a two-phase routing strategy is used to dynamically balance the weights between shared headers and route headers. In this routing strategy, the route score is determined by the score of each header and a score associated with the header type. Specifically, given... The t-th input token Then the routing score g i Defined as:

[0067]

[0068] Where β = if(W r x t ) i ∈Top-K({(W r xt ) i |h s +1≤i≤h s}), h s Indicates the number of shared headers. Let represent the projection matrices of the shared header and the routing header, respectively. The coefficients α1 and α2 balance the contributions of the shared header and the routing header, and are defined as follows:

[0069] [α1,α2]=Softmax(W h x t )

[0070] in, For a trainable projection matrix, d in For x t Size.

[0071] 4. Loose Reconstruction

[0072] Current mainstream feature reconstruction frameworks extract specific encoder layers (e.g., the last 3 layers of ResNet) through corresponding decoder layers. Figure 3 (a)). Intuitively, using more encoder-decoder feature pairs ( Figure 3 (b) The reconstruction model can utilize more information from different layers to identify anomalies. However, with more layer-to-layer supervision, the decoder may exhibit behavior stronger than the encoder, which is detrimental to reconstruction models that detect anomalies through encoder-decoder differences. Considering the top-to-bottom consistency of the columnar Transformer layers, a loose reconstruction is adopted where the modified decoder sums all feature maps of the layers of interest as a whole, i.e., group-to-group constraints, such as... Figure 3 As shown in (c). This scheme can be seen as relaxing the layer-to-layer correspondence, so the decoder behaves more differently from the encoder when the input pattern is not visible. Since shallow features contain low-level visual features, they aid in accurate localization. Features can also be further divided into low-level feature groups and high-level feature groups, such as... Figure 3 As shown in (d).

[0073] The framework of this invention uses the global cosine loss from hard mining

[20] as the reconstruction loss function, which separates the gradients of feature points with low cosine distance during training. Let f E and f D These represent the feature maps of the encoder and decoder, respectively.

[0074]

[0075]

[0076] in, Indicates the flattening operation, f D (h,w) represents the feature point at (h,w), sg(·) 0.1 This means reducing the gradient to one-tenth of its original value. This means selecting 90% of the feature points with smaller cosine distances within a batch.

[0077] 5. Loss Function

[0078] Considering the subtlety and repetitiveness of silk fabric features, this invention adds a contrast constraint loss to narrow the distance between similar features. Specifically, for similar texture features, the goal is to reduce their distance to aid the decoder's learning. Conversely, for features with different textures, the goal is for the decoder to distinguish between them.

[0079]

[0080] Among them, y i The label representing whether sample i belongs to the same category, d 2 The distance between feature vectors of sample i is the square of the distance between them. N represents the number of samples. The margin is a boundary parameter used to control the distance between samples of the same class and the distance between samples of different classes.

[0081] The final total loss is the average of the global cosine loss and the contrast constraint loss.

[0082]

[0083] 6 Experiments

[0084] To evaluate the effectiveness of the algorithm of this invention on real silk fabric data, this invention was compared with several recently published algorithms on the AITEX and Kagglefabric datasets, and the interaction between the various modules was explored on these two datasets. Specifically, this invention compared DMAD

[23] , MMR

[24] , RD

[26] , RD++

[27] , Efficien_ad

[25] , Dinomaly

[21] , Csflow

[22] , and Simplenet

[28] . The method of this invention uses three evaluation metrics. Image-level anomaly detection performance is measured by the area under the receiver operator curve (AUROC), denoted as I-AUROC. Pixel-level AUROC and area under per-region-overlap (AUPRO) are used to measure pixel-level anomaly localization, denoted as P-AUROC and PRO-AUROC, respectively.

[0085] 6.1 Parameter Selection

[0086] This invention utilizes ablation experiments on the AITEX and Kaggle fabric datasets to validate the effectiveness of the proposed model components: Noise Bottleneck (MD), Fusion Multi-Head Attention (HMA), and Loss (LS). The results are shown in Table 1. The current state-of-the-art baseline model incorporates a MeanDropout bottleneck, Fusion Multi-Head Attention (HMA), dense layer-to-layer reconstruction, and cosine contrastive loss. The results demonstrate the significant impact of HMA, as it reduces redundancy among other dynamic routing headers by integrating common knowledge within a shared header. Furthermore, MD and LS further enhance performance in conjunction with HMA.

[0087] Table 1 shows the performance of different modules on the AITEX and Kaggle Fabric datasets.

[0088]

[0089]

[0090] 6.2 Qualitative Comparison

[0091] To intuitively verify the defect detection performance of the algorithm of this invention. Figure 4 A visualization example of defect detection on two datasets is presented. The first column of the figure is the test image, the second column is the test data mask, and the third column is the anomaly segmentation map. This invention uses a method to annotate subtle regions of the images, facilitating a more intuitive verification of the results. It can be seen that the proposed class reconstruction anomaly detection framework based on multi-head attention achieves good defect detection performance. This method can also effectively locate anomaly regions even against the backdrop of extremely subtle defects in silk fabrics.

[0092] 6.3 Quantitative Comparison

[0093] Table 2 shows the evaluation results on the AITEX and Kaggle fabric test sets. The top three performers are indicated by bold, red, and green, respectively. The results show that the proposed method achieves 100.0% I-AUROC on both datasets. On the AITEX dataset, it surpasses the state-of-the-art methods EfficienAD and Dinomaly by 7.7% and 2.1%, respectively. On the Kaggle fabric dataset, it matches Simplenet and surpasses the second-best method by 0.6%. Furthermore, compared to other methods, the proposed model shows a significant improvement in I-AUROC. This is because there is no significant visual difference between defective and normal images of silk fabrics. In addition, some defects are very subtle and difficult to distinguish; unsupervised methods without specific design may fall into overfitting and fail to effectively distinguish the boundary between normal and abnormal areas.

[0094] Table 2 Quantitative Comparison with Advanced Algorithms

[0095]

[0096]

[0097] The experiments of this invention used pixel-level AUROC and region-by-region overlap area PRO-AUROC for evaluation. It can be seen that the proposed method achieved the best P-AUROC (96.0%) and PRO-AUROC (62.0%) on the AITEX dataset, demonstrating superior pixel-level localization performance. On the Kaggle fabric dataset, it is noted that the proposed method is slightly inferior to EfficienAD. This may be because the Kaggle fabric dataset contains silk fabric samples of various colors, resulting in small differences between normal and defective features. Therefore, the reconstruction performance is relatively lower compared to knowledge distillation, but in terms of image-level performance, the proposed method outperforms EfficienAD. It is worth noting that there are significant numerical differences in I-AUROC, P-AUROC, and PRO-AUROC on the Kaggle fabric dataset. This is because in the Kaggle fabric silk fabric test dataset, most background color pixels are not significantly different from the normal silk fabric samples, and the distribution of normal and abnormal samples is uneven, resulting in numerical bias. This is also one of the reasons why various methods have high image-level metrics but large differences in pixel-level localization. Nevertheless, the proposed method achieved satisfactory results.

[0098] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor, wherein when the processor executes the computer program instructions, it can implement the steps of the method described above.

[0099] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied 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.

[0100] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this 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, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0101] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing 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, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0102] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0103] References:

[0104] [1] Tao Xian, Hou Wei, Xu De. A review of surface defect detection methods based on deep learning. Acta Automatica Sinica, 1017-1034, 2021.

[0105] [2] Yang Enjun, Liao Yihui, Liu Andong, et al. Fabric defect detection based on low-rank decomposition. Journal of Textile Research, 72-78, 2020.

[0106] [3] Ma Mingyin, Di Lan, Liang Jiuzhen. Textile defect detection based on image correction and template segmentation. Journal of Nanjing University (Natural Science), 29-41, 2021.

[0107] [4]R Han,L Zhang.Fabric Defect Detection Method Based on Gabor FilterMask.IEEE Computer Society,184–188,2009.

[0108] [5]J Jing,D Zhuo,H Zhang,et al.Fabric defect detection using theimproved YOLOv3model.Journal ofEngineered Fibers and Fabrics,15,2020.

[0109] [6]AshishVaswani,Noam Shazeer,Niki Parmar,et al.Attention is all youneed.NeurIPS,2017.

[0110] [7]Paul Michel,Omer Levy,Graham Neubig.Are sixteen heads reallybetter than one?NeurIPS,14014–14024,2019.

[0111] [8]Alexey Dosovitskiy,Lucas Beyer,Alexander Kolesnikov,et al.An imageis worth 16x16words:Transformers for image recognition at scale.ICLR,2021.

[0112] [9]Dong Gong,Lingqiao Liu,Vuong Le,et al.Memorizing normality todetect anomaly:Memory-augmented deep autoencoder for unsupervised anomalydetection.2019IEEE / CVF International Conference on Computer Vision,1705–1714,2019.

[0113]

[10] Zhoufeng Liu,Chengli Gao,Chunlei Li,et al.Unsupervised fabricdefect detection based on dcgan with component-encoder.Pattern Recognition,557–568,2022.

[0114]

[11] Juhua Liu,Chaoyue Wang,Hai Su,et al.Multistage GAN for fabricdefect detection.IEEE Transactions on Image Processing,3388–3400,2020.

[0115]

[12] J.Goodfellow,Jean Pouget-Abadie,Mehdi Mirza,et al.Generativeadversarial nets.the 27th International Conference onNeural InformationProcessing Systems(NeurIPS),2672–2680,2014.

[0116]

[13] T.Reiss,N.Cohen,E.Horwitz,et al.Anomaly detection requires betterrepresentations.European Conference on ComputerVision(ECCV),56–68,2022.

[0117]

[14] Y.Lee,H.Lim,H.Yoon,Selformaly:Towards task-agnostic unifiedanomaly detection.arXiv:2307.12540,2023.

[0118]

[15] T.Darcet,M.Oquab,J.Mairal,et al.Vision transformers needregisters.arXiv:2309.16588,2023.

[0119]

[16] Dong Gong,Lingqiao Liu,Vuong Le,et al.Memorizing normality todetect anomaly:Memory-augmented deep autoencoder for unsupervised anomalydetection.2019 IEEE / CVFInternational Conference on Computer Vision,1705–1714,2019.

[0120]

[17] Zhoufeng Liu,Chengli Gao,Chunlei Li,et al.Unsupervised fabricdefect detection based ondcgan with component-encoder.Pattern Recognition,557–568,2022.

[0121]

[18] Juhua Liu,Chaoyue Wang,Hai Su,et al.Multistage GAN for fabricdefect detection.IEEETransactions on Image Processing,3388–3400,2020.

[0122]

[19] Damai Dai,Chengqi Deng,Chenggang Zhao,et al.Deepseekmoe:Towardsultimate expertspecialization in mixtureof-experts language models.arXiv:2401.06066,2024.

[0123]

[20] J.Guo,S.Lu,L.Jia,et al.Recontrast:Domain-specific anomalydetection via contrastivereconstruction.Neural Information Processing Systems(NeurIPS),10721–10740,2023.

[0124]

[21] Y.Zhao.Omnial:A unified CNN framework for unsupervised anomalylocalization.IEEE / CVF Conference on Computer Vision and Pattern Recognition(CVPR),3924–3933,2023.

[0125]

[22] Marco Rudolph,Tom Wehrbein,Bodo Rosenhahn.Fully convolutionalcross-scale-flows forimage-based defect detection.2022 IEEE / CVF WinterConference on Applications of ComputerVision,1829–1838,2022.

[0126]

[23] Wenrui Liu,Hong Chang,Bingpeng Ma,et al.Diversity measurableanomaly detection.2023IEEE / CVF Conference on Computer Vision and PatternRecognition,12147–12156,2023.

[0127]

[24] Zilong Zhang,Zhibin Zhao,Xingwu Zhang,et al.Industrial anomalydetection with domainshift:A real-world dataset and masked multi-scalereconstruction.Computers in Industry,103990,2023.

[0128]

[25] Kilian Batzner,Lars Heckler,and Rebecca Konig.Efficient_ad:Accurate visual anomalydetection at millisecond-level latencies.2024 IEEE / CVFWinter Conference on Applications ofComputer Vision,127–137,2024.

[0129]

[26] Hanqiu Deng and Xingyu Li.Anomaly detection via reversedistillation from one-classembedding.2022 IEEE / CVF Conference on ComputerVision and Pattern Recognition,9727–9736,2022.

[0130]

[27] Tran Dinh Tien,Anh Tuan Nguyen,Nguyen Hoang Tran,et al.Revisitingreverse distillation for anomaly detection.2023IEEE / CVF Conference onComputer Vision and Pattern Recognition,24511–24520,2023.

[0131]

[28] Zhikang Liu,Yiming Zhou,Yuansheng Xu,et al.Simplenet:A simplenetwork for image anomaly detection and localization.IEEE / CVF Conference onComputer Vision and Pattern Recognition(CVPR),20402–20411,2023.。

[0132] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. An unsupervised silk fabric defect detection method based on a fusion multi-head attention reconstruction network, characterized in that, A silk fabric defect detection framework based on a fusion multi-head attention reconstruction network is proposed, which is composed of a Transformer pre-training feature encoder, a bottleneck layer with MeanDropout and a fusion attention decoder.

2. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 1, characterized in that, Specifically comprising: A pre-trained visual Transformer (ViT) is used as a feature encoder to extract discriminative features of silk fabric images as reconstruction objects. The extracted features are input into a bottleneck layer with MeanDropout to obtain a multi-layer feature combination. A fusion attention decoder is proposed to combine the multi-layer feature combination into a whole for loose reconstruction, i.e., not forced layer-by-layer and point-by-point reconstruction, thereby relaxing the reconstruction constraints.

3. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 1 or 2, characterized in that, The feature encoder is implemented as follows: Given a training image x train The feature extraction process of the feature encoder is defined as: e = φ(x train ) where φ represents a pre-trained DINOv2 network with registers, e represents the features extracted by the pre-trained DINOv2 network, and the pre-trained DINOv2 network with registers is based on Transformer.

4. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 1 or 2, characterized in that, The bottleneck layer with MeanDropout uses Mean Dropout as a feature noise scheme, which uses the mean value to fill in the discarded elements to reduce the model's dependence on specific subtle features, and is represented as follows: where e represents the features extracted by the pre-trained DINOv2 network with registers, p represents the probability of retaining features, and mean(e) represents the use of the average value to replace the features with a probability of (1-p).

5. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 1 or 2, characterized in that, The fusion attention decoder is a decoder that combines the fusion multi-head attention mechanism HMA and the LLamaMLP.

6. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 5, characterized in that, The fusion multi-head attention mechanism HMA regards attention heads as experts, and the expert heads can adaptively assign different weights to features to improve the attention to subtle texture features. Specifically, HMA is composed of h={H 1 , 2 ..., h H} and the routing of Top-K activated heads. Formally, for each Txd in dimensional marker and each T'd in dimensional marker The output of HMA is the weighted sum of the outputs of the K selected heads: where H i represents the i-th attention head, g i represents the routing score, which is only non-zero when the i-th attention head is activated; i is the final projection matrix;​ At the same time, HMA specifies a subset of attention heads as shared heads that are always activated, reducing redundancy between other dynamically routed heads by integrating common knowledge within the shared heads, Finally, the weights between the shared head and the routing head are dynamically balanced using a two-stage routing strategy, in which the routing score is determined by the score of each head and the score related to the head type; specifically, given the tth input token in the routing score g is defined as: i ​ where β = if(W r x t ) i ∈ Top-K({(W r x t ) i |h s +1≤i≤h s}) represents selecting the feature points with the activation head smaller than the attention head, h s represents the number of shared heads, and represent the projection matrices of the shared head and the routing head, respectively, the activation function Softmax maps the output to 0-1, and the coefficients a1 and a2 balance the contributions of the shared head and the routing head, which are defined as: [α1, α2] = Softmax(W h x t ) wherein, is a trainable projection matrix, d in is x t size.

7. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 2, characterized in that, The loose reconstruction of the multi-layer feature combination is to add up all the features of the layer of interest in the multi-layer feature combination as a whole for loose reconstruction, i.e., group-to-group constraints.

8. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 1, characterized in that, The silk fabric defect detection framework based on the fusion multi-head attention reconstruction network adopts a hard-mining global cosine loss as a reconstruction loss function, where f E and f D respectively represent feature mapping of the encoder and the decoder, and the global cosine loss is represented as follows: where, represents taking cos value for input, represents flattening operation, f D (h,w) represents feature points at (h,w), sg(·) 0.1 represents reducing gradient to one tenth of original, represents selecting 90% of feature points with smaller cosine distance within one batch.

9. The unsupervised silk fabric defect detection method based on the fusion multi-head attention reconstruction network according to claim 8, characterized in that, Considering the subtlety and repetition of silk fabric features, an additional contrast constraint loss is added to narrow the distance between similar features, and the contrast constraint loss function is represented as follows: wherein y i represents the label indicating whether the sample i belongs to the same class, d 2 represents the square of the distance between the feature vectors of the sample i, N represents the number of samples, and margin is a boundary parameter for controlling the distance between samples of the same class and the distance between samples of different classes. The final overall loss is the average of the sum of the global cosine loss and the contrast constraint loss:

10. A computer-readable storage medium having stored thereon computer program instructions capable of being executed by a processor, when the processor executes the computer program instructions, the method steps of any one of claims 1-9 can be implemented.

Citation Information

Cited By

  • Image retrieval model training method, image retrieval method, equipment and medium

    CN121706857A

  • Network security risk detection method based on machine learning

    CN122119977A