Method and device for detecting weft skew angle of fabric

By designing a regression head module with an expert gating mechanism on the ResNet18 backbone, angle detection with multi-expert fusion is achieved, solving the accuracy problem of traditional weft skew detection technology under complex fabric textures and lighting changes, and improving the accuracy and stability of fabric weft skew angle detection.

CN121639685APending Publication Date: 2026-03-10CHANGZHOU HONGDA INTELLIGENCE TECHNOLOGY CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610155407.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-04
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Traditional weft skew detection technology has low accuracy when dealing with complex fabric textures, making it difficult to meet the industrial testing needs of multiple types of fabrics. Furthermore, changes in lighting conditions and noise interference lead to a decrease in detection accuracy.

Method used

A regression head module with an expert gating mechanism is designed on the ResNet18 backbone network. Through the multi-expert fusion angle detection mechanism, the expert angle regression head performs expert-based regression on the feature maps of each layer, outputs the sine and cosine components of the latitudinal oblique angle, and calculates the final angle of the latitudinal oblique angle.

Benefits of technology

It significantly improves the detection accuracy of fabric weft skew angle, reducing the average absolute error from 1.67° in the traditional method to 0.37°, enhancing the model's generalization ability and robustness, and enabling it to maintain stable and reliable detection accuracy in complex industrial environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121639685A_ABST
    Figure CN121639685A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of fabric skew detection. The invention provides a fabric weft skew angle detection method and device. The method comprises the steps that a fabric yarn image is collected and preprocessed, and an input image of a standard size is obtained; and inputting the input image into the ResNet18 backbone network with the classification head removed to extract each layer of feature map, performing expert shunt regression on each layer of feature map through the expert angle regression head, outputting sine and cosine components of the weft oblique angle, and calculating to obtain the final angle of the weft oblique angle. In this way, a regression head module with an expert gating mechanism is designed on the basis of a ResNet18 backbone network, a multi-expert fusion angle detection mechanism is achieved, the limitation that a traditional detection algorithm is limited by the principle and only can be optimized for a single texture type is broken through, specific image processing algorithms do not need to be developed for different fabric types, and the detection efficiency is improved. The detection efficiency is greatly improved, and reliable technical support is provided for intelligent textile manufacturing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of fabric skew detection, and in particular to a fabric skew angle detection method and device. BACKGROUND

[0002] In the field of textile manufacturing, fabric skew is a common defect that seriously affects product quality. Its characteristic is that the weft yarn deviates from the ideal horizontal position and forms an inclination. This defect not only damages the appearance quality and touch experience of the fabric, but also causes size precision deviation and texture deformation problems in subsequent printing and dyeing processing, cutting and sewing, and other key production links. Therefore, developing high-precision fabric skew detection and intelligent correction technology has important engineering practical value for promoting the production automation and intelligent transformation and upgrading of the textile industry.

[0003] Traditional skew detection technology is mainly based on image processing algorithms, including geometric fitting, Fourier direction transformation, and edge direction histogram analysis methods. This kind of technology performs well when dealing with plain fabrics with simple texture structure and single pattern, but faces significant technical bottlenecks in actual production environments. When encountering complex fabric textures such as twill and satin, where the yarn pattern is not obvious, the traditional algorithm is prone to false detection due to the diversity, non-periodicity and complexity of the texture pattern. In addition, changes in lighting conditions and image noise interference commonly found in production sites also cause a sharp decline in detection accuracy, making it difficult to meet the industrial detection needs of multiple types of fabrics.

[0004] In recent years, deep learning technology has brought new solutions to skew detection. Researchers have begun to explore the use of convolutional neural networks to automatically learn fabric texture features and implement angle detection through regression models. However, existing model architectures have obvious defects. They generally use fully connected layers with limited expression ability as the regression output head and only use simple angle normalization processing to detect the results. This simplified modeling approach cannot capture the deep nonlinear mapping relationship between complex texture features and angle changes, ultimately restricting the detection accuracy and engineering applicability of the model. SUMMARY

[0005] To solve the above problems, the present application designs a regression head module with an expert gate mechanism based on the ResNet18 backbone network, realizes a multi-expert fusion angle detection mechanism, and achieves high-precision angle estimation within ±30°, providing control basis for subsequent weft straightening correction equipment.

[0006] According to an embodiment of the present application, a fabric skew angle detection method and device are provided.

[0007] In a first aspect of the present application, a fabric skew angle detection method is provided. The method comprises: Step S01: Acquire images of fabric yarns and preprocess them to obtain standard-sized input images; Step S02: Input the input image into the ResNet18 backbone network with the classification head removed to extract the feature maps of each layer. Perform expert-based regression on the feature maps of each layer using an expert angle regression head, output the sine and cosine components of the latitudinal oblique angle, and calculate the final angle of the latitudinal oblique angle.

