A Deep Learning-Based Online Color Difference Detection Method for Textiles

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.

CN120997215BActive Publication Date: 2026-01-30SHAANXI WANRONG IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511519513.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-01-30
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 model's discriminative performance feedback, 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 CN120997215B_ABST
    Figure CN120997215B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image processing, specifically to a deep learning-based online color difference detection method for textiles. First, defect-free samples are collected to establish a reference benchmark under ideal lighting. Then, by calculating the comprehensive deviation of the current image from the reference benchmark in terms of global chromaticity, brightness, and local texture, a continuous lighting deviation descriptor is obtained. Finally, in domain adversarial training, this descriptor is combined with discriminator performance feedback to obtain a dynamic adversarial gradient modulation factor, adaptively adjusting the adversarial training intensity to force the network to learn lighting-invariant features, ultimately achieving accurate and stable color difference segmentation under varying lighting conditions. This invention calculates the lighting deviation descriptor and combines it with discriminator performance feedback to dynamically modulate the intensity of domain adversarial training to learn lighting-invariant features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more specifically to an online color difference detection method for textiles based on deep learning. Background Technology

[0002] In industrial quality inspection fields such as textile production, the automatic detection of color difference defects on product surfaces using machine vision technology is a key step in ensuring product quality and production efficiency. These inspection systems typically deploy industrial cameras on the production line to acquire fabric images in real time, and then use image processing and deep learning algorithms to analyze the images to identify and locate areas of color difference.

[0003] However, on high-speed production lines, the actual lighting environment is extremely complex and variable. Fluctuations in ambient light, aging of the light source itself, and localized shadows caused by fabric shaking or wrinkles can all severely interfere with the color and texture information of images. These artifacts caused by uneven lighting exhibit characteristics in images that are very similar to real color difference defects, making traditional detection algorithms prone to misjudgment and missed detection, seriously affecting the stability and accuracy of the detection system.

[0004] To address the challenges posed by varying lighting conditions, existing technologies have begun to employ domain-adaptive methods such as Domain-Adversarial Neural Networks (DANNs). This approach introduces a domain discriminator that trains against the main task, aiming to teach the model features insensitive to lighting changes and thus improve its generalization ability under different lighting conditions. However, traditional domain-adversarial training methods typically use a fixed adversarial loss weight or a static scheduling strategy preset during training. This approach cannot adaptively adjust based on the severity of real-time lighting perturbations. When lighting changes are slight, a fixed adversarial strength may be too strong, impairing feature learning for color difference segmentation; conversely, when lighting changes are drastic, the adversarial strength may be insufficient to effectively eliminate domain differences, leading to training instability or poor convergence. Summary of the Invention

[0005] To address the problem that a fixed adversarial strength may impair feature learning in color difference segmentation tasks or lead to unstable training or poor convergence, this invention proposes a deep learning-based online color difference detection method for textiles. The method includes: training a domain adversarial network comprising 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; acquiring the current target domain image and calculating its global statistical features and local structural features; comparing the global statistical features and local structural features with preset reference values ​​to obtain global deviation components and local deviation components, and fusing them to obtain a continuous illumination deviation descriptor; calculating basic adversarial weights, whose values ​​are positively correlated with the continuous illumination deviation descriptor; calculating a feedback modulation factor, whose values ​​are positively correlated with the difference between the discriminant loss value of the domain discriminator and the preset target loss value; multiplying the basic adversarial weights by the feedback modulation factor to obtain a dynamic adversarial gradient modulation factor; and applying the dynamic adversarial gradient modulation factor to the loss gradient of the domain discriminator during backpropagation to update the weights of the feature extractor.

[0006] Compared to existing technologies that employ fixed adversarial weights and struggle to adapt to drastic changes in lighting conditions during online production, this invention calculates the deviation of the current image from standard lighting in real time and combines this with feedback from the model's discriminative performance to obtain a dynamic adversarial gradient modulation factor. This factor adaptively adjusts the strength of the adversarial force based on the severity of lighting changes. When lighting changes are significant, it strengthens neighborhood alignment to learn lighting-invariant features; when lighting changes are minor, it weakens the adversarial force to preserve more detailed features. This dynamic adjustment mechanism enables the model to better overcome interference from complex and variable lighting conditions in online detection environments, thereby significantly improving the robustness and accuracy of color difference detection.

