Colored spun yarn color characterization method fusing spatial features

By combining multi-aperture spectroscopy and high-resolution image acquisition with a deep learning model, the problem of low color matching efficiency of spun yarns has been solved, accurate prediction of fiber types and ratios has been achieved, and the intelligence level of the textile industry has been improved.

CN120655737AActive Publication Date: 2025-09-16WUHAN TEXTILE UNIV

Patent Information

Application Number
CN202511131867.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-13
Publication Date
2025-09-16
Estimated Expiration
2045-08-13

AI Technical Summary

Technical Problem

Existing color matching technology for spun yarn relies on manual judgment, which is inefficient and highly subjective, making it difficult to meet the market demand for fast and accurate color matching. In addition, the accuracy of existing models is limited by idealized assumptions.

Method used

By combining multi-aperture spectral measurement with high-resolution image acquisition, and utilizing 1D-CNN temporal feature extraction, Bi-LSTM spatial dependency modeling, ResNet image color feature extraction, and Transformer cross-modal fusion, a multi-level architecture is constructed. Through color feature extraction and characterization models, accurate prediction of fiber types and ratios can be achieved.

Benefits of technology

It significantly improves color prediction accuracy and material generalization, is suitable for intelligent color control and formula design in the textile industry, and enhances the automation and intelligence level of color matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120655737A_ABST
    Figure CN120655737A_ABST
Patent Text Reader

Abstract

The invention provides a spatial feature fused colored spun yarn color characterization method, and the method comprises the steps: constructing a multi-level architecture of 1D-CNN time sequence feature extraction, DNN aperture internal fusion, Bi-LSTM spatial sequence modeling, ResNet image color feature extraction, pyramid pooling layer image spatial feature extraction, and Transform cross-modal fusion through five aperture multi-position spectrum collection. The method is characterized by comprising the steps of hierarchical feature extraction of a multi-aperture spectrum, bidirectional LSTM space dependence modeling and Transform spectrum depth fusion. Experiments show that the method is obviously superior to the prior art in color prediction precision, material generalization and calculation efficiency, and is suitable for intelligent color control and formula design in the textile industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of textile printing and dyeing, and in particular to a color characterization method for color-spun yarn integrating spatial features. Background Art

[0002] As an innovative textile material, melange yarn utilizes a "dye-first, then blend-spin" production process. This process not only effectively solves the dyeing challenge of heterogeneous fiber blends but also reduces wastewater discharge by approximately one-third compared to traditional methods. This environmentally friendly feature aligns with global sustainable development trends and is crucial for promoting the green transformation of the textile industry. Furthermore, melange yarn, with its natural color gradation and soft feel, is extremely popular in both domestic and international markets, particularly for knitted fabrics.

[0003] However, current color matching technology relies on manual judgment, which is inefficient and highly subjective, making it difficult to meet the market demand for fast and accurate color matching. Therefore, building a prediction model for color-spun fabric formulas is beneficial for improving the automation and intelligence of color matching, promoting the green development and intelligent transformation of the textile industry. In recent years, scholars have used mathematical analysis to establish color-spun yarn color formula prediction models based on the Kubelka-Munk theory, the Stearns-Noechel model, and the Friele model. However, these models all make certain idealized assumptions, which limits their accuracy. Summary of the Invention

[0004] In order to overcome the above-mentioned deficiencies of the prior art, the present invention provides a method for extracting and characterizing color features of a color-spun yarn and its fabric by integrating spatial features, which specifically comprises the following steps:

[0005] Step 1: Using a spectrophotometer with different apertures to measure the color of a colored spun yarn fabric at multiple locations, obtaining corresponding spectral reflectance values; using a high-resolution industrial camera to capture visual images of the colored spun yarn fabric under specific lighting conditions, and preprocessing the collected data;

[0006] Step 2: Using the color feature extraction module to extract color features from the spectral data measured at different positions under a specific aperture, the obtained color features are fused using the color feature fusion module, and the spatial feature extraction module is used to extract spatial color features from the color fusion features obtained under different apertures, which are used as spectral features;

[0007] Step 3: Extract image color features through the image color feature extraction module. In order to further explore the spatial features of the image, the pyramid pooling layer is used to extract the image spatial features. This is used as the image feature to be fused with the spectral data features of the colored spun yarn fabric to accurately characterize the color features.

[0008] Step 4: Fuse spectral features and image features to achieve accurate representation of multi-dimensional color features. Finally, perform global average pooling and predict the fiber type and ratio probability distribution through a classification fully connected layer and softmax activation function.

[0009] Step 5: Train the color prediction model constructed in steps 2 to 4, use the trained model to achieve color representation, and output the probability distribution of fiber types and ratios.

[0010] Furthermore, the input of the color feature extraction module is a single-aperture single-position 31-dimensional spectrum R φk-i , after 3×3 convolution layer, global average pooling and full connection layer FC, the color feature R' is extracted φk-i ; where φ k represents the aperture and i represents the position.

[0011] Furthermore, the input of the color feature fusion module is the color features of all positions of the same aperture. The first fully connected layer: 128 neurons, ReLU activation, weight initialization uses Xavier normal distribution, the second fully connected layer: 64 neurons, the third fully connected layer: 31 neurons, Dropout rate 0.2, activation function Tanh, the feature dimension is aligned to the 31 wavelength points of the spectral data, and the output is a 10×31-dimensional matrix. After global average pooling, a 31-dimensional aperture-level fusion feature R is generated. φf .

