A textile fiber nondestructive testing method and device and a storage medium

By constructing a non-destructive testing method for textile fibers based on convolutional neural networks and multi-head attention, and utilizing multi-head self-attention and cross-attention mechanisms, rapid and accurate identification of textile fibers is achieved, solving the problems of low fiber detection efficiency and low accuracy in existing technologies.

CN115294077BActive Publication Date: 2025-11-11DONGHUA UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210961308.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2025-11-11
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

Existing textile fiber detection methods require damaging the fabric, resulting in low efficiency and low recognition accuracy. They cannot meet the needs of large-scale rapid detection and immediate consumer detection. Furthermore, convolutional neural networks and Transformer models suffer from problems such as loss of small target features and insufficient consideration of shape specificity when identifying fibers.

Method used

A non-destructive testing method for textile fibers based on convolutional neural networks and multi-head attention is adopted. The fiber category features are extracted by multi-head self-attention mechanism and fiber features are located by multi-head cross-attention mechanism. An automatic fiber identification model is constructed to realize the identification of non-destructive fabric fibers.

Benefits of technology

It enables rapid and accurate identification of textile fibers, solving the problem of insufficient accuracy of convolutional neural networks and Transformer models in fiber identification, and is suitable for non-destructive testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115294077B_ABST
    Figure CN115294077B_ABST
Patent Text Reader

Abstract

This invention relates to a method, apparatus, and storage medium for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention. The method includes: acquiring a dataset of fabric surface images and fiber category information; preprocessing; adding position encoding; constructing an automatic fiber identification model, wherein the automatic fiber identification model includes a fiber feature extraction module based on a convolutional neural network, a fiber identification module based on a multi-head attention mechanism, a linear projection module, and an output judgment module; training the automatic fiber identification model based on the preprocessed fabric surface image dataset and the fiber category information containing position encoding; completing training when the loss function of the automatic fiber identification model converges; and performing non-destructive fiber detection of textiles based on the trained automatic fiber identification model. Compared with existing technologies, this invention has advantages such as high detection efficiency and non-destructive detection of the fabric under test.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of nondestructive testing, and in particular to a method, apparatus, and storage medium for nondestructive testing of textile fibers based on convolutional neural networks and multi-head attention. Background Technology

[0002] Fiber composition has a significant impact on the comfort, warmth, and moisture-wicking properties of clothing. Therefore, textiles sold on the market are required to clearly label their fiber composition. However, some manufacturers deliberately mislabel their composition for profit, such as labeling cheap synthetic fabrics as high-quality natural fibers like cotton or wool. These actions seriously disrupt market order and harm consumer interests. Therefore, textile composition identification is one of the main concerns for market regulators and consumers. Currently, the mainstream method for textile fiber testing involves damaging the fabric and extracting a portion of the fibers for testing. This method is inefficient, costly, and easily influenced by subjective factors. These methods are neither convenient for large-scale, rapid fiber composition testing by relevant regulatory departments nor suitable for immediate testing by ordinary consumers when purchasing consumer goods. With the development of computer vision technology, convolutional neural networks have begun to assist in fiber identification technology. However, such fiber identification methods still require damaging the clothing to create samples and are limited by the inherent limitations of convolutional neural networks in classifying small objects. This results in low automation levels for current fiber detection and reliance on experienced operators. In 2017, the Google Translate team proposed a Transformer model that completely replaced convolutional kernels for feature extraction using an attention mechanism. This model, along with related improvements, achieved great success in natural language processing and became the mainstream model. In the last two years, Transformer-based neural networks have also begun to emerge in the field of computer vision. However, these Transformer models for computer vision require segmenting the input image into multiple small blocks according to certain rules. During segmentation, the unique characteristics of fiber shapes in fabrics, such as fiber curling, overlapping, and entanglement, cannot be taken into account. Therefore, Transformer-based neural networks exacerbate the imbalance in the types and quantities of fibers in the input image, resulting in poor fiber recognition accuracy. Summary of the Invention

[0003] The purpose of this invention is to provide a method, device, and storage medium for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention. It extracts fiber category features based on a multi-head self-attention mechanism and locates the fiber features of each fiber category through a multi-head cross-attention mechanism. It adaptively extracts the required features from the data, thereby achieving rapid identification of non-destructive fabrics of each fiber type in fabric images with high recognition accuracy.

[0004] The objective of this invention can be achieved through the following technical solutions:

