CNN-Transform fusion model-based textile color fastness automatic rating method and system

Through the automatic rating method of textile color fastness based on the CNN-Transformer fusion model, the existing rating methods have been solved, and the high-precision textile color fastness rating is achieved, and the five-level nine-level fine rating standards are adapted.

CN119850607AActive Publication Date: 2025-04-18ZHEJIANG SHIKE INSTR CO LTD +1

Patent Information

Application Number
CN202510323086.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-04-18
Estimated Expiration
2045-03-19

AI Technical Summary

Technical Problem

The existing color fastness rating methods for textiles have problems such as poor accuracy, low consistency and difficulty in adapting to fine rating standards, especially in the process of feature extraction, it is difficult to simultaneously capture local detailed features and global structural features.

Method used

The automatic rating method of textile color fastness based on the CNN-Transformer fusion model is adopted to collect image data through a high-resolution RGB color industrial camera, and grayscale, denoising and spectral data preprocessing are performed. Then, the CNN module is constructed to extract local features, combine with the Transformer module to extract global features, and then weighted through the attention mechanism to perform fusion, and finally calculate the color fastness level probability through the Softmax function.

Benefits of technology

It realizes automated and high-precision textile color fastness rating, improves the accuracy and consistency of rating results, and can adapt to the five-level nine-level fine rating standards.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850607A_ABST
    Figure CN119850607A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic textile color fastness rating method and system based on a CNN-Transform fusion model, and relates to the technical field of textile digital detection. And then, feature extraction and rating are carried out by using a CNN-Transform fusion model. After the features of the two are fused, weighting is carried out through an attention mechanism, classification is carried out through a full-connection layer, and the color fastness grade probability is determined through a Softmax function. Meanwhile, a cross entropy loss function is combined with a label smoothing technology, an Adam optimizer is utilized, and a learning rate attenuation strategy is matched to train the model. Finally, confidence evaluation and result correction are carried out on the rating result, automatic and high-precision textile color fastness rating is achieved, and the problems that an existing rating method is poor in accuracy, low in consistency, difficult to adapt to fine rating standards and the like are effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of digital textile detection, and in particular to a method and system for automatically rating the color fastness of textiles based on a CNN-Transformer fusion model. Background Art

[0002] In the textile quality inspection system, color fastness is a key quality indicator that reflects the stability of textile color under the influence of various external factors such as light, washing, friction, etc. The currently widely used five-level nine-grade color fastness rating system divides color fastness from good to poor into five levels and nine grades, thereby accurately measuring the color retention ability of textiles.

[0003] Traditional methods of textile color fastness rating mainly include visual rating and instrument rating. Visual rating relies on manual observation and comparison, and is greatly affected by subjective factors of the raters (such as visual differences, experience level) and environmental factors (such as lighting conditions), resulting in poor accuracy and consistency of the rating results. The ratings of the same textile by different raters may even differ by 1-2 grades. Although instrument rating can reduce human interference to a certain extent, due to the limitations of instrument calibration accuracy, measurement principles and errors in the operation process, its measurement results deviate from the actual color fastness, and the comparability of measurement results between different instruments is poor. Existing methods have many shortcomings in dealing with textile color fastness rating. On the one hand, in the feature extraction process, it is difficult to effectively capture the local detail features and global structural features of textiles at the same time. Local detail features are crucial for accurately identifying subtle changes in color, while global structural features help to grasp the overall color distribution and the impact of patterns on color fastness. On the other hand, the existing deep learning model lacks targeted optimization for the fine rating standard of five levels and nine grades, and it is difficult to accurately distinguish adjacent levels, so that the accuracy of the rating results needs to be improved. Summary of the invention

[0004] In view of the shortcomings of the prior art, the object of the present invention is to provide a method and system for automatic rating of color fastness of textiles based on a CNN-Transformer fusion model.