[0012] Furthermore, the input of the spatial feature extraction module is the color fusion features of five apertures [R1f, R2f, R3f, R4f, R5f], where the color fusion feature of each aperture R φf The 31-dimensional aperture feature matrix is ​​formed into a 5×31-dimensional aperture feature matrix, which is sorted according to the physical position. A two-layer Bi-LSTM is used to extract sequence space features. In the first layer of Bi-LSTM, the forward LSTM unit extracts feature information according to the sequence input order, and the backward LSTM unit extracts feature information according to the reverse order of the sequence input. The forward LSTM unit captures the color gradient features presented in the sequence according to the input order, and the backward LSTM unit captures the association relationship in the sequence according to the reverse order of the input, and outputs the forward hidden state H. t and the backward hidden state H' t The dimensions are all 64 dimensions, which are 128 dimensions after splicing. The second layer Bi-LSTM focuses on long-distance dependencies, with 128 dimensions for each forward and backward hidden unit, and outputs a hidden state matrix H for 5 positions. The forward + backward splicing of each position is 256 dimensions. Finally, the hidden state of each position is compressed to 31 dimensions through a linear mapping layer, retaining the consistency of the spectral wavelength dimension. The 31-dimensional features of the 5 positions are then globally averaged and pooled to generate a 31-dimensional spatial feature vector F. s, F s The 31 dimensions correspond to 31 wavelength points, and each dimension value reflects the spatial distribution characteristics of the wavelength among the five apertures.

[0013] Furthermore, the image color feature extraction module extracts the multi-scale features of the image by performing multi-level convolution and pooling operations on the input color-spun yarn or fabric image to comprehensively and accurately characterize the global features of the image; the input layer takes the pre-processed color-spun yarn or fabric image as input I img , before being input into the network, the image is standardized; the convolution layer uses a 7×7 convolution kernel with a step size of 2 to perform a convolution operation on the input image; after the convolution layer, the size of the image changes, and then a padding operation is performed to adjust the output size; the maximum pooling layer uses a 3×3 pooling kernel with a step size of 2 to perform a maximum pooling operation on the output of the convolution layer; after maximum pooling, the size of the image is further reduced; the residual block group contains four residual blocks, and different residual blocks are responsible for extracting features of different scales, respectively extracting features of four different dimensions, and then performing a global average pooling operation on the output of the last residual block group through the global average pooling layer, that is, averaging all pixel values ​​of each channel to obtain a fixed-length feature vector; finally, the color feature vector F of the color spinning image containing global multi-scale features is output through the fully connected layer resnet .

[0014] Furthermore, the color feature vector F of the color spun yarn image output by the image color feature extraction module is converted into resnet The input is sent to the spatial pyramid pooling layer, which sets three pooling windows of different scales: 1×1, 2×2, and 4×4. Through these three pooling operations of different scales, the spatial features of the image are extracted from the global, medium-scale, and local details levels respectively. These features are flattened to obtain feature maps V1, V2, and V3, and then the three feature maps are spliced ​​to obtain the feature map V. A fully connected layer is then connected to reduce the dimensionality of the input, and then activated by the ReLU function, and finally the feature vector F containing color and spatial features is output. i .

[0015] Furthermore, the specific process of fusing spectral features and image features is as follows:

[0016] The spectral feature F s and image features F i After concatenation, map them to the same dimension as input F input , add position encoding to the input;

[0017] The multi-head attention mechanism uses 8-head parallel calculation, and the attention score is calculated as follows:

[0018]

[0019] Where Q = F i , K=V=F s , capturing the cross-modal correlation between image regions and aperture spectra, represents the matrix product of the query vector Q and the key vector K, V is the value vector, divided by This is to prevent the dot product result from being too large, which will cause the gradient of the softmax function to disappear. Finally, the outputs of the 8 heads are spliced ​​together and transformed through a linear layer to obtain the output of the multi-head self-attention mechanism;

[0020] The feedforward neural network consists of two fully connected layers. The calculation process of FFN is:

[0021]

[0022] Where x is the output of the multi-head self-attention mechanism, W1 and W2 are the weight matrices of the two fully connected layers, b1 and b2 are the bias vectors of the two fully connected layers, is the activation function; after the multi-head self-attention mechanism and feedforward neural network, residual connections are added respectively;

[0023] After the residual connection, the layer normalization operation is performed;

[0024] The multi-head self-attention mechanism, feedforward neural network, residual connection, and layer normalization are used as encoders. Several layers of encoders are stacked in sequence. The output of each layer of encoder is used as the input of the next layer of encoder. After processing by several layers of encoders, the final feature representation is obtained.

[0025] Furthermore, the weight matrix and bias vector of the classification fully connected layer are learned through training, which uses a learning rate scheduling method combining cosine annealing and hot restart;

[0026] The cosine annealing algorithm formula is:

[0027] in, For the The learning rate of the epoch, is the initial maximum value of the learning rate, is the minimum value of the learning rate, is the current training round, is the cycle length of cosine annealing; For the The length of the restart cycle, the learning rate As training rounds The learning rate is dynamically adjusted according to the periodic cosine decay method and restarted to the maximum value at the end of each cycle.

