Textile color difference online detection method based on deep learning

By dynamically adjusting the adversarial gradient strength of the domain adversarial network, the problem of misjudgment caused by changes in illumination in textile color difference detection is solved, and efficient and accurate color difference detection is achieved in complex lighting environments.

CN120997215AActive Publication Date: 2025-11-21SHAANXI WANRONG IND CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511519513.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2025-11-21
Estimated Expiration
2045-10-23

AI Technical Summary

Technical Problem

Traditional textile color difference detection algorithms are prone to misjudgment and missed judgment in complex and variable lighting environments. Existing domain adversarial training methods cannot adaptively adjust according to the intensity of lighting disturbances, resulting in unstable training or poor convergence.

Method used

A domain adversarial network, comprising a feature extractor, a color difference segmentation head, and a domain discriminator, is employed. By calculating the deviation between global statistical features and local structural features, and combining the discriminative loss value of the domain discriminator, the adversarial gradient strength is dynamically adjusted to achieve illumination-invariant feature learning.

Benefits of technology

It significantly improves the robustness and accuracy of color difference detection in textiles, and can efficiently identify color difference areas under complex and variable lighting conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997215A_ABST
    Figure CN120997215A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image processing, in particular to a textile color difference online detection method based on deep learning, which comprises the following steps: firstly, collecting a defect-free sample to establish an ideal illumination reference; a continuous illumination deviation descriptor is obtained by calculating the comprehensive deviation of the current image from the reference benchmark on the global chromaticity and brightness and the local structure texture; and finally, in field adversarial training, combining the descriptor with discriminator performance feedback to obtain a dynamic adversarial gradient modulation factor, adaptively adjusting the adversarial training intensity, forcing the network to learn illumination invariant features, and finally realizing accurate and stable chromatic aberration segmentation under variable illumination. According to the method, illumination deviation descriptors are calculated, discriminator performance feedback is combined, and the intensity of confrontation training in the field is dynamically modulated, so that illumination invariance features are learned.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing, and particularly relates to a textile color difference online detection method based on deep learning. BACKGROUND

[0002] In the field of industrial quality inspection such as textile production, using machine vision technology to automatically detect color difference defects on the surface of products is a key link to ensure product quality and production efficiency. Such detection systems usually deploy industrial cameras on the production line, real-time capture fabric images, and use image processing and deep learning algorithms to analyze the images to identify and locate color difference areas.

[0003] However, in the high-speed running production line, the actual lighting environment is extremely complex and changeable. The fluctuation of environmental light, the aging of the light source itself, and the local shadow caused by the shaking or wrinkling of the fabric will seriously interfere with the color and texture information of the image. The artifacts caused by uneven lighting have features very similar to real color difference defects on the image, which can easily cause misjudgment and omission of traditional detection algorithms, seriously affecting the stability and accuracy of the detection system.

[0004] In order to cope with the challenge of light changes, existing technologies have begun to use domain adaptive methods such as domain-adversarial neural networks (DANN). This method introduces a domain discriminator and conducts adversarial training with the main task, aiming to make the model learn light change insensitive features, thereby improving the model's generalization ability under different lighting conditions. However, traditional domain adversarial training methods usually use a fixed adversarial loss weight, or a pre-set static scheduling strategy as the training progresses. This way cannot adaptively adjust according to the severity of real-time light disturbance. When the light changes slightly, the fixed adversarial strength may be too strong, which may damage the feature learning of the color difference segmentation task; while when the light changes drastically, its adversarial strength may not be enough to effectively eliminate the domain difference, resulting in unstable training or poor convergence effect. SUMMARY