[0008] Furthermore, the specific steps in step S02, which involve inputting the input image into the ResNet18 backbone network (after removing the classification head) to extract feature maps from each layer, are as follows: The input image is downsampled for the first time by convolution, BN, and ReLU activation; then it is downsampled further by max pooling; then basic features are constructed by two basic feature blocks, BasicBlock, without downsampling at this stage; subsequently, three rounds of downsampling are completed by passing through the basic feature blocks, BasicBlock, using convolution kernels of a specified size, and adjusting the convolution stride and number of channels, and the corresponding features are output after each round of downsampling; finally, the backbone network outputs a list of three multi-scale features [S2, S3, S4].

[0009] Furthermore, the expert-perspective regression head mentioned in step S02 includes: a multi-scale compatibility and fusion module, a cosine gating module, a shared trunk module, and a parallel expert head module. The three multi-scale features output by the ResNet18 main network are processed by two branches. One path is first processed by the shared trunk module and the parallel expert head module, outputting two detection dimensions; the other path is input to the cosine gating module to obtain three types of tensors: the similarity result after scaling and temperature adjustment, the normalized routing probability, and the original cosine similarity. Finally, the outputs of the two paths are weighted and fused.

[0010] Furthermore, the processing flow of the multi-scale compatibility and fusion module is as follows: Unify feature dimensions through the unified channel module: , in, For the first Feature maps fused at various scales The list of multi-scale features indivual, For the first Batch size for each feature For embedded dimensions, For the first Each feature map height, The width of the feature map; Next, the features of each layer are compressed into a global description vector using global average pooling: , in, For the first A global description vector at each scale; Attention weights for each level are computed through cross-scale aggregation: , in, For the first Normalized fusion weights at each scale, The scale subscript is used for Softmax normalization, indicating... ,in It is the number of multi-scale features; Finally, the global feature vector is obtained. : , in, This represents the number of multi-scale features.

[0011] Furthermore, the processing flow of the cosine gating module is as follows: Receive the input global feature vector ,in, Indicates batch size, The input feature vector represents the channel dimension. To avoid scale differences interfering with similarity calculation, the input feature vector is first... With prototype vector Perform L2 normalization separately: , in, This represents the input feature vector. Represents the prototype vector; After normalization, all vectors lie on the unit sphere; Calculate the cosine similarity between the input vector and each prototype vector using matrix multiplication: , Received The shape of the tensor is Its range is [−1,1], and the larger the value, the closer the input is to the corresponding prototype; The similarity results are then subjected to scaling and temperature control in sequence: , in, Used to amplify the discriminative power of similarity. Used to control the smoothness of the output distribution; Finally, regarding the adjusted Along the expert dimension conduct Normalization: , get Indicates each sample in The routing probability distribution on each expert has a sum of 1 for each row. The final output consists of three types of tensors: The similarity results, after scaling and temperature adjustment, are used for backpropagation; for The normalized routing probabilities are used for expert weighting; The original cosine similarity is used to analyze the degree of matching between input features and the prototype.

[0012] Furthermore, the processing flow of the shared trunk module is as follows: Receive the input global feature vector After normalization by the first LayerNorm layer, the features are then increased in dimension by a Linear layer, followed by SiLU activation to inject nonlinearity. The second LayerNorm layer then normalizes the increased-dimensional features again. The SwiGLU module performs deep nonlinear processing on the features before passing them to the next Linear layer, where GELU activation further optimizes the feature representation. Finally, a Dropout layer completes regularization, outputting intermediate features. .

[0013] Furthermore, the parallel expert head module contains multiple parallel regression branches, with each expert independently detecting the sine and cosine corresponding to the angle. The specific steps are as follows: Input features ,in, For batch size, For intermediate feature dimensions; start up Each expert branch Perform parallel computation, with each branch working independently. The process involves linear dimensionality increase, GELU activation, Dropout regularization, and linear dimensionality reduction to 2D. Ultimately, each expert outputs a shape... The tensor, column 0 corresponds to The detection value corresponds to the value in column 1. Detection value; Use the torch.stack function to The output tensors of each expert are stacked according to the dimension of the number of experts, forming a shape as follows: The final output, where Corresponding batch size, The corresponding number of experts, 2 corresponds to and Two detection dimensions.

[0014] Further, the step in step S02, which involves outputting the sine and cosine components of the latitude tilt angle and calculating the final angle of the latitude tilt angle, is as follows: ... Expand on the last dimension: , The final output stage uses weights calculated based on cosine gating. Weighted fusion of all expert test results: , in, For experts of Component detection, For experts of Component detection.

[0015] Output Final angle detection: .

[0016] Furthermore, the preprocessing described in step S01 includes color gamut transformation, noise reduction, slight blurring or sharpening, small-area occlusion and erasure enhancement operations, normalization and cropping of the image.

[0017] In a second aspect of the invention, an apparatus for detecting the weft skew angle of a fabric is provided. The apparatus includes: Image acquisition module: used to acquire images of fabric yarns and preprocess them to obtain standard-sized input images; Angle detection module: It is used to input the input image into the ResNet18 backbone network after removing the classification head to extract the feature maps of each layer. The expert angle regression head performs expert-based regression on the feature maps of each layer, outputs the sine and cosine components of the latitudinal oblique angle, and calculates the final angle of the latitudinal oblique angle.