[0028] Furthermore, the mean square error is introduced as the loss function to train the color prediction model. The difference between the predicted color value and the true color value is measured by calculating the mean of the square of the difference between the two. The calculation formula is:

[0029] in, is the sample size, Indicates the The true color value of the samples, Indicates the model The color value predicted by each sample.

[0030] This paper proposes a color feature extraction method for spun-dyed yarn that integrates spatial features. By acquiring spectra at multiple positions using five apertures, this method constructs a multi-layered architecture consisting of: 1D-CNN temporal feature extraction → DNN intra-aperture fusion → Bi-LSTM spatial sequence modeling → ResNet image color feature extraction → pyramid pooling layer image spatial feature extraction → Transformer cross-modal fusion. Innovations include hierarchical feature extraction from multi-aperture spectra, bidirectional LSTM spatial dependency modeling, and Transformer graph deep fusion. Experiments demonstrate that this method significantly outperforms existing technologies in color prediction accuracy, material generalization, and computational efficiency, making it suitable for intelligent color control and formulation design in the textile industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A flow chart of the method provided by the present invention;

[0032] Figure 2 This is a structural diagram of the color feature extraction module provided by the present invention;

[0033] Figure 3 This is the network structure diagram of the color feature fusion module provided by the present invention;

[0034] Figure 4 The Bi-LSTM network structure diagram provided by the present invention;

[0035] Figure 5 This is the network structure diagram of the image color feature extraction module provided by the present invention;

[0036] Figure 6 Flowchart of the image space feature extraction module provided by the present invention;

[0037] Figure 7 This is a flow chart of the feature fusion module provided by the present invention. DETAILED DESCRIPTION

[0038] The technical solution of the present invention will be fully described below in conjunction with the accompanying drawings in the present invention.

[0039] like Figure 1 As shown, an embodiment of the present invention provides a color characterization method for color-spun yarn integrating spatial features, comprising the following steps:

[0040] Step 1: Use a spectrophotometer with different apertures to measure the color of the colored spun yarn fabric at multiple locations to obtain the corresponding 31-dimensional spectral reflectance values. Use a high-resolution industrial camera to capture visual images of the colored spun yarn fabric under specific lighting conditions, and pre-process the collected data.

[0041] Step 2: Using a color feature extraction module to extract color features from the 31-dimensional spectral data measured at different positions under a specific aperture, in order to fully utilize the spectral values ​​measured at different positions of the same measurement aperture and explore the inherent connections of multi-dimensional data, the obtained color features are fused using a color feature fusion module. In order to explore the detailed features of different positions of the colored spun yarn fabric, the color fusion features obtained at different apertures are extracted using a spatial feature extraction module to extract spatial color features, which are used as spectral features.

[0042] Step 3: To fully and accurately characterize the color-spun yarn fabric and to better reflect human visual perception, the image color features are extracted using the image color feature extraction module. To further explore the spatial features of the image, the pyramid pooling layer is used to extract the image spatial features. These features are used as image features and then fused with the spectral data features of the color-spun yarn fabric to accurately characterize the color features.

[0043] Step 4: Fuse spectral features and image features to achieve accurate representation of multi-dimensional color features. Finally, perform global average pooling and predict the fiber type and ratio probability distribution through a fully connected layer and softmax activation function.

[0044] Step 5: Train the color prediction model constructed in steps 2 to 4, use the trained model to achieve color representation, and output the probability distribution of fiber types and ratios.

[0045] The specific image data is collected by a high-resolution industrial camera under specific lighting conditions. The image data format is the common RGB format, and the image size is uniformly adjusted to 256×256 pixels to ensure the consistency of the input data. The spectral data is obtained by measuring the color of the colored spun yarn and its fabric using a spectrophotometer. The measurement is divided into five measurement apertures (φ1-φ5), and the length and height of each interval are measured once (the interval distance is selected based on actual experience). A total of S positions are measured. Therefore, for a certain aperture φ k The spectral characteristic value of the i-th position is Rφk-i =[R φk-i-λ1 , R φk-i-λ2 ,……, R φk-i-λ31 ]. In order to improve the accuracy of characterization, data sets are constructed according to different materials.

[0046] The preprocessing method is as follows: perform zero mean and unit variance standardization on the R, G, and B channels respectively:

[0047] Among them μR=0.485, σR=0.229, μG=0.456, σG=0.244, μB=0.406, σB=0.255.

[0048] For the training set, random flipping (horizontal / vertical), rotation (±15°), and brightness adjustment (±10%) were applied to improve the model's robustness to fabric placement angles and lighting fluctuations, thereby enhancing data diversity. Datasets were then constructed based on different types of colored yarns and fabric materials. The datasets were divided into a training set and a validation and test set. To improve the model's generalization and stability, a K-fold cross-validation method was used, randomly partitioning the training and validation sets into K mutually exclusive subsets of equal size. The value of K was selected based on actual needs.

[0049] In step 2, the color feature extraction module is constructed as follows Figure 2 As shown, the module input is a single aperture single position 31-dimensional spectrum R φk-i The convolution layer uses a 3×3 kernel to capture the local correlation of three adjacent wavelength points (such as the coordinated change of the reflectivity of 650nm red light and 660nm wavelength). The global average pooling replaces the traditional flattening operation to retain the overall trend of the spectral sequence and suppress single wavelength noise (such as abnormally high values ​​of a certain wavelength caused by random errors of the sensor). Finally, the color feature R' is extracted through the fully connected layer FC. φk-i .