[0005] A non-destructive testing method for textile fibers based on convolutional neural networks and multi-head attention includes the following steps:

[0006] Acquire a dataset of fabric surface images and fiber category information, wherein the fiber category information contains multiple vectors, and each vector corresponds to a fiber category;

[0007] Preprocess the fabric surface image dataset;

[0008] Position encoding is added to fiber category information based on sine and cosine functions;

[0009] An automatic fiber identification model is constructed, comprising a fiber feature extraction module based on a convolutional neural network, a fiber identification module based on a multi-head attention mechanism, a linear projection module, and an output judgment module.

[0010] The fiber feature extraction module is a convolutional neural network consisting of one regular convolutional module and four groups of residual convolutional modules. The regular convolutional module includes convolutional layers, batch normalization layers, ReLU functions, and pooling layers. Each group of residual convolutional modules includes one residual sub-module 1 and multiple residual sub-modules 2. The output of the fiber feature extraction module is the fiber spatial features.

[0011] The fiber recognition module consists of two Transformer decoding layers. Each Transformer decoding layer includes a self-attention module, a cross-attention module, and a position-feedforward network module connected sequentially. Both the self-attention and cross-attention modules employ a multi-head attention mechanism. The input to the self-attention module is fiber category information and fiber category information including position encoding. The input to the cross-attention module is the output of the self-attention module, fiber spatial features, and fiber spatial features including position encoding. The fiber spatial features including position encoding are obtained by adding position encoding to the fiber spatial features using sine and cosine functions. The position-feedforward network module connects two-dimensional linear transformation layers based on the ReLU activation function, enhancing the output of the cross-attention module and outputting a fiber category feature vector.

[0012] The linear projection module linearly projects the feature vector output by the fiber identification module into the probability value of the fiber category based on the Sigmoid function.

[0013] The output judgment module determines whether a fiber of a certain category exists based on the probability value of the fiber category.

[0014] The automatic fiber identification model is trained based on the preprocessed fabric surface image dataset and fiber category information containing position encoding. The training is completed when the loss function of the automatic fiber identification model converges.

[0015] The trained automatic fiber identification model is used to perform fiber detection in non-destructive textiles.

[0016] The preprocessing includes image reduction, rotation, and cropping operations.

[0017] The operation of adding location encoding is as follows:

[0018]

[0019]

[0020] in, This represents the data after the position encoding operation is added. This represents the data after adding position encoding when the pixel's position is even. This represents the data after adding position encoding when the pixel position is odd, where pos is the pixel position and d is the dimension of the pixel. modexl The total number of dimensions when performing location encoding on the data.

[0021] The output of the self-attention module is:

[0022]

[0023] Among them, Q i-1 This is the fiber category information output from the previous layer. To add position-coded fiber category information to the output of the previous layer,

[0024] MultiHead(Q,K,V)=Concat(head1,head2,…head n W o

[0025] head i =Attention(QW i Q KW i K VW i V )

[0026]

[0027] Where Q represents the query, K represents the key, V represents the value, and d k W is the scaling parameter. i Q W i K W i V Wo These are the weight parameters.

[0028] The output of the cross-attention module is:

[0029]

[0030] Where F represents the spatial characteristics of the fiber. For fiber spatial features containing position encoding.

[0031] The output of the position feedforward network module is:

[0032]

[0033] Where FFN represents the position feedforward network, max(·) is the ReLU activation function, w1 and w2 are weight parameters, b2 and b2 are bias parameters, and Q is the position of the input. i This is the output fiber category feature vector.

[0034] Before entering the next module, the outputs of the self-attention module, cross-attention module, and position feedforward network module undergo an addition and normalization operation. Specifically, the addition and normalization operation involves adding the output to the input of each module and normalizing it.

[0035] The calculation method of the linear projection module is as follows:

[0036]

[0037] Among them, P m Let W be the probability of belonging to the m-th fiber. m b m Q is the linear projection parameter. m Let m be the feature vector of the m-th fiber output by the fiber identification module, where m = 1, 2, ..., M, and M is the number of fiber categories.

[0038] The loss function is:

[0039]

[0040] Where γ+ and γ- are hyperparameters, with the default γ+ = 0 and γ- = 1, y m It is a binary label representing the presence state of fiber category m in the input fabric surface image, y m =1 indicates the existence of fiber categories m and y. m =0 indicates that fiber category m does not exist.

[0041] A textile fiber non-destructive testing device based on convolutional neural networks and multi-head attention includes a memory, a processor, and a program stored in the memory, wherein the processor executes the program to implement the method described above.

[0042] A storage medium having a program stored thereon, which, when executed, implements the method described above.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] Without damaging the textile, this invention utilizes a convolutional neural network to extract fiber features from fabric images and employs multi-head attention adaptively to match fiber features with fiber category information, achieving rapid and accurate identification of textile fibers. This solves both the problem of convolutional neural networks easily losing features of small targets and the issue of poor fiber recognition accuracy caused by the Transformer model's inability to account for the special characteristics of fiber shapes in the fabric, such as fiber curling, overlapping, and entanglement, when segmenting fiber images into input image blocks. Attached Figure Description