[0007] Furthermore, the global statistical features include: converting the current target domain image to the CIELab color space and extracting 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 luminance channel and the contrast features of the gray-level co-occurrence matrix.

[0008] Compared to existing technologies that may only use single color or luminance information, this invention, by combining the global color distribution in the CIELab space with the local texture details of the luminance channel, can more comprehensively and accurately describe the changes in an image caused by variations in illumination. This multi-dimensional feature combination provides a richer and more reliable basis for subsequent calculations of illumination deviation, thereby improving the accuracy of dynamic adversarial weight calculation.

[0009] Furthermore, the method for obtaining the global deviation component is as follows: 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; the method for obtaining the local deviation component is as follows: performing a logarithmic transformation on 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 value, and then performing a weighted summation on the transformed result.

[0010] Compared to the simple Euclidean distance or absolute difference methods used in existing technologies, this invention employs Mahalanobis distance for global features, taking into account the correlation between features and making the distance metric unaffected by dimensions, thus possessing greater statistical significance. Furthermore, it uses logarithmic transformation for local features, effectively compressing the impact of abnormally large values ​​and making the deviation metric smoother and more stable. This calculation method can more accurately quantify the difference between the image and the reference baseline, thereby ensuring the generation of accurate illumination deviation descriptors.

[0011] Furthermore, the basic adversarial weights are calculated by inputting the difference between the continuous illumination deviation descriptor and the preset activation threshold into the Sigmoid function to obtain the basic adversarial weights.

[0012] Furthermore, 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 result after transformation is subjected to exponential operation to obtain the feedback modulation factor.

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

[0014] Furthermore, the fusion method of the continuous illumination deviation descriptor specifically involves: performing a weighted summation of the global deviation component and the local deviation component, wherein the weight coefficient of the local deviation component ranges from 0.4 to 0.6.

[0015] Furthermore, 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.

[0016] By employing mature network structures such as ResNet, Feature Pyramid Network (FPN), and Multilayer Perceptron (MLP), which have been proven to have superior performance in the field of computer vision, the method of this invention is provided with powerful feature extraction, multi-scale segmentation, and discrimination capabilities, ensuring the basic performance and reliability of the method, enabling it to efficiently learn deep features from images and accurately locate color difference regions.

[0017] Furthermore, the method for establishing the reference benchmark includes: acquiring multiple images of defect-free fabric under standard illumination, calculating the global statistical feature vector and local structural feature value of each image; using the mean vector and covariance matrix of the global statistical feature vector as the global reference benchmark; and using the mean of the local structural feature value as the local reference benchmark.

[0018] Furthermore, 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.

[0019] Compared with traditional methods where the weights of the adversarial loss term remain constant, the loss function of this invention can adaptively balance the two objectives of segmentation accuracy and domain confusion according to the change of the dynamic adversarial gradient modulation factor. This achieves an intelligent trade-off during training, thereby more efficiently guiding the model to learn robust features that can accurately segment color differences and are insensitive to changes in illumination.

[0020] The technical effects of this invention are as follows:

[0021] The core innovation of this invention lies in proposing a dynamic domain adversarial learning strategy for online color difference detection in textiles. It abandons the fixed adversarial weights of traditional methods and dynamically generates a modulation factor by calculating in real-time the deviation of the current image from a standard illumination benchmark in terms of global color and local structure, combined with discriminator performance feedback. This factor adaptively adjusts the intensity of the domain adversarial learning, enabling the model to learn illumination-invariant features more intelligently and efficiently when facing complex and variable illumination conditions on the production line, thereby significantly improving the stability and accuracy of color difference detection. Attached Figure Description

[0022] Figure 1 This is a schematic flowchart illustrating an online color difference detection method for textiles based on deep learning, according to an embodiment of the present invention.

[0023] Figure 2 This is a schematic diagram illustrating the process of converting a fabric image from the RGB color space to the CIELab color space in an embodiment of the present invention;

[0024] Figure 3 This is a schematic diagram illustrating the feature extraction process for calculating local structural disturbance components in an embodiment of the present invention;

[0025] Figure 4This is a schematic diagram of a comprehensive dashboard for analyzing illumination disturbances in the current image in an embodiment of the present invention;