[0005] In view of the problem that the fixed confrontation strength may damage the feature learning of the color difference segmentation task or cause unstable training or poor convergence effect, the application provides a textile color difference online detection method based on deep learning, which comprises the following steps: a domain adversarial network comprising a feature extractor, a color difference segmentation head and a domain discriminator is used for training, and the training process uses source domain images under standard illumination and target domain images under variable illumination; a current target domain image is obtained, and global statistical features and local structural features thereof are calculated; the global statistical features and the local structural features are compared with preset reference benchmark values respectively to obtain global deviation components and local deviation components, and the global deviation components and the local deviation components are fused to obtain a continuous illumination deviation descriptor; a basic adversarial weight is calculated, and the value of the basic adversarial weight is positively correlated with the continuous illumination deviation descriptor; a feedback modulation factor is calculated, and the value of the feedback modulation factor is positively correlated with the difference between the discrimination loss value of the domain discriminator and a preset target loss value; the basic adversarial weight is multiplied by the feedback modulation factor to obtain a dynamic adversarial gradient modulation factor; and when the weight of the feature extractor is updated through back propagation, the dynamic adversarial gradient modulation factor is applied to the loss gradient of the domain discriminator.

[0006] Compared with the domain self-adaptive method in the prior art which adopts a fixed adversarial weight and is difficult to adapt to the illumination change in online production, the application calculates the deviation degree of the current image relative to the standard illumination in real time, and obtains a dynamic adversarial gradient modulation factor in combination with the feedback of the model discrimination performance. The factor can adaptively adjust the strength of the domain confrontation according to the severity of the illumination change. When the illumination change is large, the domain alignment is strengthened to learn illumination-invariant features. When the illumination change is small, the confrontation is weakened to retain more detailed features. The dynamic adjustment mechanism enables the model to better overcome the interference caused by the complex and changeable illumination in the online detection environment, thereby significantly improving the robustness and accuracy of color difference detection.

[0007] Further, the global statistical features comprise converting the current target domain image to a CIELab color space and extracting the mean value and standard deviation of the pixel values of the three color channels of the CIELab; and the local structural features comprise gradient energy features and gray level co-occurrence matrix contrast features of the brightness channel.

[0008] Compared with the prior art which may only use single color or brightness information, the application can more comprehensively and accurately describe the changes of the image caused by illumination change by combining the global color distribution of the CIELab space and the local texture details of the brightness channel. The multi-dimensional feature combination provides a richer and more reliable basis for subsequent calculation of the illumination deviation degree, thereby improving the accuracy of dynamic adversarial weight calculation.

[0009] Further, the method for obtaining the global deviation component is: calculating the Mahalanobis distance between the global statistical feature vector of the current target domain image and the reference mean vector of the reference benchmark value; and the method for obtaining the local deviation component is: performing logarithmic transformation on the absolute value of the difference between the local structure feature value of the current target domain image and the corresponding reference feature value of the reference benchmark value, and performing weighted summation on the transformed result.

[0010] Compared with the simple Euclidean distance or absolute value difference that can be used in the prior art, the Mahalanobis distance is calculated for the global feature, the correlation between features can be considered, the distance measurement is not affected by the dimension, and the distance measurement is more statistically significant; the logarithmic transformation is used for the local feature, the influence of an abnormally large value can be effectively compressed, and the deviation measurement is more smooth and stable. This calculation method can more accurately quantify the difference between the image and the reference benchmark, thereby providing a guarantee for generating an accurate illumination deviation descriptor.

[0011] Further, the method for calculating the basic adversarial weight is: inputting the difference between the continuous illumination deviation descriptor and a preset activation threshold into a Sigmoid function to obtain the basic adversarial weight.

[0012] Further, the method for calculating the feedback modulation factor is: performing hyperbolic tangent transformation on the difference between the discrimination loss value of the domain discriminator and the preset target loss value, and performing exponential operation on the transformed result to obtain the feedback modulation factor.

[0013] Further, the preset target loss value is .

[0014] Further, the fusion method of the continuous illumination deviation descriptor is specifically: performing weighted summation on the global deviation component and the local deviation component, wherein the weight coefficient of the local deviation component is in the range of 0.4 to 0.6.