[0018] This invention designs a regression head module with an expert gating mechanism based on the ResNet18 backbone network, realizes a multi-expert fusion angle detection mechanism, achieves high-precision angle estimation within a range of ±30°, and provides control basis for subsequent weft straightening equipment.

[0019] It should be understood that the description in the Summary of the Invention is not intended to limit the key or essential features of the embodiments of the present invention, nor is it intended to restrict the scope of the invention. Other features of the invention will become readily apparent from the following description.

[0020] The above-mentioned English abbreviations are explained as follows: ResNet18: Residual Network 18, an 18-layer residual network BN: Batch Normalization ReLU: Rectified Linear Unit BasicBlock: Basic feature block Conv: Convolution MaxPool: Maximum Pooling LayerNorm: Layer Normalization SwiGLU: Gated Swish Gaussian Error Linear Unit Linear: Linear layer Softmax: Soft maximization function Squeeze: A compression operation (dimensionality reduction) SiLU: S-type linear unit Dropout: Randomized deactivation regularization GELU: Gaussian Error Linear Unit Neck: Neck network FPN: Feature Pyramid Network torch.stack: Tensor stack AdaptiveAvgPool2d: Two-dimensional adaptive average pooling Flatten: to spread out GAP: Global Average Pooling The beneficial effects of this invention are: 1. By adopting an expert regression head structure, the accuracy of fabric weft skew angle detection is significantly improved, and the average absolute error is reduced from 1.67° in the traditional method to 0.37°. At the same time, this structure relies on an expert gating mechanism to achieve feature adaptive splitting, enhances the texture layering modeling capability through a multi-expert network architecture, and avoids the angle periodicity problem by using sin / cos vector output. Through the combined effect of multiple dimensions, the regression accuracy and stability are greatly improved. 2. The design of a multi-expert network focuses on learning the texture features of different fabrics (such as high-frequency plain weave, low-frequency twill weave, and non-periodic printed textures), which enables the model to have stronger generalization ability. It can not only maintain stable and reliable detection accuracy in complex industrial environments such as lighting changes, noise interference, and partial occlusion, but also breaks through the limitation of traditional machine vision methods that are only optimized for a single fabric type. The detection index on a test set covering 70 different fabrics maintains a high accuracy level of MAE=0.37°, which significantly enhances the robustness of industrial applications. 3. The method of using sin / cos output combined with normalized vector loss is adopted, and the optimization mechanism of expert entropy constraint and Top-k strategy is introduced to fundamentally avoid the gradient jump problem caused by angle periodicity. At the same time, it effectively prevents the expert network from becoming unbalanced or collapsing, ensures the collaborative optimization of multiple expert networks, guarantees the stability of the model training process, and solves the inherent defects of traditional methods at the training level. 4. By combining deep learning and expert mechanisms to build an end-to-end intelligent detection solution, we can overcome the limitations of traditional detection algorithms that are only optimized for a single texture type due to their inherent limitations. We can maintain excellent performance on a test set covering 70 types of fabrics, including plain weave, twill weave, and satin weave, without developing specific image processing algorithms for different fabric types. This not only greatly improves detection efficiency but also provides reliable technical support for intelligent textile manufacturing, achieving a qualitative leap in versatility and applicability. Attached Figure Description

[0021] The above and other features, advantages, and aspects of the various embodiments of the present invention will become more apparent from the accompanying drawings and the following detailed description. Wherein: Figure 1 A flowchart of a method for detecting the weft skew angle of a fabric according to an embodiment of the present invention is shown; Figure 2 A schematic diagram of the overall network structure according to an embodiment of the present invention is shown; Figure 3 A schematic diagram of a multi-scale compatibility and fusion module structure according to an embodiment of the present invention is shown; Figure 4 A schematic diagram of a cosine gate module according to an embodiment of the present invention is shown; Figure 5 A schematic diagram of a shared trunk module structure according to an embodiment of the present invention is shown; Figure 6 A schematic diagram of the parallel expert head module structure according to an embodiment of the present invention is shown; Figure 7 The following diagrams show the detection results for different fabric types according to embodiments of the present invention; Figure 8 The following diagram shows the detection results of the same fabric type at different angles according to an embodiment of the present invention; Figure 9 Heat maps of different fabric types according to embodiments of the present invention are shown; Figure 10 A schematic diagram of a discrete scatter plot for real-detection according to an embodiment of the present invention is shown; Figure 11 (a) A schematic diagram of the loss curve according to an embodiment of the present invention is shown; Figure 11(b) A schematic diagram of the MAE curve according to an embodiment of the present invention is shown; Figure 12 A block diagram of a fabric weft skew angle detection device according to an embodiment of the present invention is shown. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] According to an embodiment of the present invention, a method and apparatus for detecting the weft skew angle of a fabric are proposed. By designing a regression head module with an expert gating mechanism on the basis of the ResNet18 backbone network, a multi-expert fusion angle detection mechanism is realized, achieving high-precision angle estimation within a range of ±30°, and providing control basis for subsequent weft straightening equipment.