[0026] Figure 5 This is a schematic diagram illustrating the visual process of feature map changes at different network layers in an embodiment of the present invention.

[0027] Figure 6 This is a schematic diagram illustrating the dynamic monitoring curve of the change in the ratio of segmentation loss to neighborhood loss during the training process in an embodiment of the present invention;

[0028] Figure 7 This is a schematic diagram illustrating the numerical distribution histogram of the dynamic adversarial gradient modulation factor throughout the training process in an embodiment of the present invention;

[0029] Figure 8 This is a schematic diagram illustrating the overall performance summary report of the textile color difference detection model in an embodiment of the present invention. Detailed Implementation

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

[0031] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0032] An example of an online color difference detection method for textiles based on deep learning:

[0033] like Figure 1 As shown, the online color difference detection method for textiles based on deep learning according to the present invention includes:

[0034] S1. Acquire fabric images using an industrial camera and process them from RGB format to CIELab format using color space conversion technology to achieve effective separation of luminance and chromaticity information.

[0035] In one embodiment, digital images of the fabric surface are first acquired in real time using industrial cameras deployed on a high-speed textile production line. To effectively separate the luminance and chrominance information of an image and eliminate the nonlinear effects caused by different color space representations, this embodiment performs the following steps on the acquired luminance and chrominance information: Formatted images Perform color space conversion.

[0036] Specifically, image Switch to Color space, to obtain the image For example, The space contains three channels: luminance channel. Its range is This represents brightness from black to white; red and green channels. 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.

[0037] 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.

[0038] 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.

[0039] 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.

[0040] 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.

[0041] First, calculate a value containing the current frame image. A six-dimensional vector of global statistical features :

[0042] ;

[0043] 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 .

[0044] Where the reference mean vector have: ,in Indicates the first A six-dimensional vector of a standard color sample fabric image; covariance matrix. have: ,in Indicates the first A six-dimensional vector of a standard color sample fabric image. Represents the reference mean vector; reference gradient energy. That is Gradient amplitude calculated from a standard color sample fabric image The mean; reference Contrast That is A standard color sample fabric image through Calculated contrast The mean.

[0045] S3. Construct a multi-dimensional representation system that includes global chromaticity deviation and local structural perturbation.

[0046] To fundamentally address the problem of insufficient perception of continuous illumination changes in existing technologies, this step will acquire a characterization system capable of accurately and comprehensively quantifying the deviation of the current frame's illumination state from a reference baseline. This system will not only focus on global brightness and color temperature changes, but also on local structural artifacts caused by fabric wrinkles, shadows, and other factors.

[0047] S3.1. Using the Mahalanobis distance algorithm, the distance from the current image's global statistical vector to the reference state center is calculated to obtain the component that can robustly measure the deviation of the global lighting environment from the ideal state.

[0048] To more robustly measure the current state vector To determine the degree of anomaly towards the center of the reference state distribution, this embodiment uses Mahalanobis distance to calculate the global deviation component. Mahalanobis distance takes into account the correlation between features and normalizes the scale, making it more effective than traditional Euclidean distance in measuring the distance from a point to a distribution. The specific calculation formula is as follows:

[0049] ;

[0050] in Represents the global statistical vector of the current frame image; This represents the reference mean vector of the global statistical features obtained in step S2; This represents the inverse covariance matrix of the global statistical vectors under the reference standard established in step S2; This represents a very small positive number, such as 1e-2, used to avoid situations where the matrix is ​​singular and cannot be inverted due to linear correlation of sample features.

[0051] From the above formula, it can be seen that when the global statistical vector Compared with the reference mean When the difference increases, The value of also increases accordingly, reflecting that the global lighting environment deviates from the ideal state. An inverse covariance matrix is ​​introduced. It can achieve decorrelation and standardization of each feature dimension, making It can automatically weigh the variability of different statistical characteristics, such as brightness and chromaticity, thus providing a more stable and physically meaningful deviation measure than simple distance summation.

[0052] S3.2. Quantify localized lighting artifacts caused by sharp shadows, fabric wrinkles, etc. by calculating the gradient energy of the luminance channel and the contrast characteristics of the gray-level co-occurrence matrix (GLCM).

[0053] In order to capture 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: image gradient and texture.