[0005] To achieve the above object, the present invention provides the following technical solutions: A method for automatically evaluating color fastness of textiles based on a CNN-Transformer fusion model, comprising the following steps: S1 uses a high-resolution RGB color industrial camera to collect image data of textiles under a standard D65 light source environment. ,in, represents the coordinates of the image pixels, Represents pixel The color value is recorded in RGB color space. , , is the pixel point in the RGB image The red, green and blue channel values ​​of the image are obtained, and the grayscale data and spectral data of the image are preprocessed; S2 constructs a CNN module, which outputs local features including local texture and color changes of textile images through alternating stacking of multiple convolutional layers, pooling layers, and activation functions. ; S3 reshapes the feature map output by the CNN module and makes it conform to the input requirements of the Transformer. It is then input into the Transformer module. After being processed by the Transformer module, the global features including global color distribution and pattern structure features are obtained by introducing position encoding. ; S4 extracts local features from the CNN module And the global features extracted by the Transformer module Fusion and fusion features After being weighted by the attention mechanism, it is input into the fully connected layer, the probability of color fastness level is calculated by the Softmax function, and the color fastness level corresponding to the maximum probability is output; S5 uses the cross-entropy loss function combined with label smoothing technology to train the model, uses the Adam optimizer and learning rate decay strategy to optimize model parameters, and improves generalization capabilities through data enhancement and model integration; it conducts confidence assessment on the rating results, and triggers a correction mechanism if the confidence is lower than the threshold.

[0006] In S1, the image data Grayscale, denoising, and contrast enhancement processing are performed, and the color space is converted to the CIE XYZ color space to derive spectral reflectance data, and the spectral reflectance data is normalized, dimensionally reduced, and standardized.

[0007] S1 for image data Grayscale processing is performed, including the following steps: I. Image data pass Convert to grayscale image ;.

[0008] II. Obtain the denoised image through Gaussian filtering;.

[0009] III. Use histogram equalization technology to enhance image contrast and make the image grayscale distribution more uniform.

[0010] In S1, the image data is preprocessed with spectral data, including the following steps: I. Based on the collected image data, Convert image data from RGB color space to CIE XYZ color space, where , , is the converted CIE XYZ color space value; II. According to , calculate the spectral reflectance data within a specific wavelength range based on CIE XYZ values , where , , For different wavelengths CIE XYZ values ​​under; , , is the CIE standard observer spectral tristimulus value; is the spectral power distribution of the lighting source; III. The obtained spectral reflectance data is Spectral reflectance data Normalize it and map its value range to interval, where and are the minimum and maximum values ​​of the spectral reflectance data, respectively; IV. Use principal component analysis to reduce the dimensionality of spectral data and extract the main components , calculate the covariance matrix of the spectral data ,right Perform eigenvalue decomposition to obtain eigenvalues and the eigenvector , select the previous one according to the eigenvalue contribution rate feature vectors, such that , is the number of original features, thus obtaining the spectral data after dimension reduction; V. Standardize the spectral data after dimension reduction to have zero mean and unit variance.

[0011] The CNN module consists of multiple convolutional layers, pooling layers and activation functions. At the same time, a dilated convolution technique is introduced in the convolutional layer to expand the receptive field of the convolution kernel to capture a wider range of local color change information, and the dilation rate is set to 2. The Transformer module includes a multi-head attention mechanism and position encoding, and encodes the feature position through sine and cosine functions.

[0012] In S4, the local features extracted by the CNN module And the global features extracted by the Transformer module Fusion is performed and fusion features are obtained by splicing , and use the attention mechanism to fusion features The weight of the attention mechanism is dynamically adjusted through learnable parameters.

[0013] In S5, the model integration adopts the voting method to train multiple CNN-Transformer fusion models with different initializations, count the prediction results of each model and select the level with the most votes as the final rating result.

[0014] A system for implementing the above-mentioned method for automatic rating of textile color fastness based on CNN-Transformer fusion model, comprising: An image acquisition module, used to acquire image data of textiles under a standard D65 light source environment; Preprocessing module, used for grayscale, denoising, spectral data conversion and standardization of images; Fusion model module, including CNN module and Transformer module, used for feature extraction and fusion; Classification module, used to output color fastness grade probability and final rating results; Post-processing module, used for confidence assessment and result correction.

[0015] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned automatic evaluation method for color fastness of textiles based on a CNN-Transformer fusion model.