[0024] The principles and spirit of the present invention will be explained in detail below with reference to several representative embodiments.

[0025] Figure 1 This is a schematic flowchart of a method for detecting the weft skew angle of a fabric according to an embodiment of the present invention. The method includes: Step S01: Acquire images of fabric yarns and preprocess them to obtain standard-sized input images; Step S02: Input the input image into the ResNet18 backbone network with the classification head removed to extract the feature maps of each layer. Perform expert-based regression on the feature maps of each layer using an expert angle regression head, output the sine and cosine components of the latitudinal oblique angle, and calculate the final angle of the latitudinal oblique angle.

[0026] It should be noted that although the operation of the method of the present invention has been described in a specific order in the above embodiments and figures, this does not require or imply that the operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0027] To provide a clearer explanation of the above-mentioned method for detecting the weft skew angle of a fabric, a specific embodiment is described below. However, it is worth noting that this embodiment is only for better illustrating the present invention and does not constitute an improper limitation of the present invention.

[0028] The following specific example will further illustrate a method for detecting the weft skew angle of a fabric: Step S01: Acquire images of fabric yarns and preprocess them to obtain input images of standard size.

[0029] Specifically, industrial cameras are used to capture images of fabric yarns, which are then filtered, normalized, and cropped to obtain standard-sized input images.

[0030] In this embodiment, image data of 70 different fabric samples were collected and loaded, including plain weave and twill weave texture types.

[0031] Each image was captured by an industrial camera, with a uniform pixel size of 512*512.

[0032] The dataset contains 21,440 images with a latitude range of ±30°.

[0033] The dataset is divided into training, validation, and test sets in an 8:1:1 ratio.

[0034] During program execution, the image is first subjected to color gamut transformation, light noise reduction, slight blurring or sharpening, small-area occlusion and erasure enhancement operations, as well as normalization online enhancement operations to improve the model's generalization ability.

[0035] Step S02: As Figure 2 As shown, the input image is fed into the ResNet18 backbone network with the classification head removed to extract the feature maps of each layer. The feature maps of each layer are then subjected to expert-based regression by an expert angle regression head, and the sine and cosine components of the latitudinal oblique angle are output to calculate the final angle of the latitudinal oblique angle.

[0036] In this embodiment, the batch image tensor of 8×3×512×512 is directly fed into the ResNet18 network without a classification head. The backbone network first transforms the input dimension from 8×3×512×512 to 8×64×256×256 through 7×7 convolution (stride 2), BN, and ReLU activation, completing the initial downsampling; then, it undergoes 3×3 max pooling with a stride of 2, further downsampling to 8×64×128×128; next, it passes through Stage 1: 2 BasicBlocks without downsampling, maintaining the dimension of 8×64×128×128, solidifying the basic features; after entering Stage 2, the first BasicBlock uses a 3×3 convolution with a stride of 2 and 64→128 channels, changing the dimension to 8×128×64. The first BasicBlock in Stage 3 is further downsampled to 8×256×32×32 using a 3×3 convolution with a stride of 2 and a channel size of 128→256, outputting the S2 feature. The first BasicBlock in Stage 4 is then downsampled to 8×512×16×16 using a 3×3 convolution with a stride of 2 and a channel size of 256→512, outputting the S4 feature. Finally, the backbone network outputs a list of three multi-scale features [S2, S3, S4], with corresponding dimensions of 8×128×64×64, 8×256×32×32, and 8×512×16×16, respectively.

[0037] Specifically, the expert-perspective regression head includes: a multi-scale compatibility and fusion module, a cosine gating module, a shared trunk module, and a parallel expert head module.

[0038] like Figure 3 As shown, the processing flow of the multi-scale compatibility and fusion (Level Adaptation + Attention Pooling) module is as follows: To address the differences in channel count and scale among features at different levels, a Level Adaptor module is used to unify feature dimensions. , in, For the first Feature maps fused at various scales The list of multi-scale features indivual, For the first Batch size for each feature For embedded dimensions, For the first Each feature map height, The width of the feature map; Next, the features of each layer are compressed into a global description vector using global average pooling (GAP): , in, For the first A global description vector at each scale; Attention weights for each level are calculated using cross-scale aggregation (Level Attention Pooling): , in, For the first Normalized fusion weights at each scale, The scale subscript is used for Softmax normalization, indicating... ,in It is the number of multi-scale features. It is a natural exponential function. For a trainable attention weight matrix, For matrix transpose, For layer normalization; Finally, the global feature vector is obtained. : , in, This represents the number of multi-scale features.

[0039] This feature It combines local texture direction information with global layout structure, providing stable input for subsequent expert gating.