[0054] First, calculate the luminance channel. gradient energy characteristics ,have: ,in These represent the brightness channels respectively. The mean and standard deviation of the gradient magnitudes; then calculate the gray-level co-occurrence matrix ( Contrast characteristics ,have: ;in The elements in the normalized gray-level co-occurrence matrix represent pixel pairs. The probability of occurrence.

[0055] Gradient energy can quantify the intensity and density of edges in an image, while Contrast reflects the clarity of the texture and the depth of the grooves. It is based on the fact that local shadows produce strong gradient edges, while fabric wrinkles change the contrast of local textures.

[0056] Next, the feature values ​​of the current frame are compared with the reference values ​​established in step S2. and The comparisons were made, and the local structural disturbance components were calculated using a weighted logarithmic function. The logarithmic function is introduced to smooth out discrepancies and enhance the model's sensitivity to small perturbations.

[0057] ;

[0058] in These represent preset weighting coefficients used to balance the importance of gradient and texture features. As a preferred approach, both can be set to [value missing]. To give equal attention, or to adjust according to the main types of disturbances in the actual production line; Represents a logarithmic function.

[0059] When a transient shadow appears in an image, the gradient magnitude increases significantly, leading to... Much larger Thus Increase. Similarly, when the fabric surface wrinkles due to shaking, the texture contrast increases. It will increase, which will also lead to Increase. This component is specifically designed to quantify localized illumination unevenness issues that are statistically insignificant but have a fatal impact on color difference detection results.

[0060] like Figure 3 As shown, the left image is the original luminance channel image. The middle image represents the gradient magnitude image. The bright areas in this image represent regions with high edge intensity. The mean and standard deviation of this image are used to calculate the gradient energy features. The right image analyzes texture features by calculating the Gray-Level Co-occurrence Matrix (GLCM). GLCM contrast. It reflects the clarity of the texture.

[0061] S3.3. The calculated global deviation component and local structural disturbance component are weighted and fused to generate the final continuous illumination deviation descriptor that can comprehensively characterize the current illumination disturbance state.

[0062] By weighting and fusing the deviation components in both the global and local dimensions, a final continuous illumination deviation descriptor that can comprehensively characterize the illumination perturbation state is formed. .

[0063] ;

[0064] in This represents the fusion coefficient, and its range is... This is used to adjust the focus on global illumination changes and local structure artifacts. In this embodiment, The preferred range is .when Pick This indicates that both global and local disturbances are equally important. If the overall lighting in the production line environment is stable, but the fabric is prone to wrinkling, the intensity can be appropriately increased. Values, for example This focuses on capturing local disturbances.

[0065] The above steps can transform a fuzzy, continuous illumination variation problem into one involving continuous illumination deviation descriptors. The numerical problems of the calculation and evaluation provide a data foundation for subsequent steps.

[0066] like Figure 4 As shown, the top left sub-image is the real-time input image to be detected. The top right sub-image shows the final deviation descriptor. It is composed of global deviation components and local disturbance components The image is obtained through weighted fusion. The lower left subplot shows the distribution of image brightness values. The mean and standard deviation of this distribution are key inputs for calculating the global six-dimensional vector. The lower right subplot shows the aggregation of image chroma values, whose statistical characteristics are also crucial for constructing the global six-dimensional vector. Part of it.

[0067] S4. A closed-loop feedback mechanism is introduced to perceive external illumination deviation and the model's internal training state, enabling the intensity of adversarial training to be dynamically and intelligently adaptively adjusted according to real-time conditions.

[0068] After obtaining an accurate description of the illumination deviation, this embodiment introduces closed-loop feedback, so that the adversarial strength not only responds to changes in external illumination, but also senses the training state inside the model, thereby achieving dynamic balance.

[0069] S4.1 Based on the illumination deviation descriptor, a baseline value for adversarial strength is calculated using the Sigmoid function, making its strength positively correlated with the degree of illumination deviation, and activating only when the threshold is exceeded.

[0070] First, based on the results obtained in step S3 Calculate a baseline value for the strength of resistance. Its design is based on the principle that adversarial training is only activated when the illumination deviation exceeds a certain threshold, and its intensity is positively correlated with the degree of deviation.

[0071] ;

[0072] in This represents the preset upper limit of the adversarial weight, for example... This is used to prevent excessive losses in combat from causing training to diverge. This represents the scaling factor, used to adjust the steepness of the Sigmoid function curve and control the weight distribution. Sensitivity to change; This represents the activation threshold. Only when the illumination deviates from the descriptor... The adversarial mechanism is only significantly activated when this threshold is exceeded. This avoids overreacting to harmless, minor fluctuations.

[0073] The logic of this formula is that when much smaller hour, close to Combat training is basically ineffective. Exceed And as it continues to increase, It will grow smoothly and approach its upper limit. This establishes a benchmark for the strength of resistance that is positively correlated with the severity of external light disturbances.

[0074] S4.2 By monitoring the loss function value of the domain discriminator in real time, a feedback modulation factor is dynamically generated to fine-tune the adversarial strength, so as to achieve a dynamic balance between the capabilities of the generator and the discriminator.

[0075] This step involves real-time monitoring of its loss function value. Domain discriminator for indicators The performance of the discriminator is used to dynamically fine-tune the adversarial intensity. Its construction is based on the premise that the ideal state of adversarial training is a discriminator... Unable to determine the source of the features, its behavior should resemble random guessing, specifically:

[0076] ;

[0077] in This represents the average loss value of the domain discriminator within the most recent training window, used to obtain a stable performance evaluation; This 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. ; Representing the hyperbolic tangent function, it compresses the loss bias to... The interval forms a bounded modulation signal; This represents the feedback gain coefficient, which controls the sensitivity of the feedback adjustment. It can be set to an empirical value, such as... .

[0078] When the discriminator performance is too strong (i.e. )hour, The function output is close to ,lead to Significantly smaller than At this point, suppressing the adversarial strength gives the feature extractor more learning opportunities. Conversely, when the discriminator's performance is too weak (i.e., ... )hour, The function output is close to ,lead to Significantly greater than This will increase the intensity of the adversarial process and increase the training pressure on the discriminator, ultimately achieving a dynamic balance between the capabilities of the generator and the discriminator.

[0079] 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.

[0080] Multiplying the base weights by the feedback modulation factor yields the final dynamic adversarial gradient modulation factor applied to the adversarial loss. ,have: ;

[0081] 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.

[0082] 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.

[0083] 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.

[0084] 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:

[0085] 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.

[0086] Color difference splitter The number of output channels for the pyramid level can be set to 128 or 256. Higher values ​​will increase the model's capacity and computational cost, but may result in finer segmentation. For binary classification tasks involving color difference and background, the final output channel value can be set to 2, which represents the probability that each pixel belongs to the background and the probability that it belongs to a defect, or 1, which means only the probability of belonging to a defect is output.

[0087] 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 a decreasing sequence such as [256, 128] or [512, 256]. The activation function can be ReLU or LeakyReLU. Dropout can also be added after the hidden layers of the MLP, and the ratio can be set between 0.3 and 0.5.

[0088] like Figure 6 The figure shows the output feature maps of the input image after passing through different layers of the feature extractor. As can be seen from the figure, with the increase in network layers, the model gradually learns more abstract and higher-level semantic features from the initial pixel-level details. This helps in understanding and debugging the network, ensuring that the model learns features that are effective for color difference recognition and insensitive to lighting conditions.

[0089] During training, the total loss function Defined as:

[0090] ;

[0091] in The color difference segmentation loss, such as cross-entropy loss, is calculated by comparing the model's segmentation output with the manually labeled ground truth. Specifically:

[0092] First, for an input image, the color difference segmentation head outputs a probability map of the same size as the original image. The value of each pixel in the map (ranging from 0 to 1) represents the probability that the pixel represents a color difference defect. Then, a pre-labeled binary image of the same size as the original image is manually annotated. Pixels in the color difference region have a value of 1, while pixels in the normal background region have a value of 0. Next, the cross-entropy loss compares the model's output probability with the manually labeled ground truth value pixel by pixel. If a pixel's ground truth value is 1, but the model predicts a low probability, the loss will be large; conversely, if the model predicts a high probability, the loss will be small. The losses of all pixels are summed or averaged to obtain the final result. value;

[0093] This represents the loss of the neighborhood discriminator, used to discriminate feature extractors. The output characteristics are determined by the type of illumination domain from which it originates, specifically:

[0094] The discriminator takes as input the feature map output by the feature extractor. Its task is a binary classification problem: determining whether these features come from the source domain image or the target domain image. The binary cross-entropy loss is typically used for calculation. The goal during feature extraction training is to learn general features independent of illumination, making them indistinguishable to the discriminator. This is achieved by adjusting the loss function... Apply a negative dynamic factor to the term. This is achieved by reversing the gradient during backpropagation, driving parameter updates, and ultimately learning the illumination invariance feature.

[0095] This represents the dynamic adversarial gradient modulation factor obtained in step S4.

[0096] Update the feature extractor during backpropagation. When weighting, from The gradient propagates normally, while the gradient from The gradient will be multiplied by a negative dynamic factor. Thus driving Learning generates Unidentifiable features unrelated to lighting conditions. The specific training process of the aforementioned domain adversarial networks is well-known technology in this field and will not be elaborated upon here.

[0097] like Figure 7 As shown, the graph illustrates The ratio changes. This ratio can be seen as an indicator of the balance between the model's two objectives: segmentation and adversarial lighting changes. Ideally, the training process should allow the two tasks to reach a dynamic equilibrium.

[0098] After training, during the online detection phase, only the trained feature extractor is used. and color difference splitter For real-time acquired production line images, the model performs forward propagation and can directly output pixel-level color difference region segmentation maps, achieving stable and accurate online detection.

[0099] like Figure 8 As shown, the implementation process of the technical solution is first briefly outlined; then, the key hyperparameters set for implementing the solution are listed, such as the fusion coefficient, the upper limit of the adversarial weights, and the target loss. Finally, the final training results are evaluated, including the final segmentation loss, neighborhood loss, and dynamic adversarial gradient modulation factor values, and conclusions are given.

Claims

1. A deep learning-based online detection method for textile color difference, characterized in that, The method comprises: training a domain adversarial network comprising a feature extractor, a color difference segmentation head and a domain discriminator, wherein the training process uses source domain images under standard illumination and target domain images under variable illumination; Obtain the current target domain image, and calculate its global statistical features and local structure features;Compare the global statistical features and local structure features with the preset reference benchmark values to obtain global deviation components and local deviation components, specifically: 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 to obtain the global deviation component;Logarithmically transform 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 weightedly sum the transformed results to obtain the local deviation component;Fuse the global deviation component and the local deviation component to obtain a continuous illumination deviation descriptor, specifically: weightedly sum 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; Computing a base adversarial weight: inputting a difference between the continuous illumination deviation descriptor and a preset activation threshold into a Sigmoid function to obtain the base adversarial weight (Wbase) , a value of which is positively correlated with the continuous illumination deviation descriptor; The feedback modulation factor is calculated by performing a hyperbolic tangent transformation on the difference between the discrimination loss value of the domain discriminator and a preset target loss value, and performing an exponential operation on the transformed result , and the value of the feedback modulation factor is positively correlated with the difference between the discrimination loss value of the domain discriminator and the preset target loss value. multiplying the base adversarial weight with a feedback modulation factor to obtain a dynamic adversarial gradient modulation factor (f) , specifically: ; when updating the weight of the feature extractor in the backward propagation, the dynamic adversarial gradient modulation factor is applied to the loss gradient of the domain discriminator, and the total loss function is defined as: ​ ; wherein denotes a segmentation loss calculated based on the model segmentation output and the manually labeled true value; denotes the dynamic adversarial gradient modulation factor; denotes a discriminator loss.

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

3. The online textile color difference detection method based on deep learning according to claim 1, characterized in that, The preset target loss value is .

4. The online textile color difference detection method 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 domain discriminator adopts a multi-layer perceptron structure.

5. The online textile color difference detection method based on deep learning according to claim 1, characterized in that, The reference benchmark value comprises: Collect multiple defect-free fabric images under standard illumination, and calculate the global statistical feature vector and local structure feature value of each image; The mean vector and covariance matrix of the global statistical feature vector are used as the global reference benchmark; The mean of the local structure feature value is used as the local reference benchmark.

Citation Information

Patent Citations

  • Color firmness evaluation method and system

    CN118429346A

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

    CN119048391A