[0050] The color features R' of all aperture positions are obtained φk-i Then, color feature fusion is performed, such as Figure 3 As shown, the input of the color feature fusion module is the color features of all positions of the same aperture. The first fully connected layer: 128 neurons, ReLU activation, weight initialization uses Xavier normal distribution to capture local dependencies between positions (such as the correlation of reflectances of adjacent positions), the second fully connected layer: 64 neurons, Dropout rate 0.2, suppress overfitting, encode the statistical characteristics of the color distribution within the aperture (such as the standard deviation reflects the color uniformity), the third fully connected layer: 31 neurons (key modification point), activation function Tanh, align the feature dimension to the 31 wavelength points of the spectral data, output 10×31 dimensional matrix, and generate a 31-dimensional aperture-level fusion feature R after global average pooling.φf .

[0051] Then comes the spatial feature extraction module. The input of this module is the color fusion features of 5 apertures [R1f, R2f, R3f, R4f, R5f], where the color fusion feature of each aperture R φf The dimension is 31 (consistent with the spectral reflectance), forming a 5×31-dimensional aperture feature matrix, which is sorted according to the physical position (φ1→φ2→φ3→φ4→φ5). A two-layer Bi-LSTM is used to extract sequence space features. Its structure is as follows: Figure 4 As shown in the figure, the forward LSTM in the first layer of Bi-LSTM captures the left→right color gradient (such as the blue-red spectrum change from left to right), and the backward LSTM captures the right→left dependency (such as how the color characteristics of the right measurement position affect the color characteristics of the left position, how the edge aperture compensates the reflectivity of the central aperture), and outputs the forward hidden state H t and the backward hidden state H' t The dimensions are all 64, and after splicing, they are 128. The second layer of Bi-LSTM focuses on long-range dependencies (such as the reflectivity difference between the small aperture φ1 and the large aperture φ5). The forward / backward hidden units are each 128-dimensional, and the output is a hidden state matrix H for 5 positions (the forward + backward splicing of each position is 256-dimensional). Finally, a linear mapping layer (256→31) is used to compress the hidden state of each position to 31 dimensions, preserving the consistency of the spectral wavelength dimension. The 31-dimensional features of the 5 positions are then globally averaged and pooled to generate a 31-dimensional spatial feature vector F. s , F s The 31 dimensions correspond to 31 wavelength points, and each dimension value reflects the spatial distribution characteristics of the wavelength among the five apertures (for example, the standard deviation of the reflectance of the 450nm wavelength at the edge aperture is large, indicating that the color of this area on the fabric surface is uneven).

[0052] Then the image color feature extraction module is performed as Figure 5 As shown in Figure 1, by performing multi-level convolution and pooling operations on the input colored yarn or fabric image, the multi-scale features of the image are extracted to fully and accurately represent the global features of the image, making it closer to human visual perception. The input layer takes the pre-processed colored yarn or fabric image as input I img, the image size is 256×256 pixels, and the number of channels is 3 (i.e., RGB three channels), that is, the dimension of the input data is 256×256×3. Before inputting into the network, the image is standardized so that its pixel values ​​conform to the distribution of zero mean and unit variance to accelerate the convergence speed of the network and improve the stability of training. The convolution layer uses a 7×7 convolution kernel with a step size of 2 to perform a convolution operation on the input image. The number of output channels of this convolution layer is set to 64. Through the convolution operation, the lower-level features such as edges and textures in the image can be extracted. After passing through this convolution layer, the size of the image becomes (Since the stride is 2), but to keep subsequent calculations convenient, padding operations are usually performed to make the output size 128×128 and the output dimension 128×128×64. The maximum pooling layer uses a 3×3 pooling kernel with a stride of 2 to perform a maximum pooling operation on the output of the convolution layer. The function of maximum pooling is downsampling, reducing the dimension of the data by selecting the maximum value within the pooling window while retaining the most important features in the image. After maximum pooling, the size of the image is further reduced to (The size can also be kept at 64 by padding), and the output dimension becomes 64×64×64. The residual block group contains four residual blocks. Different residual blocks are responsible for extracting features of different scales, extracting features of four different dimensions of 64×64×256, 32×32×256, 16×16×512, and 8×8×512 respectively. Then, the output of the last residual block group is subjected to a global average pooling operation through the global average pooling layer, that is, all pixel values ​​of each channel are averaged to obtain a feature vector of fixed length. Through global average pooling, the 8×8×512 feature map is compressed into a 512-dimensional vector. Finally, the color feature vector F of the color spinning image containing global multi-scale features is output through the fully connected layer. resnet , with a dimension of 512.