[0045] Figure 1 This is a flowchart of the method of the present invention;

[0046] Figure 2 This is a schematic diagram of the structure of the automatic fiber identification model;

[0047] Figure 3 This is a schematic diagram of the fiber identification module.

[0048] Figure 4 Here are structural diagrams of the residual submodules, where (a) is a structural diagram of residual submodule 1 and (b) is a structural diagram of residual submodule 2. Detailed Implementation

[0049] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.

[0050] A non-destructive testing method for textile fibers based on convolutional neural networks and multi-head attention, such as Figure 1 As shown, it includes the following steps:

[0051] 1) Obtain fabric surface image dataset and fiber category information

[0052] A dataset of images of common fabric surfaces was collected and stored using a commercially available optical magnifying glass connected to a smartphone or laptop. The fabric was placed under the magnifying glass and manually focused until the image on the phone or computer screen was clear, at which point the image was taken. Five images were taken from different positions for each fabric. If a photo of the reverse side of the fabric could be obtained, five more photos were taken from the reverse side using the same method to increase data diversity. Simultaneously, fiber category information was determined for each photo in the dataset. This fiber category information consisted of multiple vectors, with each vector corresponding to a fiber category.

[0053] 2) Preprocess the fabric surface image dataset;

[0054] After reducing the original image to 400×400, rotate the image by 90°, 180°, and 270° to obtain four corresponding images. From each rotated image, randomly crop five 224×224 images to add to the training set.

[0055] 3) Add positional encoding to fiber category information based on sine and cosine functions;

[0056] The operation of adding location encoding is as follows:

[0057]

[0058]

[0059] in, This represents the data after the position encoding operation is added. This represents the data after adding position encoding when the pixel's position is even. This represents the data after adding position encoding when the pixel position is odd, where pos is the pixel position and d is the dimension of the pixel. model The total number of dimensions when performing location encoding on the data.

[0060] 4) Construct an automatic fiber identification model

[0061] The fiber automatic identification model is as follows: Figure 2 As shown, it includes a fiber feature extraction module based on a convolutional neural network, a fiber recognition module based on a multi-head attention mechanism, a linear projection module, and an output judgment module.

[0062] ① Fiber Feature Extraction Module

[0063] The fiber feature extraction module is a convolutional neural network consisting of one conventional convolutional module and four sets of residual convolutional modules, used to extract fabric surface image features and output fiber spatial features.

[0064] A standard convolutional module consists of convolutional layers, batch normalization layers, ReLU functions, and pooling layers. The convolutional layers comprise 64 kernels of size 7×7 with a stride of 2. The pooling layers are 3×3 max pooling layers with a stride of 2. A 224×224 image of the fabric surface is input, processed sequentially through convolutional layers, batch normalization layers, ReLU functions, and pooling layers. The output of this processed image serves as the input to the residual convolutional module.

[0065] The residual convolution module consists of one residual submodule 1 and multiple residual submodules 2, and its structure is as follows: Figure 4 As shown. In residual submodule 1, the input data is sequentially passed through three convolutional layers with kernel sizes of 1×1, 3×3, and 1×1. This result is then added to the input data after passing through a 1×1 convolutional layer to obtain the output. Similarly, in residual submodule 2, the input data is sequentially passed through three convolutional layers with kernel sizes of 1×1, 3×3, and 1×1. This result is then added to the input data to obtain the output. The stride of the 1×1 convolutional kernels is 1, and the stride of the 3×3 convolutional kernels is 2.

[0066] The first group of residual convolutional modules contains one residual submodule 1 and two residual submodules 2;

[0067] The second set of residual convolutional modules includes one residual submodule 1 and three residual submodules 2;

[0068] The third group of residual convolutional modules includes one residual submodule 1 and five residual submodules 2;