[0015] Further, the feature extractor adopts a ResNet network structure, the color difference segmentation head adopts a feature pyramid network structure, and the domain discriminator adopts a multi-layer perceptron structure.

[0016] By using ResNet, feature pyramid network (FPN) and multi-layer perceptron (MLP), which are mature network structures verified as superior performance in the field of computer vision, the method of the present application provides strong feature extraction, multi-scale segmentation and discrimination ability, guarantees the basic performance and reliability of the method, and enables the method to efficiently learn deep features from images and accurately locate color difference regions.

[0017] Further, the reference value establishing method comprises: collecting multiple images of defect-free fabrics under standard light, calculating a global statistical feature vector and a local structural feature value of each image; taking a mean vector and a covariance matrix of the global statistical feature vector as a global reference benchmark; and taking a mean value of the local structural feature value as a local reference benchmark.

[0018] Further, the domain adversarial network comprises a total loss function which is minimized, the total loss function is defined as: ; wherein represents a segmentation loss calculated based on a model segmentation output and an artificial annotation true value; represents the dynamic adversarial gradient modulation factor; represents a discriminator loss.

[0019] Compared with a fixed and unchangeable adversarial loss term weight in a traditional method, the loss function of the present application can adaptively balance the two goals of segmentation accuracy and domain confusion according to the change of the dynamic adversarial gradient modulation factor, and intelligently trade off in the training process, thereby more efficiently guiding the model to learn robust features that can accurately segment color difference and are not sensitive to light changes.

[0020] The technical effect of the present application is: The core innovation of the present application is to propose a dynamic domain adversarial learning strategy for textile color difference online detection. It discards the fixed adversarial weight in the traditional method, and dynamically generates a modulation factor by real-time calculation of the deviation degree of the current image from the standard light benchmark in terms of global color and local structure, combined with the performance feedback of the discriminator. The factor can adaptively adjust the intensity of domain adversarial, so that the model can more intelligently and efficiently learn the invariance feature of light when facing the complex and variable light conditions of the production line, thereby significantly improving the stability and accuracy of color difference detection. BRIEF DESCRIPTION OF DRAWINGS

[0021] Figure 1 is a flow chart of a deep learning-based textile color difference online detection method according to an embodiment of the present application; Figure 2 is a process schematic diagram of converting a fabric image from an RGB color space to a CIELab color space according to an embodiment of the present application; Figure 3 is a feature extraction process analysis schematic diagram of calculating a local structural disturbance component according to an embodiment of the present application; Figure 4 is a comprehensive dashboard schematic diagram of analyzing the light disturbance of the current image according to an embodiment of the present application; Figure 5is a visual diagram illustrating the feature map change process of the feature extractor in different network levels in the embodiment of the present application; Figure 6 is a dynamic monitoring curve diagram illustrating the change of the ratio of segmentation loss to domain loss in the training process in the embodiment of the present application; Figure 7 is a histogram diagram illustrating the numerical distribution of the dynamic adversarial gradient modulation factor in the entire training process in the embodiment of the present application; Figure 8 is a performance summary report diagram of the textile color difference detection model in the embodiment of the present application. DETAILED DESCRIPTION

[0022] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the present application.

[0023] The specific embodiments of the present application will be described in detail below with reference to the drawings.

[0024] An online textile color difference detection method based on deep learning embodiment: As shown in the figure, the online textile color difference detection method based on deep learning of the present application comprises: Figure 1 S1, acquiring fabric images through an industrial camera and converting the images from RGB format to CIELab format by using color space conversion technology to realize effective separation of brightness and chrominance information. S1, acquiring fabric images through an industrial camera and converting the images from RGB format to CIELab format by using color space conversion technology to realize effective separation of brightness and chrominance information.

[0025] In one embodiment, first, digital images of the fabric surface are acquired in real time by an industrial camera deployed on a high-speed textile production line . In order to effectively separate the brightness information from the chrominance information of the images and eliminate the nonlinear effects caused by different color space representations, color space conversion is performed on the acquired format images in this embodiment.