[0040] In this embodiment, the input for multi-scale compatibility and fusion comes from three original multi-scale features S2, S3, and S4 of the ResNet18 backbone. Although these three features cover different spatial resolutions: 64×64 corresponds to 8x downsampling, 32×32 corresponds to 16x downsampling, and 16×16 corresponds to 32x downsampling, the number of channels differs greatly, at 128, 256, and 512 respectively, making it impossible to directly perform cross-scale calculations. At this point, three independent Level Adaptor modules process each scale feature separately: for S2, a 1×1 convolution is used to increase the number of channels from 128 to 512, resulting in an 8×512×64×64 adaptation feature A2; for S3, a 1×1 convolution is used to increase the number of channels from 256 to 512, resulting in an 8×512×32×32 adaptation feature A3; for S4, a 1×1 convolution is used to keep the number of channels unchanged at 512, resulting in an 8×512×16×16 adaptation feature A4. The final output is a multi-scale feature list [A2, A3, A4] with uniform channels, all of which are 512, thus removing format obstacles for cross-scale aggregation.

[0041] Next, we enter the cross-scale attention aggregation stage, where the Level Attention Pooling submodule completes the compression and integration from multi-scale vectors to global vectors: First, we perform global average pooling and flattening on each adaptive feature in [A2,A3,A4]: We compress the spatial dimensions of each feature (64×64, 32×32, 16×16) to 1×1 using AdaptiveAvgPool2d(1), and then remove the spatial dimensions using flatten(1) to obtain three vectors that retain only channel information: g2: 8×512, g3: 8×512, g4: 8×512; The second step is to sort these three vectors by the layer dimension ( The first step involves stacking layers to form an 8×3×512 3D tensor, where 3 corresponds to 3 scales, representing a set of multi-scale features. The second step uses a built-in attention scorer composed of LayerNorm and Linear(512→1) to calculate the importance score for each scale. First, LayerNorm normalizes the 8×3×512 tensor to stabilize the feature distribution. Then, the number of channels is compressed from 512 to 1 using a Linear layer. Finally, a squeeze(-1) is used to remove redundant dimensions, resulting in an 8×3 attention score, with each score corresponding to the contribution of one scale. The third step applies a softmax function to the attention scores. The first step is to normalize the weights of the three scales so that the sum of the weights is 1, resulting in an 8×3 attention weight. The higher the weight value, the greater the contribution of the corresponding scale to the final feature. The fifth step is to perform weighted aggregation, multiplying the attention weights and the 3D tensor by matrix multiplication along the "batch-scale-channel" dimension, finally outputting an 8×512 global feature vector. .

[0042] The entire multi-scale fusion module requires no additional multi-scale neck, such as complex operations like FPN upsampling and convolutional fusion. It achieves format unification and information filtering of multi-scale features solely through "1×1 convolutional channel adaptation" and "attention-weighted aggregation." This preserves the advantages of features at different resolutions: detailed information in high-resolution A2 and global information in low-resolution A4. Furthermore, it adaptively allocates the contribution of each scale through an attention mechanism, ultimately outputting a global feature vector. Key features from all scales have been integrated and can be directly fed into the angle regression head for subsequent detection.

[0043] like Figure 4 As shown, the Cosine Gating module is the core component for implementing feature-adaptive routing. Its main function is to dynamically generate a routing probability distribution based on the cosine similarity between the input feature vector and a set of learnable prototype vectors, which guides the weighted fusion of subsequent parallel expert heads. The overall logic of this module can be divided into two parts: the component initialization phase and the forward propagation phase.

[0044] During the initialization phase, the module defines three types of key parameters: First, prototype vectors, with the shape of... ,in, For the number of experts, To provide input feature dimensions, the module is randomly initialized using a Gaussian distribution with a mean of 0 and a standard deviation of 0.02 during initialization. This ensures that the initial distribution of each prototype is uniform and diverse. These prototype vectors can be regarded as the "semantic centers" of different expert branches in the feature space, used to characterize the feature preferences of each expert. Second, temperature parameters Temperature parameters are used to control the smoothness of the routing probability distribution; smaller values ​​indicate a smoother distribution. This will make the softmax distribution sharper, thus allowing the input features to be more concentratedly allocated to specific experts, while larger... This will result in a smoother distribution of experts; Thirdly, the scaling factor (scale) is used to amplify the numerical range of the similarity distribution to prevent the gradient from being too small. The module also uses a logarithmic parameterization method. The default initial value is the square root of the dimension, which is used to expand the numerical range of cosine similarity and avoid gradient problems caused by excessively small similarity values.

[0045] The forward propagation phase revolves around the logic of "cosine similarity calculation between the input vector and the prototype vector, scaling and temperature adjustment, and probability normalization," as shown in the figure. The processing flow is as follows.

[0046] 1. Input Feature Normalization: Receives the global feature vector as input. ,in, Indicates batch size, This represents the dimension of the feature vector; to avoid scale differences interfering with similarity calculation, the input feature vector is first... With prototype vector Perform L2 normalization separately: , in, Represents the eigenvector. Represents the prototype vector; After normalization, all vectors lie on the unit sphere.

[0047] 2. Cosine similarity calculation: The cosine similarity between the input vector and each prototype vector is calculated using matrix multiplication. , Received The shape of the tensor is Its range is [−1,1], and the larger the value, the closer the input is to the corresponding prototype.

[0048] 3. Scaling and Temperature Adjustment: The similarity results are then subjected to scaling and temperature control. , in, Used to amplify the discriminative power of similarity. Used to control the smoothness of the output distribution.

[0049] 4. Routing probability normalization: Finally, for the adjusted... Along the expert dimension conduct Normalization: , get Indicates each sample in The routing probability distribution on an expert has a sum of 1 for each row.

[0050] The final output consists of three types of tensors: The similarity results, after scaling and temperature adjustment, are used for backpropagation; for The normalized routing probabilities are used for expert weighting; The original cosine similarity is used to analyze the degree of matching between input features and the prototype.

[0051] The Regress Shared Trunk module employs a "LayerNorm, Linear, SwiGLU, Linear, GELU" structure to map input features to a stable, non-linear intermediate representation space. , in, This represents the feature vector after processing along the shared trunk. This indicates that the eigenvector g is processed using a shared trunk path. This represents the second linear transformation (fully connected layer). This represents the first level of linear transformation; This is used to unify the scale and distribution of different samples in the feature space, providing a general intermediate representation for subsequent expert regression.

[0052] The shared trunk module is a core component in the angle regression head that receives the global feature vector and provides adapted intermediate features for the parallel expert head. Its input comes directly from the global feature vector after multi-scale fusion. Through a series of interconnected operations involving normalization, linear transformation, and nonlinear activation, the following is achieved: Deep processing and dimensional adjustment are performed to ultimately output features adapted to the expert head. The overall process revolves around the logic of "feature preprocessing, deep processing, and dimensional adaptation," such as... Figure 5 The specific processing flow is as follows: The module receives the global vector after multi-scale fusion. And process them sequentially according to the initialized pipeline: First The first LayerNorm normalizes the features to ensure a stable distribution. Next, a Linear layer increases the dimensionality, followed by SiLU activation to inject non-linearity. The second LayerNorm then normalizes the increased-dimensional features again, providing stable input for the SwiGLU module. The SwiGLU module performs deep non-linear processing on the features before passing them to the next Linear layer to reduce dimensionality. GELU activation further optimizes the feature representation, and finally, a Dropout layer completes regularization, outputting the intermediate features. .

[0053] It is worth noting that the shared trunk road and the cosine routing module are "parallel from the same source," with both receiving multi-scale fusion as their input. However, their functions differ: cosine routing is responsible for generating expert route probabilities, while shared trunk routes focus on... The feature processing provides high-quality input features for the expert head. This design ensures both the specificity of feature processing and the sharing of the original global vector. This ensures the consistency between the expert head input and the routing probability, laying the foundation for the subsequent weighted aggregation of "expert output × routing probability".

[0054] The Parallel Expert Heads module contains multiple parallel regression branches, with each expert independently detecting the sine and cosine of the angle. The specific steps are as follows: The input features are the intermediate features output by the shared trunk module: ,in, For batch size, This is the intermediate feature dimension.

[0055] Each expert Each layer contains two fully connected network layers and a non-linear activation function, with the following structure: , in, For the first An expert network analyzes the input features The output. This is the weight matrix of the first fully connected layer. This is the weight matrix of the second fully connected layer. For the expert index, the value range is from 1 to , The total number of parallel experts, For activation function, , For the first The bias terms (Bias) corresponding to the first and second layers of each expert.

[0056] This parallel structure can be written as: , in, This is the final total output tensor of the parallel expert head module. For stacking operations, The outputs of the experts are merged in a new dimension.

[0057] The parallel expert head module is the core component of the angle regression head responsible for "multi-branch parallel detection." Its core function is to receive intermediate features from the shared trunk output and then... Each expert branch has the same structure but independent parameters. They calculate the (sin,cos) detection basis of the angle, and finally output the multi-expert detection results that can be matched with the cosine gated routing probability, providing material for subsequent weighted aggregation.

[0058] like Figure 6 As shown, during the forward propagation phase, the module receives intermediate features from the shared trunk. , shape is , For batch size, Share trunk output dimension and start. Parallel computation is performed by several expert branches: First... Each expert branch is simultaneously input into the parallel expert head, and each branch is independent of the others. The process involves linear dimensionality increase, GELU activation, Dropout regularization, and linear dimensionality reduction to 2D. Ultimately, each expert outputs a shape... The tensor, column 0 corresponds to The detection value corresponds to the value in column 1. The detected value; subsequently, the torch.stack function is used to... The output tensor of each expert is categorized by the number of experts ( =1) Stack them to form a shape as The final output, where Corresponding batch size, The corresponding number of experts, 2 corresponds to and Two detection dimensions.

[0059] The design logic of this module works closely with the cosine gating module: its output The results of multi-expert testing can be directly compared with the cosine-gated output. The routing probabilities are weighted and calculated: after expanding the probability dimension, the probabilities are multiplied element-wise and then summed to obtain the comprehensive (sin, cos) detection value for each sample. This multi-expert parallel + probability weighting mode can not only capture diverse detection modes from different experts' perspectives, but also select the optimal expert contribution through routing probabilities, thereby improving the overall detection accuracy.

[0060] To make probability With expert output Multiplying in dimensions requires... of Expanding to the last dimension : , The final output stage uses weights calculated based on cosine gating. Weighted fusion of all expert test results: , in, For experts of Component detection, For experts of Component detection.

[0061] Output .

[0062] Final angle detection: .

[0063] like Figure 7 As shown, for different fabric types, the comparison line is parallel to the weft oblique line, indicating that the angle value deduced by the present invention is very close to the angle value of the fabric itself, and at the same time, it reflects that the generalization ability of the present invention is also strong.

[0064] like Figure 8 As shown, this invention demonstrates the detection capability of the same fabric type at different angles, reflecting the accuracy of its detection of weft skew angle values ​​and adaptability to different weft skew angle conditions. The detection capability of this invention has high stability.

[0065] like Figure 9As shown, this invention demonstrates precise focus in identifying weft skew features: for fabrics with obvious diagonal textures, this invention focuses on the distribution area of ​​the diagonal texture, clearly capturing the tilted trajectory of the weft yarn deviating from the horizontal direction; even for fabrics with relatively fine textures, this invention can locate local irregular texture areas, corresponding to subtle weft skew features; and for fabrics with uniformly distributed textures, the area of ​​focus of this invention exhibits uniformity matching the regular texture. This series of performances demonstrates that this invention can effectively capture the weft skew features of different fabrics, accurately identifying and focusing on both significant diagonal textures and subtle local deviations.

[0066] Figure 10 This diagram illustrates the relationship between the detected angle and the true angle. The blue dots represent the combination of the detected angle and the true angle for each sample, while the red dashed line represents the ideal case where the detected angle equals the true angle. Most points are concentrated near the red dashed line, indicating a strong linear relationship between the detected angle and the true angle, suggesting that the model's detection results are generally quite accurate.

[0067] In this embodiment, on a validation set of 21,440 samples, the mean absolute error (MAE) reached 0.37°, a significant improvement compared to the traditional direct regression model's MAE of 1.67°. Figure 11 As shown in (b). Figure 11 As shown in (a), both training and validation losses decrease and tend to stabilize in the later stages as the number of training rounds increases, indicating that the model learns effectively and is not overfitting, as the validation loss does not increase significantly.

[0068] The model maintains stable performance under varying lighting conditions and different texture complexities.

[0069] The output angle is directly connected to the automatic weft adjustment control system, realizing a closed loop from detection to control.

[0070] Based on the same inventive concept, this invention also proposes a device for detecting the weft skew angle of a fabric. The implementation of this device can be found in the implementation of the method described above, and repeated details will not be elaborated further. Figure 12 As shown, the device 100 includes: Image acquisition module 101: used to acquire images of fabric yarns and preprocess them to obtain standard-sized input images; Angle detection module 102: It is used to input the input image into the ResNet18 backbone network after removing the classification head to extract the feature maps of each layer, and to perform expert-based regression on the feature maps of each layer through the expert angle regression head, outputting the sine and cosine components of the latitudinal oblique angle, and calculating the final angle of the latitudinal oblique angle.

[0071] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the described module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0072] Furthermore, although the operations are described in a specific order, this should be understood as requiring that such operations be performed in the specific order shown or in sequential order, or requiring that all illustrated operations be performed to achieve the desired result. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single implementation. Conversely, various features described in the context of a single implementation may also be implemented individually or in any suitable sub-combination in multiple implementations.