[0069] The fourth group of residual convolutional modules contains one residual submodule 1 and two residual submodules 2.

[0070] ② Fiber recognition module

[0071] The fiber recognition module consists of two Transformer decoding layers, each including a self-attention module, a cross-attention module, and a position feedforward network module connected in sequence. Two Transformer decoding layers represent two computations. Before entering the next module, the outputs of the self-attention module, cross-attention module, and position feedforward network module undergo an addition-normalization operation. This addition-normalization operation specifically involves adding the output to the input of each respective module and normalizing it to prevent gradient vanishing or gradient explosion problems during computation. Figure 3 As shown.

[0072] Both the self-attention module and the cross-attention module employ a multi-head attention mechanism.

[0073] MultiHead(Q,K,V)=Concat(head1,head2,…head n W o

[0074] head i =Attention(QW i Q KW i K VW i V )

[0075]

[0076] Where Q represents the query, K represents the key, V represents the value, and d k W is the scaling parameter. i Q W i K W i V W o These are the weight parameters.

[0077] The input to the self-attention module is fiber category information and fiber category information including location encoding, calculated as follows:

[0078]

[0079] Among them, Q i-1 This is the fiber category information output from the previous layer (i.e., the (i-1)th layer). This adds positional encoding to the fiber category information output of the previous layer (i.e., the (i-1)th layer).

[0080] The input to the cross-attention module is the output of the self-attention module, fiber space features, and fiber space features containing position encoding. The fiber space features containing position encoding are obtained by adding position encoding to the fiber space features based on sine and cosine functions. The calculation method is as follows:

[0081] The calculation method for the cross-attention module is as follows:

[0082]

[0083] Where F represents the spatial characteristics of the fiber. For fiber spatial features containing position encoding, This is the output of the self-attention module.

[0084] The position feedforward network module is a fully connected network based on the ReLU activation function, connecting two linear transformation layers. It enhances the output of the cross-attention module, outputting a feature vector for each fiber category. The calculation method is as follows:

[0085]

[0086] Where FFN represents a position-fed network, max(·) is the ReLU activation function, w1 and w2 are weight parameters, and b2 and b3 are bias parameters. Q is the output of the cross-attention module. i This is the fiber category feature vector. These are two transition variables.

[0087] ③ Linear projection module

[0088] The linear projection module linearly projects the feature vector output by the fiber identification module into the probability value of the fiber category based on the Sigmoid function:

[0089]

[0090] Among them, P m Let W be the probability of belonging to the m-th fiber. m b m Q is the linear projection parameter. m Let m be the feature vector of the m-th fiber output by the fiber identification module, where m = 1, 2, ..., M, and M is the number of fiber categories.

[0091] ④ Output Judgment Module

[0092] The output judgment module determines whether a fiber of a certain category exists based on the probability value of the fiber category; when P m If the value is greater than 0.5, then the fiber of that category is considered to exist.

[0093] 5) Train an automatic fiber identification model based on the preprocessed fabric surface image dataset and fiber category information containing location encoding. Training is complete when the loss function of the automatic fiber identification model converges.

[0094] The loss function is:

[0095]

[0096] Where γ+ and γ- are hyperparameters, with the default γ+ = 0 and γ- = 1, y m It is a binary label representing the presence state of fiber category m in the input fabric surface image, y m =1 indicates the existence of fiber categories m and y. m =0 indicates that fiber category m does not exist.

[0097] In this embodiment, the total loss is calculated by averaging the loss of all samples in the training dataset, and is optimized using stochastic gradient descent with a learning rate of 0.00001 and an impulse of 0.9.

[0098] 6) Complete the fiber detection of non-destructive textiles based on the trained automatic fiber identification model.

[0099] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0100] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.

Claims