[0026] Specifically, the images are converted to color space, obtaining images . Exemplarily, the CIELab color space contains three channels: a brightness channel with a value range of representing brightness from black to white; a red-green channel Its range is usually in This represents the hue from green to red; and the yellow-blue channel. Its range is usually in , representing the chroma from blue to yellow.

[0027] like Figure 2 As shown, an image of fabric with uneven light and shadow due to wrinkles is decomposed into three independent channels: The channel clearly shows the changes in light and shadow caused by fabric folds, and this information is unrelated to color. Channel and The channel shows a uniform amount of noise, indicating that the fabric itself has a uniform color and there is no color difference.

[0028] S2. By acquiring multiple standard fabric sample images, calculate the mean and covariance of their global statistical features and local structural features, thereby establishing a reference benchmark characterizing an ideal lighting environment.

[0029] This step is used to establish a reference benchmark characterizing an ideal lighting environment, and is typically performed once when the system is first deployed, when the product is changed, or when a periodic calibration is performed.

[0030] Specifically, under the premise of ensuring that the lighting environment of the production line is in a standard and stable state, for example, all light sources are working properly and there is no external ambient light interference, data is collected. A standard color sample fabric image without any color difference defects. As a preferred embodiment, the... The value can be This is to ensure the stability of the statistics.

[0031] First, calculate a value containing the current frame image. A six-dimensional vector of global statistical features : ; in and These represent the mean and standard deviation of the pixel values ​​for the corresponding color channels, respectively. For example, Indicates the brightness channel The average brightness. Then, for this set of reference images, a series of statistical feature benchmark values ​​are calculated and stored. These benchmark values ​​together constitute the reference illumination state benchmark, specifically including: the reference mean vector of global statistical features. and its covariance matrix Reference values ​​for local structural features, including reference gradient energy. and reference Contrast .

[0032] Where the reference mean vector has: wherein represents the i-th six-dimensional vector of the i-th standard fabric swatch image; covariance matrix has: wherein represents the i-th six-dimensional vector of the i-th standard fabric swatch image, represents the aforementioned reference mean vector; reference gradient energy is the mean value of the gradient amplitude calculated from the i-th standard fabric swatch image ; reference contrast is the mean value of the contrast calculated from the i-th standard fabric swatch image .

[0033] S3, constructing a multi-dimensional characterization system containing global chroma deviation and local structure disturbance.

[0034] To fundamentally solve the problem of insufficient perception of continuous illumination changes in the prior art, this step will obtain a characterization system that can accurately and comprehensively quantify the deviation of the illumination state of the current frame image compared to the reference benchmark. This system not only focuses on global brightness and color temperature changes, but also focuses on local structural artifacts caused by fabric wrinkles, shadows, etc.

[0035] S3.1, using Mahalanobis distance algorithm to calculate the distance of the global statistical vector of the current image to the center of the reference state, obtaining a component that can robustly measure the deviation of the global illumination environment from the ideal state.

[0036] In order to more robustly measure the abnormality of the current state vector to the center of the reference state distribution, this embodiment uses Mahalanobis distance to calculate the global deviation component . Mahalanobis distance can consider the correlation between features and normalize the scale, which is more effective than traditional Euclidean distance in measuring the distance of a point to a distribution. The specific calculation formula is as follows: ; wherein represents the global statistical vector of the current frame image; represents the reference mean vector of the global statistical feature obtained in step S2; represents the inverse covariance matrix of the global statistical vector under the reference benchmark established in step S2; represents a very small positive number, for example, 1e-2, which is used to avoid the situation that the matrix is singular and cannot be inverted due to linear correlation of sample features. ​

[0037] From the above equation, when the global statistical vector differs from the reference mean , the value of also increases, reflecting that the global lighting environment deviates from the ideal state. The introduction of the inverse covariance matrix can achieve decorrelation and standardization of each feature dimension, so that can automatically weigh different statistical features, such as the variability of brightness and chrominance, thereby providing a more stable and more physically meaningful deviation measure than simple distance summation.