[0053] Then the 512-dimensional color spinning image color feature vector F output by the image color feature extraction module is resnet Input to the spatial pyramid pooling layer, the process is as follows Figure 6 As shown in the figure, the spatial pyramid pooling layer sets three pooling windows of different scales: 1×1, 2×2, and 4×4. Through these three pooling operations of different scales, the spatial features of the image are extracted from the three levels of global, medium scale, and local details. resnetThe three pooling windows are input into the spatial pyramid pooling layer respectively. For the 1×1 pooling window, a 1×1×512 feature map is obtained after pooling. For the 2×2 and 4×4 pooling windows, 2×2×512 and 4×4×512 feature maps are obtained respectively. These feature maps are flattened to obtain 512-dimensional, 2048-dimensional and 8192-dimensional feature maps V1, V2 and V3, and then the three feature maps are spliced ​​to obtain a 10752-dimensional feature map V. A fully connected layer is then connected to reduce the input dimension to 256 dimensions, and then activated by the ReLU function, and finally a 256-dimensional feature vector F containing color and spatial features is output. i The calculation method of the fully connected layer is:

[0054]

[0055] Where X is the input feature vector, W is the weight matrix of the fully connected layer, b is the bias term, and σ is the ReLU activation function. After the fully connected layer, the output is the color spinning image feature vector F containing global multi-scale features. i , whose dimension is 256.

[0056] The last step is the fusion of image features and spectral features. Figure 7 As shown, the spectral feature F s (31 dimensions) and image features F i (256 dimensions) after concatenation (287 dimensions) mapped to the same dimension (128 dimensions) as input F input , add positional encoding to the input:

[0057]

[0058]

[0059] pos=1-5 corresponds to 5 types of apertures, and i=0-63 is the dimension index, which encodes the spatial order of the apertures. The position encoding formula involves sine and cosine functions. Different position encoding values ​​will be calculated as pos changes and the value of i changes. In the high-frequency part, that is, when i takes a larger value, the independent variable of the function will change greatly for different pos, resulting in more drastic changes in the values ​​of the sine and cosine functions. Therefore, apertures at different positions (such as the central aperture pos = 3 and the edge aperture pos = 1 or pos = 5) will form obvious differences in high-frequency position encoding. This difference allows the model to better distinguish apertures at different positions and capture the spatial order information between apertures. The multi-head attention mechanism uses 8-head parallel calculations, with 16 dimensions per head and a total dimension of 128. The attention score is calculated as follows:

[0060]

[0061] Q=F i (256 dimensions are reduced to 128 dimensions by linear layer), K=V=F s (64 dimensions are increased to 128 dimensions by linear layers), capturing the cross-modal correlation between image regions and aperture spectra, represents the matrix product of the query vector Q and the key vector K, divided by This is to prevent the dot product result from being too large, which will cause the gradient of the softmax function to disappear. Finally, the outputs of the 8 heads are spliced ​​together and transformed through a linear layer to obtain the output of the multi-head self-attention mechanism.

[0062] The feedforward neural network consists of two fully connected layers. The first fully connected layer has 2048 neurons and uses ReLU as the activation function. The second fully connected layer has 128 neurons. The function of the FFN is to further transform and extract features from the output of the multi-head self-attention mechanism, increasing the model's nonlinear expression capabilities. The calculation process of the FFN is as follows:

[0063]

[0064] Here, x is the output of the multi-head self-attention mechanism, W1 and W2 are the weight matrices of the two fully-connected layers, and b1 and b2 are the bias vectors of the two fully-connected layers. Residual connections are added after the multi-head self-attention mechanism and the feedforward neural network. Residual connections directly add the input to the transformed output, effectively alleviating the vanishing gradient problem in deep neural networks and enabling better training and learning. Specifically, for the output z of the multi-head self-attention mechanism and the input x, the output of the residual connection is z + x; for the output y of the feedforward neural network and the input z + x, the output of the residual connection is y + (z + x).

[0065] After the residual connection, layer normalization is performed. Layer normalization normalizes all feature dimensions of each sample so that the feature mean of each sample is 0 and the variance is 1. Layer normalization can accelerate the training convergence speed of the model and improve the stability of the model. The calculation formula of layer normalization is:

[0066]

[0067] Where x is the input vector, μ is the mean of the input vector, and σ 2 is the variance of the input vector, is a small constant used to prevent the denominator from being zero, and γ and β are learnable parameters used to scale and translate the normalized results.

[0068] The four-layer encoder of the above structure (including multi-head self-attention mechanism, feedforward neural network, residual connection, and layer normalization) is stacked in sequence, and the output of each layer of encoder is used as the input of the next layer of encoder. After processing by the four-layer encoder, the final feature representation is obtained. Then, the feature representation is subjected to a global average pooling operation to compress it into a vector of fixed length. Finally, a fully connected layer is used to map the vector after global average pooling to the required dimension, and the Softmax activation function is used to output the probability distribution of fiber types and ratios. The weight matrix and bias vector of the fully connected layer are learned through training. The training adopts a learning rate scheduling combining cosine annealing and warm restarts (Cosine Annealing with Warm Restarts). The formula of the cosine annealing algorithm is:

[0069]

[0070] in, For the The learning rate of the epoch, is the initial maximum value of the learning rate, is the minimum value of the learning rate, is the current training round, is the period length of cosine annealing, For the The length of the restart cycle, the learning rate As training rounds The learning rate is dynamically adjusted according to the periodic cosine decay method, and the learning rate is restarted to the maximum value at the end of each cycle to enhance the model's ability to escape from the local optimum and improve the model's generalization ability for color prediction of colored yarns and fiber classification tasks.