1. A non-destructive testing method for textile fibers based on convolutional neural networks and multi-head attention, characterized in that, Includes the following steps: Acquire a dataset of fabric surface images and fiber category information, wherein the fiber category information contains multiple vectors, and each vector corresponds to a fiber category; Preprocess the fabric surface image dataset; Position encoding is added to fiber category information based on sine and cosine functions; An automatic fiber identification model is constructed, comprising a fiber feature extraction module based on a convolutional neural network, a fiber identification module based on a multi-head attention mechanism, a linear projection module, and an output judgment module. The fiber feature extraction module is a convolutional neural network consisting of one regular convolutional module and four sets of residual convolutional modules. The regular convolutional module includes convolutional layers, batch normalization layers, ReLU functions, and pooling layers. Each set of residual convolutional modules includes one residual submodule 1 and multiple residual submodules 2. The output of the fiber feature extraction module is the fiber spatial features. The input data of residual submodule 1 is sequentially passed through three convolutional layers with kernel sizes of 1×1, 3×3, and 1×1, and then added to the input data after passing through a 1×1 convolutional layer to obtain the output. The input data of residual submodule 2 is sequentially passed through three convolutional layers with kernel sizes of 1×1, 3×3, and 1×1, and then added to the input to obtain the output. The stride of the 1×1 convolutional kernels is 1, and the stride of the 3×3 convolutional kernels is 2. The first group of residual convolutional modules contains one residual submodule 1 and two residual submodules 2; The second set of residual convolutional modules includes one residual submodule 1 and three residual submodules 2; The third group of residual convolutional modules includes one residual submodule 1 and five residual submodules 2; The fourth group of residual convolutional modules contains one residual submodule 1 and two residual submodules 2; The fiber recognition module consists of two Transformer decoding layers. Each Transformer decoding layer includes a self-attention module, a cross-attention module, and a position-feedforward network module connected sequentially. Both the self-attention and cross-attention modules employ a multi-head attention mechanism. The input to the self-attention module is fiber category information and fiber category information including position encoding. The input to the cross-attention module is the output of the self-attention module, fiber spatial features, and fiber spatial features including position encoding. The fiber spatial features including position encoding are obtained by adding position encoding to the fiber spatial features using sine and cosine functions. The position-feedforward network module connects two-dimensional linear transformation layers based on the ReLU activation function, enhancing the output of the cross-attention module and outputting a fiber category feature vector. The linear projection module linearly projects the feature vector output by the fiber identification module into the probability value of the fiber category based on the Sigmoid function. The output judgment module determines whether a fiber of a certain category exists based on the probability value of the fiber category. The automatic fiber identification model is trained based on the preprocessed fabric surface image dataset and fiber category information containing position encoding. The training is completed when the loss function of the automatic fiber identification model converges. The trained automatic fiber identification model is used to perform fiber detection in non-destructive textiles.

2. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention as described in claim 1, characterized in that, The operation of adding location encoding is as follows: in, This represents the data after the position encoding operation is added. This represents the data after adding position encoding when the pixel's position is even. This represents the data after adding position encoding when the pixel's position is odd. pos For pixel position, d It is the dimension where the pixel is located. The total number of dimensions when performing location encoding on the data.

3. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention as described in claim 2, characterized in that, The output of the self-attention module is: =MultiHead( , , ) in, This is the fiber category information output from the previous layer. To add fiber category information to the output of the previous layer with added position encoding, in, Indicates a query. Indicates key, Represents value, For scaling parameters, , , , These are the weight parameters.

4. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention according to claim 3, characterized in that, The output of the cross-attention module is: =MultiHead( , ,F) Where F represents the spatial characteristics of the fiber. For fiber spatial features containing position encoding.

5. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention according to claim 4, characterized in that, The output of the position feedforward network module is: Where FFN represents a position-fed network, and max(·) is the ReLU activation function. For weight parameters, For bias parameters, This is the output fiber category feature vector.

6. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention according to claim 1, characterized in that, Before entering the next module, the outputs of the self-attention module, cross-attention module, and position feedforward network module undergo an addition and normalization operation. Specifically, the addition and normalization operation involves adding the output to the input of each module and normalizing it.

7. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention according to claim 1, characterized in that, The calculation method of the linear projection module is as follows: in, For belonging to the first m The probability of fiber-like structures. , For linear projection parameters, The first output of the fiber identification module m Fiber-like feature vectors , This represents the number of fiber categories.

8. The method for non-destructive testing of textile fibers based on convolutional neural networks and multi-head attention according to claim 7, characterized in that, The loss function is: Where γ+ and γ- are hyperparameters, It is a binary label representing the fiber category in the input fabric surface image. m The state of existence, This indicates the existence of fiber categories. m , This indicates that no fiber category exists. m .

9. A non-destructive testing device for textile fibers based on convolutional neural networks and multi-head attention, comprising a memory, a processor, and a program stored in the memory, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-8.

10. A storage medium having a program stored thereon, characterized in that, When the program is executed, it implements the method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Human body action recognition method based on dual-channel residual neural network

    CN110348494A

  • Image description generation method and device, equipment and medium

    CN114743018A