[0073] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A method of detecting the skew angle of a fabric, characterized by, The method comprises: Step S01: collecting a fabric yarn image and preprocessing to obtain an input image of a standard size; Step S02: inputting the input image into a ResNet18 backbone network without a classification head to extract feature maps of each layer, performing expert branch regression on the feature maps of each layer through an expert angle regression head, outputting sine and cosine components of the weft skew angle, and calculating a final angle of the weft skew angle.

2. A method of detecting the skew angle of a fabric according to claim 1, wherein, The specific steps of inputting the input image into the ResNet18 backbone network without the classification head to extract the feature maps of each layer in step S02 are as follows: The input image is convolved, BN and ReLU activated, and first down-sampled; then further down-sampled through maximum pooling; then the basic feature construction is completed through two basic feature blocks BasicBlock, and no down-sampling is performed in this stage; subsequently, the basic feature blocks BasicBlock are sequentially passed through, a specified size convolution kernel is used, the convolution step and the number of channels are adjusted, three rounds of down-sampling are completed, and the corresponding features are output after each round of down-sampling; finally, the backbone network outputs a list composed of three multi-scale features.

3. A method of detecting the skew angle of a fabric according to claim 1, wherein, The expert angle regression head in step S02 comprises a multi-scale compatibility and fusion module, a cosine gating module, a shared trunk module, and a parallel expert head module. The three multi-scale features output by the ResNet18 main network are processed through two branches. One path is processed through the shared trunk module and the parallel expert head module, and two detection dimensions are output. The other path is input into the cosine gating module to obtain three types of tensors, i.e., scaled and temperature-adjusted similarity results, normalized routing probability original cosine similarity, and finally the outputs of the two paths are weighted and fused.