[0038] S3.2, by calculating the gradient energy of the brightness channel and the gray level co-occurrence matrix (GLCM) contrast features, to quantify the local lighting artifacts caused by sharp shadows, fabric wrinkles, etc.

[0039] In order to capture the local lighting artifacts caused by sharp shadows, fabric wrinkles, etc., which are difficult to detect by traditional global statistical methods, this step extracts local structural features from two dimensions of image gradient and texture.

[0040] First, the gradient energy feature of the brightness channel is calculated, which is: where and represent the mean and standard deviation of the gradient amplitude of the brightness channel , respectively; then the gray level co-occurrence matrix (GLCM) contrast feature is calculated, which is: ; where denotes the element in the normalized gray level co-occurrence matrix, and denotes the probability of the occurrence of a pair of pixels.

[0041] Gradient energy can quantify the intensity and density of edges in the image, while contrast reflects the clarity and depth of texture. The basis for its construction is that local shadows will produce strong gradient edges, while fabric wrinkles will change the contrast of local texture.

[0042] Next, the feature values of the current frame are compared with the reference benchmark values and established in step S2, and the local structural disturbance component is calculated by a weighted logarithmic function. The introduction of the logarithmic function is to smooth the difference value and enhance the sensitivity of the model to small disturbances.

[0043] ; where respectively, are used to balance the importance of gradient and texture features. As a preferred solution, both of them can be set as to give equal attention, or be adjusted according to the main disturbance type in actual production line; represents a logarithmic function.

[0044] When transient shadow appears in the image, the gradient amplitude will increase significantly, resulting in much larger than , so that increases. Similarly, when the fabric surface produces wrinkles due to shaking, the texture contrast will increase, also resulting in increases. This component is dedicated to quantifying those local uneven illumination problems that are not significant in global statistics, but have a fatal impact on the color difference detection results.

[0045] As shown in Figure 3 , where the left image is the original luminance channel image. The middle image represents the gradient amplitude image. The bright area in this image represents the area with high edge intensity in the image. The mean and standard deviation of this image are used to calculate the gradient energy feature . The right image analyzes the texture features of the image by calculating the gray level co-occurrence matrix (GLCM). The GLCM contrast reflects the sharpness of the texture.

[0046] S3.3, the calculated global deviation component and the local structural disturbance component are weighted and fused to generate the final continuous light deviation descriptor that can fully represent the current light disturbance state.

[0047] The global and local deviation components in the above two dimensions are weighted and fused to form the final continuous light deviation descriptor that can fully represent the light disturbance state .

[0048] ; where represents the fusion coefficient, whose value range is , used to adjust the attention focus on global light changes and local structural artifacts. In this embodiment, , the preferred range of is . When , it means that global and local disturbances are equally important. If the overall light of the production line environment is stable, but the fabric is prone to wrinkles, the value of may be appropriately increased, for example , to focus on the capture of local disturbances.

[0049] By the above steps, a fuzzy, continuous lighting variation problem can be converted into a description of the deviation from continuous lighting by a global deviation component The numerical problem of the evaluation provides a data basis for the subsequent steps.

[0050] As shown in Figure 4 , the upper left subgraph is the real-time input image to be detected. The upper right subgraph shows the final deviation descriptor is obtained by weighted fusion of the global deviation component and the local perturbation component . The lower left subgraph shows the distribution of the image brightness value. The mean and standard deviation of this distribution are one of the key inputs for calculating the global six-dimensional vector. The lower right subgraph shows the aggregation of the image chrominance value, and its statistical characteristics are also part of .

[0051] S4, introduce a closed-loop feedback mechanism that perceives the external lighting deviation and the internal training state of the model, so that the strength of the adversarial training can be dynamically and intelligently self-adapted according to real-time conditions.