[0016] The beneficial effects of the present invention are as follows: by combining the powerful local feature extraction capability of CNN with the excellent global information capture capability of Transformer, the features related to the color fastness of textiles can be accurately extracted, and the rating process can be optimized for the five-level nine-grade rating system to achieve automated and high-precision color fastness rating of textiles, effectively solving the problems of poor accuracy, low consistency and difficulty in adapting to fine rating standards in existing rating methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a schematic diagram of the process of the present invention.

[0018] Figure 2 It is a schematic diagram of the CNN model adopted in the present invention.

[0019] Figure 3 It is a schematic diagram of the Transformer model adopted in the present invention.

[0020] Figure 4 The present invention is a table of corresponding relations between the color fastness of the present invention and the gray scale grade of the color change.

[0021] Figure 5 The present invention is a table of corresponding relations between the color fastness to staining and the gray scale for staining. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0024] like Figure 1 As shown, the present invention provides a method for automatically rating color fastness of textiles based on a CNN-Transformer fusion model, which comprises the following steps: S1 uses a high-resolution RGB color industrial camera to collect image data of textiles under a standard D65 light source environment. ,in, represents the coordinates of the image pixels, Represents pixel The color value is recorded in RGB color space. , , is the pixel point in the RGB image The red, green and blue channel values ​​of the image are obtained, and the grayscale data and spectral data of the image are preprocessed; S2 constructs a CNN module, which outputs local features including local texture and color changes of textile images through alternating stacking of multiple convolutional layers, pooling layers, and activation functions. ; S3 reshapes the feature map output by the CNN module and makes it conform to the input requirements of the Transformer. It is then input into the Transformer module. After being processed by the Transformer module, the global features including global color distribution and pattern structure features are obtained by introducing position encoding. ; S4 extracts local features from the CNN module And the global features extracted by the Transformer module Fusion and fusion features After being weighted by the attention mechanism, it is input into the fully connected layer, the probability of color fastness level is calculated by the Softmax function, and the color fastness level corresponding to the maximum probability is output; S5 uses the cross-entropy loss function combined with label smoothing technology to train the model, uses the Adam optimizer and learning rate decay strategy to optimize model parameters, and improves generalization capabilities through data enhancement and model integration; it conducts confidence assessment on the rating results, and triggers a correction mechanism if the confidence is lower than the threshold.

[0025] 1. Data Collection and Preprocessing Using a high-resolution RGB color industrial camera, image data of textiles is collected under a standard D65 light source environment. ,in, represents the coordinates of the image pixels, Represents pixel The color value is recorded in RGB color space. , , is the pixel point in the RGB image The red, green, and blue channel values ​​of the image are shown in Figure 1. The standard D65 light source simulates average daylight. Collecting images under this light source can ensure that the acquired color information has good versatility and reference value.

[0026] (1) Image grayscale data preprocessing In order to facilitate the subsequent focus on the extraction of texture and structural features of the image, simplify the image information, convert the color image into a grayscale image with only brightness information, and remove the interference of color. The collected RGB image is grayed and converted into a grayscale image using formula (1): , and the denoised image is obtained by Gaussian filtering (Formula 2): (1) (2) Here, 0.299, 0.587, and 0.114 are weight coefficients determined based on the sensitivity of the human eye to different colors of light. is the Gaussian kernel function, is the filter window radius, is the standard deviation of the Gaussian distribution.

[0027] The value of can be determined by calculating the noise power spectral density of the image: that is, the spectrum is obtained by Fourier transforming the image , calculate the power spectral density , the mean of the statistical power spectral density , according to the empirical formula ( is a constant, determined experimentally to be 10).

[0028] After that, the histogram equalization technology is used to enhance the image contrast, make the image grayscale distribution more uniform, improve the clarity, and facilitate the subsequent feature extraction. Histogram equalization redistributes the grayscale values ​​of the image to make the pixels originally concentrated in certain grayscale intervals more evenly distributed. This can highlight the detailed differences in color and texture in the image, which is critical for the extraction of color fastness related features.

[0029] (2) Spectral data preprocessing Based on the collected image data, the image data is converted from the RGB color space to the CIE XYZ color space using formula (3): (3) in , , The converted CIE XYZ color space value (CIE XYZ color space is a device-independent color space that can more accurately describe color characteristics).

