A color representation method of color spun yarn fusing spatial features
By combining multi-aperture spectral measurement and high-resolution image acquisition with deep learning technology, a multi-level architecture was constructed to solve the problem of low color matching efficiency of colored spun yarns, achieve accurate prediction of fiber types and ratios, and improve the intelligence level of the textile industry.
Patent Information
- Application Number
- CN202511131867.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-13
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-08-13
AI Technical Summary
Existing color matching technology for colored spun yarns 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.
By combining multi-aperture spectral measurement with high-resolution image acquisition, and through 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 to achieve accurate prediction of the probability distribution of fiber types and ratios.
It significantly improves color prediction accuracy and material generalization, and is suitable for intelligent color control and formula design in the textile industry.
Smart Images

Figure CN120655737B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of textile printing and dyeing technology, and particularly relates to a color representation method of color spun yarn fusing spatial features. BACKGROUND
[0002] As an innovative textile material, color spun yarn realizes "dyeing first and then blending spinning" in the production process. This process not only effectively solves the dyeing problem of blending of different fibers, but also reduces about one-third of wastewater discharge compared with traditional processes. This environmentally friendly feature meets the global trend of sustainable development and is of great significance for promoting the green transformation of the textile industry. On the other hand, color spun yarn is very popular in the domestic and foreign markets due to its natural color gradation and soft hand feeling, especially in the field of knitted fabrics.
[0003] However, the current color matching technology relies on manual judgment, which is inefficient and highly subjective, and cannot meet the market demand for fast and accurate color matching. Therefore, building a color spun fabric formula prediction model is beneficial to improving the automation and intelligence level of color matching and 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, Stearns-Noechel model and Friele model. However, the above models have certain idealized assumptions, which limit the accuracy of the models. SUMMARY
[0004] In order to overcome the shortcomings of the prior art, the present application provides a color spun yarn and fabric color feature extraction and representation method fusing spatial features, which specifically includes the following steps:
[0005] Step 1: Use spectrophotometers with different apertures to measure the color of color spun yarn fabric at multiple positions to obtain corresponding spectral reflectance values; use a high-resolution industrial camera to collect visual images of color spun yarn fabric under specific lighting conditions, and pre-process the collected data;
[0006] Step 2: Use the color feature extraction module to extract color features from the spectral data measured at different positions under a specific aperture, fuse the obtained color features using the color feature fusion module, and extract spatial color features from the color fusion features obtained under different apertures as spectral features;
[0007] Step 3: Extract image color features through the image color feature extraction module, and further extract image spatial features using a pyramid pooling layer to serve as image features, which are used to fuse with spectral data features of color spun yarn fabric to accurately represent color features;
[0008] Step 4, fuse the spectral features and image features, realize the accurate representation of multi-dimensional color features, and finally perform global average pooling and predict the fiber type and ratio probability distribution through a classification fully connected layer and a Softmax activation function;
[0009] Step 5, train the color prediction model constituted by steps 2-4, realize color representation using the trained model, and output the fiber type and ratio probability distribution.
[0010] Further, the input of the color feature extraction module is a single aperture unit 31-dimensional spectrum R φk-i , which is sequentially subjected to a 3x3 convolution layer, global average pooling and a fully connected layer FC to extract color features R' φk-i ; wherein φ k represents the aperture, and i represents the position.
[0011] Further, the input of the color feature fusion module is the color features of all positions in the same aperture, the first fully connected layer has 128 neurons, ReLU activation, and the weight is initialized using the Xavier normal distribution, the second fully connected layer has 64 neurons, the third fully connected layer has 31 neurons, the Dropout rate is 0.2, and the activation function is Tanh. The feature dimension is aligned to the 31 wavelength points of the spectral data, and a 10x31-dimensional matrix is output. After global average pooling, a 31-dimensional aperture-level fusion feature R φf is generated.
[0012] Further, the input of the spatial feature extraction module is the color fusion features [R1f, R2f, R3f, R4f, R5f] of the 5 apertures, wherein the color fusion feature R φf of each aperture is 31-dimensional, forming a 5x31-dimensional aperture feature matrix, which is sorted according to the physical position; a double-layer Bi-LSTM is used to extract sequence spatial features. In the first layer Bi-LSTM, the forward LSTM unit extracts feature information in sequence input order, and the backward LSTM unit extracts feature information in reverse sequence input order. The forward LSTM unit captures the color gradient features presented in the input order in the sequence, and the backward LSTM unit captures the association relationships existing in the reverse input order in the sequence. The output forward hidden state H t and the backward hidden state H' t are both 64-dimensional, and after splicing, they are 128-dimensional; the second layer Bi-LSTM focuses on long-distance dependence, and the forward and backward hidden units are each 128-dimensional, outputting a hidden state matrix H of 5 positions, each position being spliced 256-dimensional; finally, a linear mapping layer is used to compress the hidden state of each position to 31-dimensional, preserving the spectral wavelength dimension consistency, and then performing global average pooling on the 31-dimensional features of the 5 positions 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 between 5 apertures.
[0013] Further, 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 spun yarn or fabric image, so as to comprehensively and accurately represent the global features of the image; the input layer takes the preprocessed colored spun yarn or fabric image as input I img , the image is standardized before being input into the network; the convolution layer uses a 7x7 convolution kernel with a step size of 2 to perform convolution operation on the input image; after the convolution layer, the size of the image is changed, and then padding operation is performed to adjust the output size; the maximum pooling layer uses a 3x3 pooling kernel with a step size of 2 to perform maximum pooling operation on the output of the convolution layer; after the maximum pooling, the size of the image is further reduced; the residual block group contains four residual blocks, different residual blocks are responsible for extracting features of different scales, and features of four different dimensions are extracted respectively, and then the global average pooling layer is used to perform global average pooling operation on the output of the last residual block group, that is, the average of all pixel values in each channel is obtained to obtain a fixed-length feature vector; finally, the color feature vector F resnet of the colored spun yarn image containing global multi-scale features is output through the fully connected layer.
[0014] Further, the color feature vector F resnet of the colored spun yarn image output by the image color feature extraction module is input into the spatial pyramid pooling layer, the spatial pyramid pooling layer sets three different scale pooling windows of 1x1, 2x2 and 4x4, and through the three different scale pooling operations, the spatial features of the image are extracted from three levels of global, medium scale and local details respectively, the features are flattened to obtain feature maps V1, V2 and V3, then the three feature maps are spliced to obtain a feature map V, and then a fully connected layer is connected to reduce the dimension of the input, and then the ReLU function is activated, and finally the feature vector F i containing color and spatial features is output.
[0015] Further, the specific process of fusing the spectral features and the image features is as follows:
[0016] The spectral feature F s and the image feature F i are spliced and mapped to the same dimension as input F input , and position encoding is added to the input.
[0017] The multi-head attention mechanism adopts 8 parallel calculations, 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 warm restart;
[0026] The cosine annealing algorithm formula is:
[0027]
[0028] 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.
[0029] 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:
[0030]
[0031] in, is the sample size, Indicates the The true color value of the samples, Indicates the model The color value predicted by each sample.
[0032] 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
[0033] Figure 1 A flow chart of the method provided by the present invention;
[0034] Figure 2 This is a structural diagram of the color feature extraction module provided by the present invention;
[0035] Figure 3 This is the network structure diagram of the color feature fusion module provided by the present invention;
[0036] Figure 4 The Bi-LSTM network structure diagram provided by the present invention;
[0037] Figure 5 This is the network structure diagram of the image color feature extraction module provided by the present invention;
[0038] Figure 6 Flowchart of the image space feature extraction module provided by the present invention;
[0039] Figure 7The feature fusion module flowchart provided in the present application. DETAILED DESCRIPTION
[0040] The technical solutions of the present application will be described in detail below in combination with the drawings in the present application.
[0041] As Figure 1 shown, the embodiment of the present application provides a color representation method for color spun yarns based on spatial feature fusion, comprising the following steps:
[0042] Step 1: Use spectrophotometers with different apertures to measure the color of the color spun yarn fabric at multiple positions to obtain corresponding 31-dimensional spectral reflectance values. Use a high-resolution industrial camera to collect visual images of the color spun yarn fabric under specific lighting conditions, and pre-process the collected data;
[0043] Step 2: Use 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 under the same measurement aperture and to mine the internal relationship of multi-dimensional data, the obtained color features are fused using a color feature fusion module. In order to mine the detail features of different positions of the color spun yarn fabric, the color fusion features obtained under different apertures are extracted by a spatial feature extraction module to obtain spatial color features as spectral features.
[0044] Step 3: In order to accurately represent the color spun yarn fabric and to be closer to human visual perception, image color features are extracted by an image color feature extraction module. In order to further mine the spatial features of the image, image spatial features are extracted by a pyramid pooling layer as image features, which are used to fuse with the spectral data features of the color spun yarn fabric to accurately represent the color features.
[0045] Step 4: Fuse the spectral features and the image features to realize accurate representation of multi-dimensional color features. Finally, perform global average pooling and predict the fiber type and the probability distribution of the ratio through a fully connected layer and a Softmax activation function.
[0046] Step 5: Train the color prediction model constituted by steps 2-4, use the trained model to realize color representation, and output the fiber type and the probability distribution of the ratio.
[0047] Specific image data is collected by high-resolution industrial cameras under specific lighting conditions. The image data is in the common RGB format, and the image size is uniformly adjusted to 256x256 pixels to ensure the consistency of the input data. Spectral data is obtained by color measurement of color spun yarn and its fabric using a spectrophotometer. Five measurement apertures (φ1-φ5) are used, and each aperture is measured once at an interval of ΔL length and ΔH height (the interval distance is selected according to experience). A total of S positions are measured, so the spectral feature value of the ith position of aperture φj is R k . φk-i φk-i-λ1 φk-i-λ2 φk-i-λ31 To improve the accuracy of representation, data sets are constructed according to different materials.
[0048] The preprocessing method is as follows: zero mean and unit variance standardization is performed on the R, G, and B channels respectively.
[0049] Where μR=0.485, σR=0.229, μG=0.456, σG=0.244, μB=0.406, and σB=0.255.
[0050] For the training set, random flipping (horizontal / vertical), rotation (±15°), and brightness adjustment (±10%) are used to improve the robustness of the model to fabric placement angle and lighting fluctuations, and to enhance data diversity. Then, data sets are constructed according to different materials of color spun yarn and its fabric. The data set is divided into training set and validation set, and test set. To improve the generalization ability and stability of the model, K-fold cross-validation method is used to randomly divide the training set and validation set into K mutually exclusive subsets of the same size. The value of K is selected according to actual requirements.
[0051] The color feature extraction module constructed in step 2 is shown in Figure 2 The module input is a single-aperture unit position 31-dimensional spectrum R φk-i , a 3x3 kernel is used in the convolution layer to capture the local correlation of adjacent 3 wavelength points (such as the cooperative change of reflectivity of 650nm red light and 660nm wavelength), and global average pooling is used instead of traditional flattening operation to preserve the overall trend of the spectral sequence and suppress single-wavelength noise (such as abnormal high value of a certain wavelength caused by random error of the sensor). Finally, the color feature R' φk-i is extracted through the fully connected layer FC.
[0052] After obtaining the color features R' φk-i of all aperture positions, color feature fusion is performed, as shown in Figure 3 As shown, the input of the color feature fusion module is the color feature of all positions in the same aperture, the first fully connected layer: 128 neurons, ReLU activation, weight initialization using Xavier normal distribution, capturing local dependence between positions (such as the correlation of reflectance of adjacent positions), the second fully connected layer: 64 neurons, Dropout rate 0.2, inhibiting overfitting, encoding statistical features of color distribution in the aperture (such as standard deviation reflecting color uniformity), the third fully connected layer: 31 neurons (key modification point), activation function Tanh, aligning the feature dimension to 31 wavelength points of the spectral data, outputting a 10x31-dimensional matrix, generating a 31-dimensional aperture-level fusion feature R φf .
[0053] Then the spatial feature extraction module, which inputs the color fusion features [R1f, R2f, R3f, R4f, R5f] of 5 apertures, where the color fusion feature R φf of each aperture is 31-dimensional (consistent with spectral reflectance), forming a 5x31-dimensional aperture feature matrix, sorted by physical position (φ1→φ2→φ3→φ4→φ5). A double-layer Bi-LSTM is used to extract sequence spatial features, and its structure is as shown in Figure 4 The forward LSTM in the first layer of Bi-LSTM captures the left→right color gradient rule (such as the blue-red spectrum change from left to right), and the backward LSTM captures the right→left dependence (such as how the color features of the right measurement position affect the color features of the left position, and how the edge aperture performs reflectance compensation for the center aperture), outputting the forward hidden state H t and the backward hidden state H' t , both with a dimension of 64, and after splicing, a dimension of 128. The second layer of Bi-LSTM focuses on long-distance dependence (such as the reflectance difference between φ1 small aperture and φ5 large aperture), with 128 dimensions for each forward / backward hidden unit, outputting a hidden state matrix H of 5 positions (each position is spliced 256-dimensional forward+backward). Finally, a linear mapping layer (256→31) is used to compress the hidden state of each position to 31 dimensions, preserving the spectral wavelength dimension consistency, and then performing global average pooling on the 31-dimensional features of the 5 positions to generate a 31-dimensional spatial feature vector F s , F s The 31 dimensions of F s correspond to 31 wavelength points, and each dimension value reflects the spatial distribution characteristics of the wavelength among the 5 apertures (such as the reflectance standard deviation of 450nm wavelength in the edge aperture being large, indicating that the color of the fabric surface in this area is not uniform).
[0054] Then the image color feature extraction module is as shown in Figure 5As shown, by performing multi-level convolution and pooling operations on the input colored spun yarn or fabric image, the multi-scale features of the image are extracted to comprehensively and accurately represent the global features of the image, making it closer to human visual perception. The input layer takes the pre-processed colored spun yarn or fabric image as input I img , the image size is 256x256 pixels, and the number of channels is 3 (i.e., RGB three channels), i.e., the dimension of the input data is 256x256x3. Before inputting into the network, the image is standardized to make the pixel value conform to the distribution of zero mean and unit variance, so as to accelerate the convergence speed of the network and improve the stability of the training. The convolution layer uses a 7x7 convolution kernel with a step size of 2 to perform convolution operation on the input image. The output channel number of this convolution layer is set to 64, and the convolution operation can extract the lower layer features such as edges and textures in the image. After this convolution layer, the size of the image is reduced to (due to the step size of 2), but in order to keep the subsequent calculation convenient, padding operation is usually performed to make the output size 128x128 and the output dimension 128x128x64. The max pooling layer uses a 3x3 pooling kernel with a step size of 2 to perform max pooling operation on the output of the convolution layer. The role of max pooling is downsampling, which reduces the dimension of the data while retaining the most important features in the image by selecting the maximum value in the pooling window. After max pooling, the size of the image is further reduced to (also by padding to keep the size 64), and the output dimension is changed to 64x64x64. The residual block group contains four residual blocks, and different residual blocks are responsible for extracting different scale features, extracting features of four different dimensions of 64x64x256, 32x32x256, 16x16x512, and 8x8x512, respectively. Then, the global average pooling layer is used to perform global average pooling operation on the output of the last residual block group, i.e., the average of all pixel values in each channel is obtained to obtain a fixed-length feature vector. Through global average pooling, the 8x8x512 feature map is compressed into a 512-dimensional vector. Finally, the color spun yarn image color feature vector F resnet with a dimension of 512 is output through the fully connected layer.
[0055] Then, the 512-dimensional color spun yarn image color feature vector F resnet output by the image color feature extraction module is input into the spatial pyramid pooling layer, as shown in Figure 6 The spatial pyramid pooling layer sets three different scale pooling windows of 1x1, 2x2, and 4x4. Through these three different scale pooling operations, the spatial features of the image are extracted from three levels of global, medium scale, and local details. The 512-dimensional image color feature F resnetThe three pooling windows input into the spatial pyramid pooling layer, for the 1x1 pooling window, a 1x1x512 feature map is obtained after pooling, and 2x2 and 4x4 pooling windows obtain 2x2x512 and 4x4x512 feature maps respectively, and the feature maps are flattened to obtain 512-dimensional, 2048-dimensional and 8192-dimensional feature maps V1, V2 and V3, then the three feature maps are spliced to obtain a 10752-dimensional feature map V, and then a fully connected layer is connected to reduce the input to 256 dimensions, and then activated by the ReLU function, and finally output a 256-dimensional feature vector F containing color and spatial features i The calculation method of the fully connected layer is:
[0056]
[0057] Where X is the input feature vector, W is the weight matrix of the fully connected layer, b is the bias term, and sigma is the ReLU activation function. After the fully connected layer, the output is a color yarn image feature vector F containing global multi-scale features i with a dimension of 256.
[0058] The last step of image feature and spectral feature fusion part is shown in Figure 7 The spectral feature F s (31 dimensions) and the image feature F i (256 dimensions) are spliced (287 dimensions) and mapped to the same dimension (128 dimensions) as input F input , and the position encoding is added to the input:
[0059]
[0060]
[0061] pos=1-5 corresponds to 5 apertures, i=0-63 is the dimension index, and the aperture space order is encoded. The formula of the position encoding involves sine and cosine functions, and different position encoding values are calculated with the change of pos and the value of i. In the high frequency part, that is, when i takes a larger value, the argument of the function will change greatly for different pos, resulting in a sharp change in the value of the sine and cosine functions. Therefore, different positions of the aperture (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 can make the model better distinguish different positions of the aperture and capture the spatial order information between the apertures. The multi-head attention mechanism adopts 8 parallel calculations, each with a dimension of 16, a total dimension of 128, and the attention score calculation:
[0062]
[0063] Q=F i (256-dimensional linear layer dimensionality reduction to 128-dimensional), K=V=F s (64-dimensional linear layer dimensionality reduction to 128-dimensional), capturing the cross-modal association of image regions and aperture spectra, denotes the matrix product of the query vector Q and the key vector K, divided by is to prevent the dot product result from being too large to cause the softmax function gradient 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.
[0064] The feedforward neural network is composed of two fully connected layers, the number of neurons in the first fully connected layer is 2048, and the activation function is ReLU; the number of neurons in the second fully connected layer is 128. The role of FFN is to further transform and extract the output of the multi-head self-attention mechanism, and increase the nonlinear expression ability of the model. The calculation process of FFN is:
[0065]
[0066] 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, and b1 and b2 are the bias vectors of the two fully connected layers. After the multi-head self-attention mechanism and the feedforward neural network, a residual connection is added respectively. The role of the residual connection is to add the input directly to the transformed output, which can effectively alleviate the gradient vanishing problem in deep neural networks, so that the model can be better trained and learned. 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).
[0067] After the residual connection, layer normalization operation is performed. Layer normalization is to normalize all feature dimensions of each sample, so that the feature mean of each sample is 0 and the feature variance is 1. Layer normalization can speed up the training convergence speed of the model and improve the stability of the model. The calculation formula of layer normalization is:
[0068]
[0069] Where x is the input vector, μ is the mean of the input vector, σ 2 is the variance of the input vector, is a very small constant to prevent the denominator from being 0, and γ and β are learnable parameters to scale and translate the normalized results.
[0070] 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:
[0071]
[0072] 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.
[0073] 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:
[0074]
[0075] 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.
[0076] The method and effect of the present application are described below with a specific embodiment:
[0077] Step 1, data collection and data preprocessing;
[0078] 11. Image data collection: Use a high-resolution industrial camera (such as Basler acA2500-14gm, resolution 2592x1944) to take pictures of colored spun yarn and its fabric under specific lighting conditions (D65 standard light source, simulating daily lighting environment, color temperature about 6500K). To ensure the consistency and accuracy of the images, the distance between the camera and the sample should be fixed (such as 30 cm) and the sample surface should be flat and wrinkle-free. The image format obtained by each shooting is common RGB format, and the size is adjusted to 256x256 pixels in the subsequent process to meet the model input requirements.
[0079] 12. Spectral data collection: Use X-rite Color i7 spectrophotometer to measure the color of colored spun yarn and its fabric. When measuring, set the wavelength range to 400-700 nm, record the spectral reflectance every 10 nm, and generate 31-dimensional spectral reflectance values. There are 5 measurement apertures (φ1=3.5mm, φ2=6mm, φ3=10mm, φ4=17mm, φ5=25mm), and on the surface of colored spun yarn and its fabric, measure once every ∆L length and ∆H height (according to actual experience, such as ∆L=∆H=2cm) from left to right in array, a total of S positions (such as S=10). Therefore, the spectral feature value of the ith position of aperture φk is φk-i =[R φk-i-λ1 , R φk-i-λ2 , ……, R φk-i-λ31 ].
[0080] 13. Standardization: Perform zero-mean and unit-variance standardization on the RGB channels of the image, i.e. where μR, μG, μB are the mean values of R, G, B channels in the training set images, and σR, σG, σB are the standard deviations of R, G, B channels in the training set images.
[0081] Step 2, model training;
[0082] Model initialization: The color prediction model is constructed according to the method of the present application, including 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 parameters in the model are initialized, such as the weights of the convolutional layer and the fully connected layer in the network structure of the color feature extraction module are initialized using the Xavier normal distribution, the weights of the Bi-LSTM are initialized using the default initialization method, the weights of the spatial feature extraction module use the pre-trained weights on the ImageNet dataset (for layers that need to be fine-tuned), and the weights of the image color feature extraction module are randomly initialized.
[0083] Training parameter setting:
[0084] 211、Optimizer: The AdamW optimizer is selected to optimize the model parameters, and the learning rate is set to 1e-4 and the weight decay is set to 0.001. The AdamW optimizer combines the advantages of the Adam optimizer and L2 regularization, which can effectively prevent model overfitting and accelerate the convergence speed of the model.
[0085] 212、Loss function: According to the task requirements of the model, the Mean Squared Error (MSE) is used as the loss function to measure the difference between the predicted color and the true color; the cross-entropy function is used as the loss function for classification tasks to calculate the error between the predicted fiber type and the true distribution of the probability distribution. The total loss function is the weighted sum of the regression loss and the classification loss, and the weight is adjusted according to the actual situation (such as 0.5 each).
[0086] 213、Training rounds and batch size: The model training rounds are set to 300 rounds, and the batch size is 32. In the training process, each round of training will traverse the entire training set, and the training data will be divided into several batches, each batch containing 32 samples, which will be input into the model for training and parameter updating.
[0087] Training process:
[0088] 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.
[0089] 222、The image data is input into the image feature extraction module, and the module output is input into the image spatial feature extraction module to obtain the image feature vector F i ; the spectral data is input into the color feature extraction module (1D-CNN), the color feature fusion module (DNN), and the spatial feature extraction module (Bi-LSTM) to obtain the unit color feature, the aperture level fusion feature, and the spatial feature vector F s , respectively.
[0090] 223、F i and F s The input atlas feature fusion module outputs fiber types and ratio probability distribution after feature fusion and transformation.
[0091] 224、According to the prediction results and the true labels, the value of the loss function is calculated, and the gradient is calculated through the back propagation algorithm to update the parameters of the model. During the back propagation process, the contribution of all modules is considered when calculating the gradient of each parameter, so as to realize the joint optimization of the whole model.
[0092] 225、After each round of training is completed, the model is evaluated using the validation set, and the loss value on the validation set, the average color difference (such as the average value of CIE DE2000 color difference) of color prediction, and the prediction accuracy of fiber types and ratio, etc. are calculated. According to the evaluation results of the validation set, the hyperparameters (such as learning rate, weight of loss function, etc.) of the model are adjusted to avoid overfitting or underfitting of the model.
[0093] Step 3, model evaluation and application;
[0094] Model evaluation: when the model training is completed, the model is finally evaluated using the test set. The performance indicators of the model are calculated on the test set, including the average color difference (such as the average value of CIE DE2000 color difference, the lower the better indicates that the predicted color is closer to the true color), the prediction accuracy of fiber types and ratio (the proportion of the number of samples predicted correctly to the total number of samples, the higher the better indicates that the prediction is more accurate), mean square error (MSE) and mean absolute error (MAE) etc. Through these indicators, the performance and accuracy of the model are comprehensively evaluated, and compared with other related models, to verify the effectiveness and superiority of the method of the present application.
[0095] Model application: the trained model is applied to actual production for the prediction of color spun yarn and its fabric color formula. The specific application process is as follows:
[0096] 31、For the color spun yarn or fabric sample to be predicted, first obtain its image data and spectral data according to the data acquisition and preprocessing method.
[0097] 32、The preprocessed image data and spectral data are input into the trained model, and the model outputs the fiber type and ratio probability distribution.
[0098] 33、According to the prediction results, the production personnel can adjust the production formula of the colored spun yarn, such as adjusting the proportion of different base color fibers, to achieve the desired color effect. At the same time, the prediction results of the model can also be used for quality control, by comparing the predicted color with the actual produced color, to find and correct the deviation in the production process in time, and to improve the quality and consistency of the product.
[0099] In order to verify the effectiveness of the model, the present application selects a variety of fiber ratio colored spun yarn fabric samples from a textile enterprise, and mixes them in disorder and divides them into three groups for model prediction. Among them, the image data is taken by a high-resolution industrial camera (Basler acA2500-14gm) under specific lighting conditions (D65 standard light source, simulating daily lighting environment, color temperature about 6500K) for color spun yarn fabric. The spectral data is obtained by color measurement of the color spun yarn fabric by X-rite Color i7 spectrophotometer. It is verified by experiment that the model training provided by the present application can reach MSE=0.00222, effectively meeting the requirements of the enterprise in the preparation process of the color spun yarn fabric.
[0100] Table 1 Comparison of model performance
[0101]
[0102] It should be understood that the above description of the preferred embodiments is more detailed and should not be considered as limiting the scope of patent protection of the present application. Those skilled in the art can make substitutions and modifications without departing from the scope of the present application, which shall fall within the scope of protection of the present application. The scope of protection of the present application shall be subject to the appended 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 five apertures [R1f, R2f, R3f, R4f, R5f]. The color fusion features of each aperture are 31-dimensional, forming a 5×31-dimensional aperture feature matrix sorted by physical position. A two-layer Bi-LSTM is used to extract sequence spatial 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. The output is the forward hidden state matrix and the backward hidden state matrix, both of which are 64-dimensional, and the concatenated dimensions are 128-dimensional. The second layer of Bi-LSTM focuses on long-distance dependencies. The forward hidden state matrix and the backward hidden state matrix are each 128-dimensional. The hidden state matrix H of 5 positions is output. The forward hidden state matrix and the backward hidden state matrix of each position are spliced into 256 dimensions. Finally, the hidden state matrix of each position is compressed to 31 dimensions through the linear mapping layer to maintain 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 wavelengths, 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, which is sequentially processed through a 3×3 convolutional layer, a global average pooling layer, and a fully connected layer FC to extract color features.
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 has 128 neurons, ReLU activation, and weight initialization uses Xavier normal distribution. The second fully connected layer has 64 neurons, and the third fully connected layer has 31 neurons, with a dropout rate of 0.2 and an activation function Tanh. The feature dimensions are aligned to the 31 wavelength points of the spectral data, and a 10×31-dimensional matrix is output. After global average pooling, a 31-dimensional aperture-level fusion feature is generated.
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 association between image regions and aperture spectra, Q is the query vector, K is the key vector, 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; 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