[0071] The Mean Squared Error (MSE) is introduced as a loss function in the color prediction loss. The difference between the predicted color value and the true color value is measured by calculating the mean of the squares of the differences between the two. The calculation formula is:

[0072]

[0073] in, is the sample size, Indicates the The true color value of the samples, Indicates the model The color value predicted by each sample. MSE can intuitively reflect the degree of deviation between the predicted color and the true color at the numerical level. The smaller the value, the more accurate the model is in color prediction.

[0074] The method and effects of the present invention are described below with a specific embodiment:

[0075] Step 1: Data collection and data preprocessing;

[0076] 11. Image Data Acquisition: Use a high-resolution industrial camera (such as the Basler acA2500-14gm, with a resolution of 2592 × 1944) to capture colored yarn and fabrics under specific lighting conditions (D65 standard illuminant, simulating everyday lighting conditions, with a color temperature of approximately 6500K). To ensure image consistency and accuracy, maintain a fixed distance between the camera and the sample (e.g., 30 cm) during capture, and ensure that the sample surface is flat and wrinkle-free. Each image is captured in the common RGB format and subsequently resized to 256 × 256 pixels to meet model input requirements.

[0077] 12. Spectral Data Acquisition: An X-rite Color i7 spectrophotometer was used to measure the color of colored spun yarns and fabrics. During measurement, the wavelength range was set to 400-700 nm, and the spectral reflectance was recorded at 10 nm intervals, generating 31-dimensional spectral reflectance values. There were five measurement apertures φ (φ1 = 3.5 mm, φ2 = 6 mm, φ3 = 10 mm, φ4 = 17 mm, and φ5 = 25 mm). Measurements were taken on the surface of the colored spun yarns and fabrics, arranged in an array from left to right, at intervals of ∆L length and ∆H height (selected based on actual experience, e.g., ∆L = ∆H = 2 cm). A total of S positions (e.g., S = 10) were measured. Therefore, the spectral characteristic value at the i-th position of a given aperture φk is R φk-i =[R φk-i-λ1 , R φk-i-λ2 , …, R φk-i-λ31 ].

[0078] 13. Standardization: The RGB channels of the image are normalized to zero mean and unit variance, i.e. , where μR, μG, and μB are the means of the R, G, and B channels in the training set images, respectively; σR, σG, and σB are the standard deviations of the R, G, and B channels in the training set images, respectively.

[0079] Step 2: Model training;

[0080] Model Initialization: A color prediction model is constructed according to the method described in this invention, comprising a color feature extraction module, a color feature fusion module, a spatial feature extraction module, an image color feature extraction module, and a graph feature fusion module. The model parameters are initialized. For example, the weights of the convolutional and fully connected layers in the color feature extraction module's network structure are initialized using a Xavier normal distribution. The Bi-LSTM weights are initialized using the default method. The weights of the spatial feature extraction module are pre-trained on the ImageNet dataset (for layers requiring fine-tuning). The weights of the image color feature extraction module are initialized using random initialization.

[0081] Training parameter settings:

[0082] 211. Optimizer: Use the AdamW optimizer to optimize model parameters, setting the learning rate to 1e-4 and the weight decay to 0.001. The AdamW optimizer combines the advantages of the Adam optimizer and L2 regularization to effectively prevent model overfitting while accelerating model convergence.

[0083] 212. Loss Function: Based on the model's task requirements, the Mean Squared Error (MSE) loss function is used to measure the difference between the predicted color and the true color. The cross-entropy function is used as the loss function for the classification task, calculating the error between the predicted probability distribution of fiber types and ratios and the true distribution. The total loss function is a weighted sum of the regression loss and the classification loss, with the weights adjusted based on the actual situation (e.g., 0.5 for each).

[0084] 213. Training rounds and batch size: Set the model training rounds to 300 and the batch size to 32. During the training process, each round of training will traverse the entire training set, divide the training data into several batches, each containing 32 samples, and input them into the model for training and parameter update.

[0085] Training process:

[0086] 221. In each round of training, a batch of samples is randomly selected from the training set, including image data, spectral data, corresponding true color values, and fiber type and ratio labels.

[0087] 222. Input the image data into the image feature extraction module, and connect the module output as input to the image space feature extraction module to obtain the image feature vector F i ; Input the spectral data into the color feature extraction module (1D-CNN), the color feature fusion module (DNN) and the spatial feature extraction module (Bi-LSTM), and obtain the single position color feature, aperture level fusion feature and spatial feature vector F in turn. s .

[0088] 223. F i and F s Input the graph feature fusion module, and after feature fusion and transformation, output the fiber type and ratio probability distribution.

[0089] 224. Based on the predicted results and the true labels, the loss function is calculated, and the gradient is calculated through the backpropagation algorithm to update the model parameters. During the backpropagation process, the contribution of all modules is taken into account when calculating the gradient of each parameter, thus achieving joint optimization of the entire model.

[0090] 225. After each round of training, the model is evaluated using the validation set. Metrics such as the validation set loss, average color difference (e.g., average CIE DE2000 color difference), and prediction accuracy for fiber type and ratio are calculated. Based on the validation set evaluation results, the model's hyperparameters (e.g., learning rate, loss function weights, etc.) are adjusted to avoid overfitting or underfitting.

[0091] Step 3: Model evaluation and application;