4. A method of detecting the skew angle of a fabric according to claim 3, wherein, The processing procedure of the multi-scale compatibility and fusion module is as follows: The feature dimensions are unified through a channel unification module: , in, For the first Feature maps fused at various scales for Convolution operation, The list of multi-scale features indivual, For the set of real numbers, For batch size, For embedded dimensions, For the first Each feature map height, The width of the feature map; Then, each layer feature is compressed into a global description vector through global average pooling: , wherein, is a global descriptor of the dimensional global descriptor, is a global average pooling; The attention weight of each level is calculated through cross-scale aggregation: , wherein, is the normalized fusion weight of the th scale, is the scale index, is the trainable attention weight matrix, is the transpose of the matrix is the layer normalization;​ resulting in a global feature vector : , wherein, is the number of multi-scale features.

5. A method of detecting the skew angle of a fabric according to claim 3, wherein, The processing procedure of the cosine gating module is as follows: receiving an input global feature vector wherein, denotes the batch size, denotes the channel dimension of the global feature vector; to avoid scale differences interfering with the similarity calculation, the input feature vector and the prototype vector are first L2-normalized, respectively: , wherein, represents an input feature vector, represents a prototype vector; After normalization, all vectors are on the unit sphere. The cosine similarity between the input vector and each prototype vector is calculated through matrix multiplication: , obtained tensor shape is ; The similarity results are sequentially scaled and temperature-controlled: , wherein, a discrimination for amplifying the similarity, a smoothness for controlling the output distribution; Finally, the adjusted along the expert dimension performed normalization: , obtained representing a routing probability distribution for each sample over experts; The final output three types of tensors: is the similarity result after scaling and temperature adjustment; is is the normalized routing probability; is the original cosine similarity.