[0052] After obtaining an accurate description of the lighting deviation, this embodiment introduces a closed-loop feedback to make the adversarial strength not only respond to external lighting changes, but also perceive the training state of the model internally, so as to achieve dynamic balance.

[0053] S4.1, based on the lighting deviation descriptor, a baseline value of the adversarial strength is calculated using the Sigmoid function, so that its strength is positively correlated with the degree of lighting deviation, and is activated only when it exceeds a threshold.

[0054] First, based on the obtained in step S3, a baseline value of the adversarial strength is calculated. The basis for its construction is that only when the lighting deviation exceeds a certain threshold, the adversarial training is activated, and its strength is positively correlated with the degree of deviation.

[0055] ; where represents a preset upper limit of the adversarial weight, for example , to prevent training divergence caused by too large adversarial loss; represents a scale coefficient, used to adjust the steepness of the Sigmoid function curve, to control the sensitivity of the weight change with ; represents the activation threshold. Only when the lighting deviation descriptor exceeds the threshold, the adversarial mechanism is significantly activated. This avoids excessive adversarial for harmless small fluctuations.

[0056] The logic of this formula is that when is much smaller than Time, Close to , the adversarial training is basically ineffective. When exceeds and continues to increase, it will grow smoothly and approach the upper limit , thus setting a benchmark for the adversarial intensity that is positively correlated with the severity of external light disturbance.

[0057] S4.2, by monitoring the loss function value of the field discriminator in real time, dynamically generating a feedback modulation factor for fine-tuning the adversarial intensity, to achieve dynamic balance of the generator and discriminator capabilities.

[0058] This step dynamically fine-tunes the adversarial intensity by monitoring the performance of the field discriminator , which takes its loss function value as an indicator. The construction basis is that the ideal state of adversarial training is that the discriminator cannot distinguish the source of the features, at which point its performance should be similar to random guessing, specifically: ; where represents the average loss value of the field discriminator in the last training window, used to obtain stable performance evaluation; represents the target loss value of the discriminator. For an ideal binary classifier, its loss should be close to the level of random guessing, i.e. ; represents the hyperbolic tangent function, which compresses the loss deviation to the interval, forming a bounded modulation signal; represents the feedback gain coefficient, which controls the sensitivity of feedback adjustment, and can be set to an empirical value such as .

[0059] When the discriminator performance is too strong (i.e. ), the function output is close to , resulting in being significantly smaller than , at which point the adversarial intensity is suppressed, giving the feature extractor more learning opportunities. Conversely, when the discriminator performance is too weak (i.e. ), the function output is close to , resulting in being significantly larger than , at which point the adversarial intensity is enhanced, increasing the training pressure on the discriminator, ultimately achieving dynamic balance of the generator and discriminator capabilities.

[0060] S4.3 Multiply the basic adversarial weights that reflect external environmental disturbances with the feedback modulation factor that reflects the internal state of the model to synthesize the dynamic gradient modulation factor that is finally applied to the adversarial loss.

[0061] Multiplying the base weights by the feedback modulation factor yields the final dynamic adversarial gradient modulation factor applied to the adversarial loss. ,have: ; Integrating through External environmental disturbances and their transmission The information reflected in the model's internal state makes the adversarial intensity no longer a preset value, but a dynamic variable that can be intelligently adjusted according to real-time conditions.

[0062] like Figure 5 As shown, the histogram is presented in the form of a graph. The distribution of weights throughout the training process shows that the weights are mainly concentrated in certain specific value ranges, reflecting the statistical characteristics of the lighting perturbations and model states encountered during training.

[0063] S5. The dynamic adjustment mechanism is integrated into the domain adversarial network framework. By modulating the gradient of the adversarial loss, the feature extractor is driven to learn the illumination invariant features, and finally, accurate color difference segmentation is achieved.