[0092] Model Evaluation: After model training is complete, the model is finally evaluated using the test set. Various performance metrics are calculated on the test set, including the average color difference of color prediction (e.g., the average CIE DE2000 color difference; lower values ​​indicate closer predicted colors to the true colors), the prediction accuracy of fiber types and proportions (the proportion of correctly predicted samples to the total number of samples; higher values ​​indicate more accurate predictions), the mean squared error (MSE), and the mean absolute error (MAE). These metrics comprehensively evaluate the model's performance and accuracy, and are compared with other relevant models to verify the effectiveness and superiority of the proposed method.

[0093] Model application: The trained model is applied to actual production to predict the color formula of colored yarn and its fabrics. The specific application process is as follows:

[0094] 31. For the colored yarn or fabric sample to be predicted, first obtain its image data and spectral data according to the data acquisition and preprocessing method.

[0095] 32. Input the preprocessed image data and spectral data into the trained model, and the model will output the probability distribution of fiber types and ratios.

[0096] 33. Based on the prediction results, production personnel can adjust the production formula of colored yarn, such as adjusting the ratio of different base color fibers, to achieve the desired color effect. The model's prediction results can also be used for quality control. By comparing the predicted color with the actual production color, deviations in the production process can be promptly identified and corrected, thereby improving product quality and consistency.

[0097] To validate the model's effectiveness, this application selected samples of multi-color spun-yarn fabrics from a textile company, with various fiber ratios, and randomly mixed them into three groups for model prediction. Image data was captured using a high-resolution industrial camera (Basler acA2500-14gm) under specific lighting conditions (D65 standard light source, simulating daily lighting conditions, with a color temperature of approximately 6500K). Spectral data was obtained by color measurement using an X-rite Color i7 spectrophotometer. Experimental verification demonstrated that the model training presented in this application achieved an average separation error (MSE) of 0.00222, effectively meeting the company's requirements for the production of multi-color spun-yarn fabrics.

[0098] Table 1 Model performance comparison

[0099]

[0100] It should be understood that the above description of the preferred embodiment is relatively detailed and cannot be regarded as limiting the scope of protection of the patent of the present invention. Under the guidance of the present invention, ordinary technicians in this field can also make substitutions and modifications without departing from the scope of protection of the claims of the present invention, which all fall within the scope of protection of the present invention. The scope of protection requested by the present invention shall be based on the attached claims.

Claims

1. A color characterization method for color-spun yarn integrating spatial features, characterized in that: The steps include: Step 1: Using a spectrophotometer with different apertures to measure the color of a colored spun yarn fabric at multiple locations to obtain corresponding spectral reflectance values; using a high-resolution industrial camera to capture visual images of the colored spun yarn fabric, and preprocessing the collected data; Step 2: Using the color feature extraction module to extract color features from the spectral data measured at different positions under different apertures, the obtained color features are fused using the color feature fusion module, and the color fusion features obtained under different apertures are extracted using the spatial feature extraction module to extract spatial color features, which are used as spectral features; The input of the spatial feature extraction module is the color fusion features of 5 apertures [R1f, R2f, R3f, R4f, R5f], where the color fusion feature of each aperture R φf The 31-dimensional aperture feature matrix is ​​formed into a 5×31-dimensional aperture feature matrix, which is sorted according to the physical position. A two-layer Bi-LSTM is used to extract sequence space features. In the first layer of Bi-LSTM, the forward LSTM unit extracts feature information according to the sequence input order, and the backward LSTM unit extracts feature information according to the reverse order of the sequence input. The forward LSTM unit captures the color gradient features presented in the sequence according to the input order, and the backward LSTM unit captures the association relationship in the sequence according to the reverse order of the input, and outputs the forward hidden state H. t and the backward hidden state H' t The dimensions are all 64, and after splicing, they are 128; The second layer Bi-LSTM focuses on long-distance dependencies, with 128-dimensional forward and backward hidden units, and outputs a hidden state matrix H of 5 positions, with 256-dimensional forward and backward concatenation at each position. Finally, the hidden state of each position is compressed to 31 dimensions through a linear mapping layer, preserving the consistency of the spectral wavelength dimension. The 31-dimensional features of the 5 positions are then globally averaged and pooled to generate a 31-dimensional spatial feature vector F. s , F s The 31 dimensions correspond to 31 wavelength points, and each dimension value reflects the spatial distribution characteristics of the wavelength among the five apertures; Step 3: Extract image color features through the image color feature extraction module. In order to further explore the spatial features of the image, the pyramid pooling layer is used to extract the image spatial features. This is used as the image feature to be fused with the spectral data features of the colored spun yarn fabric to accurately characterize the color features. Step 4: Fuse spectral features and image features to achieve accurate representation of multi-dimensional color features. Finally, perform global average pooling and predict the fiber type and ratio probability distribution through a classification fully connected layer and softmax activation function. Step 5: Train the color prediction model constructed in steps 2 to 4, use the trained model to achieve color representation, and output the probability distribution of fiber types and ratios.

2. The method for characterizing color of a spun-dyed yarn by integrating spatial features according to claim 1, wherein: The input of the color feature extraction module is a single aperture single position 31-dimensional spectrum R φk-i , after 3×3 convolution layer, global average pooling and full connection layer FC, the color feature R' is extracted φk-i ; where φ k represents the aperture and i represents the position.