[0030] Spectral reflectance It reflects the reflectivity of textiles to light of different wavelengths. The shape and value of the curve represent the difference in textile color at the spectral level, which is closely related to the color fastness rating. Assuming that within a specific wavelength range (such as 380nm - 780nm), the corresponding spectral reflectance data is derived through the pre-established relationship model between spectral reflectance and CIE XYZ value, combined with the XYZ value of each pixel in the image. Calculate the spectral reflectance data according to CIE XYZ values ​​according to formula (4): : (4) In the formula, , , For different wavelengths CIE XYZ values ​​under; , , is the CIE standard observer spectral tristimulus value; It is the spectral power distribution of the lighting source, measured by special equipment.

[0031] Normalization can eliminate the differences in dimension and value range of spectral reflectance data of different samples, making the data comparable and facilitating the learning and processing of subsequent models. Therefore, the obtained spectral reflectance data is calculated according to formula (5): Normalize it and map its value range to Range: (5) in and are the minimum and maximum values ​​of the spectral reflectance data, respectively.

[0032] Spectral data is usually high-dimensional and contains a lot of redundant information. PCA dimensionality reduction can reduce data dimensions and improve computational efficiency while retaining the main information. It also helps to remove noise and irrelevant information and highlight the spectral features related to color. . Calculate the covariance matrix of the spectral data ,right Perform eigenvalue decomposition to obtain eigenvalues and the eigenvector , select the previous one according to the eigenvalue contribution rate feature vectors, such that ( is the number of original features), thus obtaining the spectral data after dimension reduction.

[0033] Standardization further optimizes the data distribution, making it easier for the model to learn the rules in the data and improving the performance and stability of the model. Finally, the spectral data after dimension reduction is standardized to have zero mean and unit variance, as shown in formula (6): (6) in is the mean of the spectral data after dimension reduction, is the standard deviation.