6. A method of detecting the skew angle of a fabric according to claim 3, wherein, The processing procedure of the shared trunk module is as follows: receive an input global feature vector The first layer of LayerNorm is normalized, and then the dimension is increased by the Linear layer, and the SiLU activation is injected to introduce nonlinearity. Then the second layer of LayerNorm normalizes the features again, and the SwiGLU module processes the features with deep nonlinearity. After that, the features are further optimized by the GELU activation of the next Linear layer. Finally, the regularization is completed by the Dropout layer, and the intermediate features are output .

7. A method of detecting the skew angle of a fabric according to claim 3, wherein, The parallel expert head module comprises a plurality of parallel regression branches, each expert independently detects the sine and cosine corresponding to the angle, and the specific steps are as follows: input features wherein, is a batch size, is an intermediate feature dimension; start up Each expert branch Perform parallel computation, with each branch working independently. The process involves linear dimensionality increase, GELU activation, Dropout regularization, and linear dimensionality reduction to 2D. Ultimately, each expert outputs a shape... The tensor, column 0 corresponds to The test value corresponds to the value in column 1. Detection value; Use the torch.stack function to The output tensors of each expert are stacked according to the dimension of the number of experts, forming a shape as follows: The final output, where Corresponding batch size, The corresponding number of experts, 2 corresponds to and Two detection dimensions.

8. A method of detecting the skew angle of a fabric according to claim 5, wherein, The step S02, which involves outputting the sine and cosine components of the latitude tilt angle and calculating the final angle of the latitude tilt angle, is as follows: Expand on the last dimension: , Final output stage according to the weights computed by the cosine gating Weighted fusion of all expert detection results: , wherein, is an expert in component detection, is an expert in component detection; Output Final angle detection: .

9. The method of detecting the skew angle of a fabric according to claim 1, wherein, The preprocessing in step S01 comprises color domain transformation, light noise, slight blur or sharpening, small-range occlusion and erasing enhancement operation, normalization and cropping of the image.

10. A device for detecting the skew angle of a fabric, characterized in that, The device comprises: An image acquisition module for acquiring a fabric yarn image and preprocessing to obtain an input image of a standard size; An angle detection module for inputting the input image into a ResNet18 backbone network without a classification head to extract feature maps of each layer, performing expert branch regression on the feature maps of each layer through an expert angle regression head, outputting sine and cosine components of the weft skew angle, and calculating a final angle of the weft skew angle.

Citation Information

Patent Citations

  • Woven fabric structure parameter identification method based on convolutional neural network

    CN111709429A

  • Method for detecting defects of plain yarn-dyed fabric

    CN117495836A

  • System for providing deep learning based fabric quality vision inspection service

    KR102775864B1