3. The method for characterizing color of a spun-dyed yarn by integrating spatial features according to claim 1, wherein: The input of the color feature fusion module is the color features of all positions of the same aperture. The first fully connected layer: 128 neurons, ReLU activation, weight initialization uses Xavier normal distribution, the second fully connected layer: 64 neurons, the third fully connected layer: 31 neurons, Dropout rate 0.2, activation function Tanh, align the feature dimensions to the 31 wavelength points of the spectral data, output 10×31 dimensional matrix, and generate 31-dimensional aperture-level fusion feature R after global average pooling. φf .

4. The method for characterizing color of a spun-dyed yarn by integrating spatial features according to claim 1, wherein: The image color feature extraction module extracts multi-scale features of the image by performing multi-level convolution and pooling operations on the input colored yarn or fabric image to comprehensively and accurately characterize the global features of the image; The input layer takes the pre-processed colored yarn or fabric image as input I img , before being input into the network, the image is standardized; the convolution layer uses a 7×7 convolution kernel with a step size of 2 to perform a convolution operation on the input image; after the convolution layer, the size of the image changes, and then a padding operation is performed to adjust the output size; the maximum pooling layer uses a 3×3 pooling kernel with a step size of 2 to perform a maximum pooling operation on the output of the convolution layer; after maximum pooling, the size of the image is further reduced; the residual block group contains four residual blocks, and different residual blocks are responsible for extracting features of different scales, respectively extracting features of four different dimensions, and then performing a global average pooling operation on the output of the last residual block group through the global average pooling layer, that is, averaging all pixel values ​​of each channel to obtain a fixed-length feature vector; finally, the color feature vector F of the color spinning image containing global multi-scale features is output through the fully connected layer resnet .

5. The method for characterizing color of a spun-dyed yarn integrating spatial features according to claim 1, wherein: The color feature vector F of the color spinning image output by the image color feature extraction module resnet The input is sent to the spatial pyramid pooling layer, which sets three pooling windows of different scales: 1×1, 2×2, and 4×4. Through these three pooling operations of different scales, the spatial features of the image are extracted from the global, medium-scale, and local details levels respectively. These features are flattened to obtain feature maps V1, V2, and V3, and then the three feature maps are spliced ​​to obtain the feature map V. A fully connected layer is then connected to reduce the dimensionality of the input, and then activated by the ReLU function, and finally the feature vector F containing color and spatial features is output. i .

6. The method for characterizing color of a spun-dyed yarn integrating spatial features according to claim 1, wherein: The specific process of fusing spectral features and image features is as follows: The spectral feature F s and image features F i After concatenation, map them to the same dimension as input F input , add position encoding to the input; The multi-head attention mechanism uses 8-head parallel calculation, and the attention score is calculated as follows: ; Where Q = F i , K=V=F s , capturing the cross-modal correlation between image regions and aperture spectra, represents the matrix product of the query vector Q and the key vector K, V is the value vector, divided by This is to prevent the dot product result from being too large, which will cause the gradient of the softmax function to disappear. Finally, the outputs of the 8 heads are spliced ​​together and transformed through a linear layer to obtain the output of the multi-head self-attention mechanism; The feedforward neural network consists of two fully connected layers. The calculation process of FFN is: ; Where x is the output of the multi-head self-attention mechanism, W1 and W2 are the weight matrices of the two fully connected layers, b1 and b2 are the bias vectors of the two fully connected layers, is the activation function; after the multi-head self-attention mechanism and feedforward neural network, residual connections are added respectively; After the residual connection, the layer normalization operation is performed; The multi-head self-attention mechanism, feedforward neural network, residual connection, and layer normalization are used as encoders. Several layers of encoders are stacked in sequence. The output of each layer of encoder is used as the input of the next layer of encoder. After processing by several layers of encoders, the final feature representation is obtained.

7. The method for characterizing color of a spun-dyed yarn by integrating spatial features according to claim 1, wherein: The weight matrix and bias vector of the classification fully connected layer are learned through training. The training adopts the learning rate scheduling method combining cosine annealing and hot restart. The cosine annealing algorithm formula is: ; in, For the The learning rate of the epoch, is the initial maximum value of the learning rate, is the minimum value of the learning rate, is the current training round, is the cycle length of cosine annealing; For the The length of the restart cycle, the learning rate As training rounds The learning rate is dynamically adjusted according to the periodic cosine decay method and restarted to the maximum value at the end of each cycle.

8. The method for characterizing color of a spun-dyed yarn integrating spatial features according to claim 1, wherein: The mean square error is introduced as the loss function to train the color prediction model. The difference between the predicted color value and the true color value is measured by calculating the mean of the square of the difference between the two. The calculation formula is: ; in, is the sample size, Indicates the The true color value of the samples, Indicates the model The color value predicted by each sample.

Citation Information

Patent Citations

  • Method and system for evaluating eggshell surface color quality based on color reflection

    CN119832318A

  • Colored spun yarn color prediction method and system based on data driving

    CN119962765A

  • Method of making a wrapped composite color blended alternating color yarn

    US6536200B1

Cited By

  • Compression method and system for multi-source heterogeneous time series data, and motor fault prediction method and system

    CN121036770A