[0034] 2. Feature extraction and rating based on CNN-Transformer fusion model (1) CNN module local feature extraction Construct a CNN module, such as Figure 2 As shown in Figure 1, it consists of multiple convolutional layers, pooling layers, and activation functions. The convolutional layer performs convolution operations by sliding the convolution kernel on the image to extract local features. The convolution operation formula is shown in formula (7): (7) in, is the pixel value of the image after convolution, Is the size of The convolution kernel weights, is the image pixel value before convolution, is the bias term. During the sliding process, the convolution kernel performs weighted summation on the image pixel values ​​at different positions. Since the color information of the image is contained in the pixel value (represented as , , Therefore, the convolution kernel can not only capture the spatial position information of the image, but also integrate the physical quantities related to the color information and extract local features containing color changes and texture details (for example, for areas with obvious color changes in textile images, the convolution kernel can capture the changing trend of RGB values ​​and then extract local features related to color, such as changes in color boundaries, local color unevenness, etc.). These local features are crucial for judging the color measurement performance of textiles in local areas. The pooling layer is used to reduce the data dimension and retain the main features. The maximum pooling is used, formula (8): (8) in , is the function to find the maximum value, is the pooling window size. The pooling operation can highlight the areas in the image where color and texture changes are more significant by selecting the maximum value within the pooling window, further simplifying the data, reducing the amount of calculation, and retaining key features.

[0035] The ReLU function can introduce nonlinear factors, enabling the neural network to learn more complex feature relationships, which is very important for extracting nonlinear changes in color and texture features. The activation function in the present invention adopts the classic ReLU function.

[0036] Through the alternating stacking of multiple convolutional layers, pooling layers, and activation functions, the CNN module can effectively extract detailed features such as local texture and color changes of textile images. .

[0037] In order to further enhance the feature extraction capability, the dilated convolution technique shown in formula (9) is introduced into the convolution layer: (9) in is the dilation rate, which is set to 2 according to experiments. It can expand the receptive field of the convolution kernel without increasing the number of parameters, and capture richer local details, including color change information in a wider area. Dilated convolution can perceive changes in color and texture in a larger range, and is effective in capturing some subtle but color-related local features.

[0038] (2) Transformer module global feature extraction The feature map output by the CNN module is reshaped to meet the input requirements of the Transformer, and then input into the Transformer module, such as Figure 3 As shown in the figure. The multi-head attention mechanism in the Transformer module can focus on different parts of the input features at the same time and capture global information. The multi-head attention mechanism can capture the impact of color distribution and pattern structure on color fastness from a global perspective by calculating the correlation between features at different positions. The multi-head attention formula is: (10) in , ,here, , , are query, key, and value matrices respectively, , , , is the weight matrix, is the dimension of the key vector, is the number of heads.

[0039] After being processed by the Transformer module, the global features are obtained In the Transformer module, the input feature map contains color and texture information that has been preliminarily processed by CNN. For example, in the case of complex patterns on textiles, the Transformer module can analyze the color relationship between different pattern areas and the uniformity of the overall color distribution to obtain global features related to color fastness.

[0040] In order to better utilize the ability of the Transformer module to capture global information, position encoding is added to it. The position encoding formula is: (11) (12) in, and are the sine and cosine functions, respectively. is the position index, is the dimension index, The hidden layer dimension of the Transformer model is used to enable the Transformer module to perceive the position information of the feature through position encoding, and more accurately capture the global structural features, including the distribution characteristics of the color on the entire textile sample. Position encoding helps the Transformer module to consider the spatial position relationship of color and texture features when processing features, which is crucial for accurately grasping the overall color characteristics and color fastness assessment of textiles.

[0041] (2) Fusion feature generation and rating The local features extracted by the CNN module And the global features extracted by the Transformer module Fusion is performed and fusion features are obtained by splicing The fused features are input into the fully connected layer for classification, taking into account the five-level nine-grade rating system for color fastness to staining and color change (reference Figure 4 , Figure 5 ), using numbers To represent different levels, the number of output nodes of the fully connected layer is set to 9. The output of the fully connected layer The representative model belongs to the sample Color fastness grades Value Correspondence The prediction scores of , which are not yet directly reflected as probabilities.

[0042] With the help of Softmax function, Converted into probability values ​​belonging to each color fastness grade ,Right now (13) In the formula, The score is converted by exponential operation Mapped to the positive range, the denominator The index scores of all grades are summed up and normalized so that the sum of all probability values ​​is 1, which conforms to the characteristics of probability distribution. The model finally takes the category with the largest probability value as the predicted color fastness grade to determine the color fastness rating of the textile.

[0043] The attention mechanism can automatically learn the importance weight of each feature element, strengthen the color and texture features that have an important impact on the color fastness rating, and improve the accuracy of the rating. Before the fusion features are input into the fully connected layer, in order to achieve feature enhancement, the attention mechanism is used to weight them, as shown in formula (14): (14) in, It is the first fusion feature elements, is the length of the fused feature, , and are learnable weights and biases to highlight the features that are more critical to color fastness rating. These features contain color information and its change characteristics from local to global.

[0044] (4) Model training optimization Design an optimization objective based on the cross entropy loss function and combine it with label smoothing technology to prevent model overfitting. Represents different levels, and the loss function is: (15) In the formula, is the sample size, is the label smoothing parameter, is the indicator function (when 1 if yes, 0 otherwise), is the model prediction sample Belong to level probability.

[0045] The model is trained using the Adam optimizer, which updates the parameters according to formula (16): (16) in is the first moment estimate of the gradient, is the exponential decay rate of the first-order moment estimate, usually set to 0.9, is the loss function at the current parameters The second moment estimate of the gradient From formula (17), we can get (17) here is the exponential decay rate of the second-order moment estimate, usually set to 0.999; Then the first-order moment estimation and second-order moment estimation correction are performed, and the corrected first-order moment estimation is , the corrected second-order moment estimate is ; , is the model parameter at the current moment, is the learning rate, A small constant to prevent the denominator from being zero.

[0046] During the training process, the learning rate decay strategy is adopted. After a certain number of training rounds (such as 10 rounds), the learning rate is multiplied by the decay factor (such as 0.9). The formula is ,in is the updated learning rate, is the learning rate before updating, is the attenuation factor. As the training progresses, gradually reducing the learning rate can make the model converge more stably in the later stages of training and avoid missing the optimal solution due to an excessively large learning rate.

[0047] 3. Model performance improvement strategy In order to increase the diversity of training data and improve the generalization ability of the model, various enhancements are performed on the training data. Geometric transformations such as rotation, translation, scaling, and flipping, as well as color transformations such as brightness adjustment, contrast adjustment, and color jittering are used. The rotation operation is (18) in is the original pixel coordinate, is the pixel coordinate after rotation, is the rotation center coordinate, is the rotation angle, and the range of random radians during training is .

[0048] The brightness is adjusted according to formula (19): (19) in is the brightness adjustment factor, Random value in the range.

[0049] In addition, Cutout data enhancement technology is used to randomly block some areas on the image to enhance the model's robustness to local feature loss. These enhancement operations not only act on the spatial structure of the image, but also diversify the color information, so that the model can learn the characteristics of different color changes and improve the recognition ability of various color fastness conditions. For example, through brightness adjustment and color jitter, the color changes of textiles under different lighting conditions can be simulated, allowing the model to better adapt to the complex environment in practical applications.

[0050] Train multiple CNN-Transformer fusion models with different initialization parameters and use voting method for model integration. Assume that The trained CNN-Transformer fusion models are denoted as For a test sample $X$, each model predicts it, and the prediction result is the color fastness grade.

[0051] In the five-level nine-grade rating system, the numbers To indicate different levels. Each model For samples The predicted color fastness grade is recorded as , .

[0052] Let the voting count array be , initially , . The prediction results of each model are statistically analyzed. The predicted color fastness grade is ,but ,Right now: Finally, the grade with the most votes is the final predicted color fastness grade of the test sample. It can be expressed as: ,in, Indicates the final predicted color fastness grade.

[0053] This voting method can be used to integrate models and synthesize the prediction results of multiple models. Since different models are trained from different initial states, the learned features and decision boundaries are different, which can effectively reduce the variance of the model, improve the stability and accuracy of the model, reduce the error of a single model, and improve the overall prediction performance.

[0054] 4. Post-processing of rating results (1) Confidence evaluation: For the color fastness grade predicted by the model, the confidence is calculated through the probability value output by the Softmax function. The grade with the highest predicted probability is selected as the prediction result, and the maximum probability value is the confidence.

[0055] When the confidence level is lower than the set threshold (such as 0.7), it can be considered that the model's rating results for the sample are less reliable and require further manual verification or other auxiliary means to confirm.

[0056] For example, images of the sample under different angles or light sources can be recaptured and analyzed again; or the color fastness grade can be comprehensively judged in combination with data from other testing equipment to ensure the accuracy of the rating results.

[0057] (2) Result correction: Establish a rating result correction mechanism, collect a large amount of actual rating data, and analyze the deviation patterns between the model prediction results and the actual ratings.

[0058] The correction mechanism includes: When the confidence level is lower than the threshold, the sample image is collected again or combined with data from other detection equipment for comprehensive judgment; a rule correction system is established based on historical deviation rules to dynamically adjust the rating results of specific colors or patterns.

[0059] For example, if it is found that the model has systematic deviations in the rating of textiles of certain specific colors (such as dark textiles) or patterns (such as complex patterns), the model parameters can be adjusted or the corresponding training data can be added. It is also possible to build a rule-based correction system to formulate a series of correction rules based on the difference between the model prediction results and the actual ratings.

[0060] For example, when the model prediction result is higher or lower than the actual rating by a certain degree, the prediction result can be adjusted according to the rules to improve the accuracy of the rating. The feedback mechanism can also be used to re-enter the corrected results into the model for training, so that the model can learn these correction information, further optimize the model performance, and reduce the deviation of future predictions.

[0061] The present invention also provides a system for realizing the above-mentioned method for automatically rating the color fastness of textiles based on the CNN-Transformer fusion model, which comprises: Image acquisition module, used to collect image data of textiles under standard D65 light source environment, using high-resolution RGB color industrial camera to collect image data of textiles under standard D65 light source environment , ensuring the accuracy and universality of color information; The preprocessing module is used to grayscale, denoise, convert spectral data and standardize the image, that is, grayscale, denoise, contrast enhance and convert spectral data of the collected image data to generate standardized input data. The grayscale is converted using the weighted formula The denoised image is obtained by Gaussian filtering. The spectral data conversion is based on the CIE XYZ color space. The corresponding spectral reflectance data is derived by combining the XYZ value of each pixel in the image through the pre-established relationship model between spectral reflectance and CIE XYZ value. ,The spectral data were reduced in dimension using the principal component analysis (PCA) method and then input into the model after standardization; The fusion model module includes a CNN module and a Transformer module for feature extraction and fusion. The CNN module contains four convolutional layers (including dilated convolution), a maximum pooling layer, and a ReLU activation function to extract local texture and color change features. The Transformer module contains a multi-head attention mechanism and sine-cosine position encoding to capture global color distribution and pattern structure features. The local features output by CNN are then concatenated with the global features output by Transformer and weighted through the attention mechanism. The classification module classifies the fused features and outputs five-level and nine-level color fastness rating results. The Softmax function calculates the probability of each level and selects the level corresponding to the maximum probability value as the final result; Post-processing module, used for confidence assessment and result correction.

[0062] The present invention also provides a computer-readable storage medium, such as a solid-state hard drive, an optical disk, a cloud server storage unit, etc., on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned automatic rating method for color fastness of textiles based on the CNN-Transformer fusion model is implemented.

[0063] When executed by the processor, the following operations are performed: Controlling the image acquisition device to acquire the textile image under the D65 light source; Call the preprocessing algorithm to grayscale, denoise, convert spectral data and standardize the image; Load the pre-trained CNN-Transformer fusion model to extract and fuse local and global features; Output the color fastness grade probability through the fully connected layer and Softmax function; Perform data augmentation and model ensemble (voting method); Assess confidence and trigger correction logic (such as rule base matching or feedback training).

[0064] The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory, wherein when the processor executes the program, the above-mentioned automatic evaluation method for color fastness of textiles based on the CNN-Transformer fusion model is implemented.

[0065] Memory: includes non-volatile storage units (such as SSD) and volatile storage units (such as RAM), used to store programs and temporary data; Processor: Multi-core CPU or GPU (such as NVIDIA Tesla series) that supports parallel computing for efficient execution of CNN-Transformer model inference; Image acquisition interface: supports connecting to industrial cameras and transmitting RAW or JPEG format image data; Communication module: supports Wi-Fi / 5G, used to receive external instructions or upload rating results to the cloud database.

[0066] Equipment workflow: 1. The processor loads program instructions from memory. 2. Obtain textile images through the image acquisition interface; 3. Call the preprocessing module to generate standardized input; 4. Run the fusion model for feature extraction and classification; 5. Output the rating results to the display screen or external system and execute the post-processing logic.

[0067] The embodiments should not be regarded as limiting the present invention, but any improvements made based on the spirit of the present invention should be within the protection scope of the present invention.

Claims

1. A method for automatic color fastness rating of textiles based on a CNN-Transformer fusion model, characterized by: It includes the following steps: S1 uses a high-resolution RGB color industrial camera to collect image data of textiles under a standard D65 light source environment. ,in, represents the coordinates of the image pixels, Represents pixel The color value is recorded in RGB color space. , , is the pixel point in the RGB image The red, green and blue channel values ​​of the image are obtained, and the grayscale data and spectral data of the image are preprocessed; S2 constructs a CNN module, which outputs local features including local texture and color changes of textile images through alternating stacking of multiple convolutional layers, pooling layers, and activation functions. ; S3 reshapes the feature map output by the CNN module and makes it conform to the input requirements of the Transformer. It is then input into the Transformer module. After being processed by the Transformer module, the global features including global color distribution and pattern structure features are obtained by introducing position encoding. ; S4 extracts local features from the CNN module And the global features extracted by the Transformer module Fusion and fusion features After being weighted by the attention mechanism, it is input into the fully connected layer, the probability of color fastness level is calculated by the Softmax function, and the color fastness level corresponding to the maximum probability is output; S5 uses the cross-entropy loss function combined with label smoothing technology to train the model, uses the Adam optimizer and learning rate decay strategy to optimize model parameters, and improves generalization capabilities through data enhancement and model integration; it conducts confidence assessment on the rating results, and triggers a correction mechanism if the confidence is lower than the threshold.

2. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 1, characterized in that: In S1, the image data Grayscale, denoising, and contrast enhancement processing are performed, and the color space is converted to the CIE XYZ color space to derive spectral reflectance data, and the spectral reflectance data is normalized, dimensionally reduced, and standardized.

3. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 2, characterized in that: S1 for image data Grayscale processing is performed, including the following steps: I. Image data pass Convert to grayscale image ; II. Obtain the denoised image through Gaussian filtering; III. Use histogram equalization technology to enhance image contrast and make the image grayscale distribution more uniform.

4. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 2, characterized in that: In S1, the image data is preprocessed with spectral data, including the following steps: I. Based on the collected image data, Convert image data from RGB color space to CIE XYZ color space, where , , is the converted CIE XYZ color space value; II. According to , calculate the spectral reflectance data within a specific wavelength range based on CIE XYZ values , where , , For different wavelengths CIE XYZ values ​​under; , , is the CIE standard observer spectral tristimulus value; is the spectral power distribution of the lighting source; III. The obtained spectral reflectance data is Spectral reflectance data Normalize it and map its value range to interval, where and are the minimum and maximum values ​​of the spectral reflectance data, respectively; IV. Use principal component analysis to reduce the dimensionality of spectral data and extract the main components , calculate the covariance matrix of the spectral data ,right Perform eigenvalue decomposition to obtain eigenvalues and the eigenvector , select the previous one according to the eigenvalue contribution rate feature vectors, such that , is the number of original features, thus obtaining the spectral data after dimension reduction; V. Standardize the spectral data after dimension reduction to have zero mean and unit variance.

5. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 1, characterized in that: The CNN module consists of multiple convolutional layers, pooling layers and activation functions. At the same time, a dilated convolution technique is introduced in the convolutional layer to expand the receptive field of the convolution kernel to capture more extensive local color change information, and the dilation rate is set to 2.

6. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 1, characterized in that: The Transformer module includes a multi-head attention mechanism and position encoding, and encodes the feature position through sine and cosine functions.

7. The automatic evaluation method for color fastness of textiles based on CNN-Transformer fusion model according to claim 1, characterized in that: In S4, the local features extracted by the CNN module And the global features extracted by the Transformer module Fusion is performed and fusion features are obtained by splicing , and use the attention mechanism to fusion features The weight of the attention mechanism is dynamically adjusted through learnable parameters.

8. The method for automatic color fastness rating of textiles based on CNN-Transformer fusion model according to claim 1, characterized in that: In S5, the model integration adopts the voting method to train multiple CNN-Transformer fusion models with different initializations, count the prediction results of each model and select the level with the most votes as the final rating result.

9. A system for implementing the method for automatically rating color fastness of textiles based on the CNN-Transformer fusion model according to any one of claims 1 to 8, characterized in that: It includes: An image acquisition module, used to acquire image data of textiles under a standard D65 light source environment; Preprocessing module, used for grayscale, denoising, spectral data conversion and standardization of images; Fusion model module, including CNN module and Transformer module, used for feature extraction and fusion; Classification module, used to output color fastness grade probability and final rating results; Post-processing module, used for confidence assessment and result correction.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for automatically rating color fastness of textiles based on a CNN-Transformer fusion model as described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Textile color stability and color aberration grading method

    CN101100807A

  • Automatic color fastness grading method and device for textiles

    CN110644216A

  • Textile color fastness automatic rating method based on spectrum reconstruction

    CN115855809A

  • Textile color fastness detection method and system based on machine vision

    CN118794895A

Cited By

  • Method and system for detecting color fastness of blended fabric

    CN120121556A

  • A Method and System for Detecting the Color Fastness of Blended Fabrics

    CN120121556B

  • Dye formula optimization method and system for disperse dark one-bath dyeing process

    CN120124498A

  • User generated content emotion recognition method and device, terminal and medium

    CN120492632A

  • Grading detection method and system for gradient color car cover film

    CN120831361A