[0064] The dynamic adjustment mechanism of this embodiment is integrated into a standard domain adversarial network, such as... Within the framework, preferably, the network includes a ResNet feature extractor. An FPN color difference splitter head and an MLP domain discriminator .in: Feature extractor The network depth can be chosen from ResNet-18, ResNet-34, and ResNet-50. For online detection with high real-time requirements, it is advisable to start with a shallower ResNet-18 or ResNet-34, which offer a good balance between speed and performance. If the chromatic aberration features are complex, a deeper ResNet-50 can be used. The initial learning rate can be set between 1e-4 and 1e-3, and a StepLR learning rate decay strategy can be used to gradually reduce the learning rate during training.

[0065] Color difference splitter The pyramid level output channel number can be set to 128 or 256. Higher values will increase the capacity and computational complexity of the model, but may bring more refined segmentation results; for the binary classification segmentation task of color difference and background, the final output channel value can be set to 2, i.e. the probability of each pixel belonging to the background and the probability of belonging to the defect or 1, i.e. only output the probability of belonging to the defect.

[0066] Domain discriminator The network structure can be set to 2-3 hidden layers, and the number of neurons in each layer can be set to [256, 128] or [512, 256] and the like in a decreasing sequence; the activation function can use ReLU or LeakyReLU; at the same time, Dropout can also be added after the hidden layer of the MLP, and the ratio can be set between 0.3 and 0.5.

[0067] As shown in Figure 6 , the output feature maps after the input image passes through the different layers of the feature extractor are shown. As can be seen from the figure, as the network depth increases, the model gradually learns more abstract and higher-level semantic features from the initial pixel-level details. It is helpful to understand and debug the network and ensure that the model learns features that are effective for color difference recognition and insensitive to light.

[0068] In the training process, the total loss function is defined as: ; Wherein represents the color difference segmentation loss, for example, the cross-entropy loss, which is calculated by comparing the model segmentation output with the manually labeled true value, specifically: First, for an input image, the color difference segmentation head outputs a probability map equal to the original image. The value of each pixel point in the figure (ranging from 0 to 1) represents the probability that the pixel is a color difference defect, and then a binary image equal to the original image is manually pre-labeled. Among them, the pixel value of the color difference area is 1, and the pixel value of the normal background area is 0. Then the cross-entropy loss compares the model output probability and the manually labeled true value pixel by pixel. If the true value of a pixel is 1 and the model predicts a low probability, the loss will be large; on the contrary, if the model predicts a high probability, the loss will be small. The losses of all pixel points are added or averaged to obtain the final value; represents the domain discriminator loss, which is used to distinguish the features output by the feature extractor from which light domain they come from, specifically: The input of the discriminator is the feature map output by the feature extractor. Its task is a binary classification problem: to judge whether these features come from source domain images or target domain images. The binary cross-entropy loss is usually used for calculation. When training the feature extractor, the goal is to learn general features that are independent of illumination, so that the discriminator cannot distinguish their source. This is achieved by applying a negative dynamic factor to the term in the total loss function . When backpropagating, this negative sign reverses the gradient, driving the update parameters, and ultimately learning illumination-invariant features; The dynamic adversarial gradient modulation factor obtained in step S4 is denoted as

[0069] When updating the weights of the feature extractor by backpropagation, the gradient from propagates normally, while the gradient from is multiplied by a negative dynamic factor , thus driving to learn features that make unable to judge. The specific training process of the above domain adversarial network belongs to the prior art and will not be described here.

[0070] As shown in Figure 7 , the graph shows the change in the ratio of . This ratio can be regarded as an indicator of the balance between the model's segmentation task and the adversarial illumination change. The ideal training process is to achieve a dynamic balance between the two tasks.

[0071] After training, when in the online detection phase, only the trained feature extractor and the color difference segmentation head are used. For real-time acquisition of production line images, the model performs forward propagation, and the pixel-level color difference region segmentation map can be directly output, achieving stable and accurate online detection.

[0072] As shown in Figure 8 , first, the implementation process of the technical solution is briefly listed; then the related key hyperparameters set to achieve the technical solution are listed, such as the fusion coefficient, the upper limit of the adversarial weight, and the target loss, etc. Finally, the final training results are evaluated, including the final segmentation loss, the domain loss, and the dynamic adversarial gradient modulation factor value, and a conclusion is given.

Claims

1. A deep learning-based online color difference detection method for textiles, characterized in that, The method includes: training a domain adversarial network that includes a feature extractor, a color difference segmentation head, and a domain discriminator, wherein the training process uses a source domain image under standard illumination and a target domain image under variable illumination; The current target domain image is acquired, and its global statistical features and local structural features are calculated. The global statistical features and local structural features are compared with preset reference values ​​to obtain global deviation components and local deviation components. The two are fused to obtain a continuous illumination deviation descriptor. Calculate the basic adversarial weights, whose values ​​are positively correlated with the continuous illumination deviation descriptor; The feedback modulation factor is calculated, and its value is positively correlated with the difference between the discrimination loss value of the neighborhood discriminator and the preset target loss value. The basic adversarial weights are multiplied by the feedback modulation factor to obtain the dynamic adversarial gradient modulation factor; when the weights of the feature extractor are updated during backpropagation, the dynamic adversarial gradient modulation factor is applied to the loss gradient of the neighborhood discriminator.

2. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The global statistical features include: Convert the current target domain image to the CIELab color space and extract the mean and standard deviation of pixel values ​​for the three CIELab color channels; The local structural features include the gradient energy features of the brightness channel and the contrast features of the gray-level co-occurrence matrix.

3. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The method for obtaining the global deviation component is as follows: Calculate the Mahalanobis distance between the global statistical feature vector of the current target domain image and the reference mean vector of the reference benchmark value; The method for obtaining the local deviation component is as follows: The absolute value of the difference between the local structural feature value of the current target domain image and the corresponding reference feature value of the reference benchmark is logarithmically transformed, and the transformed result is weighted and summed.

4. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The calculation method for the basic adversarial weights is as follows: The difference between the continuous illumination deviation descriptor and the preset activation threshold is input into the Sigmoid function to obtain the basic adversarial weights.

5. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The method for calculating the feedback modulation factor is as follows: The difference between the discrimination loss value of the neighborhood discriminator and the preset target loss value is subjected to hyperbolic tangent transformation, and the feedback modulation factor is obtained by exponential operation on the transformed result.

6. The online color difference detection method for textiles based on deep learning according to claim 5, characterized in that, The preset target loss value is .

7. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The specific method for fusing continuous illumination deviation descriptors is as follows: The global deviation component and the local deviation component are weighted and summed, wherein the weight coefficient of the local deviation component ranges from 0.4 to 0.

6.

8. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The feature extractor adopts a ResNet network structure, the color difference segmentation head adopts a feature pyramid network structure, and the neighborhood discriminator adopts a multilayer perceptron structure.

9. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The method for establishing the reference benchmark value includes: Multiple images of defect-free fabrics under standard illumination were acquired, and the global statistical feature vector and local structural feature values ​​of each image were calculated. The mean vector and covariance matrix of the global statistical eigenvectors are used as global reference benchmarks; The mean value of the local structural feature values ​​is used as a local reference benchmark.

10. The online color difference detection method for textiles based on deep learning according to claim 1, characterized in that, The domain adversarial network includes minimizing the total loss function: The total loss function Defined as: ; in This represents the segmentation loss calculated based on the model's segmentation output and manually labeled ground truth. This represents the dynamic adversarial gradient modulation factor; This indicates the loss of the discriminator.

Citation Information

Patent Citations

  • Color firmness evaluation method and system

    CN118429346A

  • Improved Swin Transform-based generative adversarial network underwater image enhancement model

    CN118608437A

  • Fabric defect image denoising method based on improved generative adversarial network

    CN119048391A

  • Laparoscopic image smoke removal method based on generative adversarial network

    US20230377097A1

  • Image defogging method and system based on cyclic generative adversarial network

    WO2022267641A1