Method and system for detecting fluff state on surface of napped fabric based on machine vision
By using a generative adversarial network model with gradient penalty term in the detection of surface fluff state of wool fabrics for image enhancement, and combining multi-feature extraction and random forest modules, the problem of insufficient detection generalization ability and accuracy in the prior art is solved. Achieve more efficient and accurate detection of villi status.
Patent Information
- Application Number
- CN202411320151.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-23
AI Technical Summary
The existing machine vision-based fleece state detection method for surface fleece in the fleece fabric is insufficient due to insufficient training set number and focusing on abnormal state shapes.
Image enhancement is performed using a generative adversarial network model with zero-centered gradient penalty term, and a multi-feature extraction module with spatial feature extraction unit and frequency feature extraction unit is constructed, combining the random forest module and the adaptive genetic algorithm to adjust the hyperparameters. Improve the accuracy and generalization ability of detection.
Through the use of image enhancement and multi-feature extraction modules, the image quality and model training effect are improved, the accuracy and automation of villi status detection are improved, and the production quality and enterprise competitiveness are ensured.
Smart Images

Figure CN118840740B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a method and system for detecting the fluff state of a napped fabric surface based on machine vision. Background Art
[0002] Napped fabric is a kind of fabric that has been mechanically treated so that the fibers on the surface of the fabric are pulled out to form fluff. The fluff state of the surface of the napped fabric refers to the appearance state of the fibers on the surface of the fabric that has been treated with napping, usually including the density, direction, gloss and other characteristics of the fluff. The napping treatment refers to the formation of fluff on the surface of the fabric through mechanical action, thereby increasing its softness, warmth retention and aesthetics.
[0003] The state of the fluff on the surface of the napped fabric directly affects the quality and appearance of the fabric. Problems such as inconsistent direction of the fluff, wear, and pilling will lead to a decline in fabric performance and affect the consumer experience. In addition, timely detection of defects can help improve production quality, reduce the production of unqualified products, and ensure that products meet market standards. The detection of the fluff state on the surface of the napped fabric based on machine vision can quickly and accurately detect problems such as inconsistent direction of the fluff, pilling, and wear, ensuring stable fabric quality, improving production efficiency, and reducing manual detection errors.
[0004] However, the existing machine vision-based methods for detecting the fluff state on the surface of napped fabrics often limit the generalization ability of detection due to the insufficient number of training sets. Moreover, during the detection process, the focus is directly on the shape of the abnormal state, which makes it difficult to detect the fluff surface that may have many subtle abnormal states, further limiting the generalization ability and detection accuracy in the real-time detection process. Summary of the invention
[0005] In order to solve the technical problems that the prior art method for detecting the fluff state on the surface of napped fabrics based on machine vision often limits the generalization ability of detection due to the insufficient number of training sets, and in the detection process, the fluff surface that may have many subtle abnormal states is not easy to detect due to the direct focus on the shape of the abnormal state, which further limits the generalization ability and detection accuracy in the real-time detection process, the present invention provides a method and system for detecting the fluff state on the surface of napped fabrics based on machine vision.
[0006] The technical solution provided by the embodiment of the present invention is as follows:
[0007] First aspect
[0008] The embodiment of the present invention provides a method for detecting the state of fluff on the surface of a napped fabric based on machine vision, comprising:
[0009] S1: Collect multiple surface images of napped fabrics with various fabric abnormality labels;
[0010] S2: Image enhancement of surface images via a generative adversarial network model with a zero-centered gradient penalty in the discriminator;
[0011] S3: constructing a fabric abnormal state detection model, wherein the fabric abnormal state detection model has a multi-feature extraction module and a random forest module connected to each other, the multi-feature extraction module includes a spatial feature extraction unit and a frequency feature extraction unit, wherein the spatial feature extraction unit and the frequency feature extraction unit are used to extract spatial features and frequency features respectively;
[0012] S4: inputting the training set consisting of the enhanced surface image and the corresponding fabric abnormal state label into the fabric abnormal state detection model, training the fabric abnormal state detection model, and adjusting the hyperparameters of the random forest module by combining the adaptive genetic algorithm with the simulated annealing optimization algorithm and the Bayesian optimization algorithm until the termination condition is reached;
[0013] S5: Acquire a real-time video frame of the napped fabric to be detected;
[0014] S6: extracting a real-time surface image of the abnormal state of the fabric from the real-time video frame;
[0015] S7: Input the real-time surface image into the trained fabric abnormal state detection model, and output the fabric abnormal state label of the real-time surface image.
[0016] Second aspect
[0017] The embodiment of the present invention provides a system for detecting the state of nap on the surface of napped fabric based on machine vision, comprising:
[0018] processor;
[0019] A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method for detecting the fluff state on the surface of a napped fabric based on machine vision as described in the first aspect is implemented.
[0020] The third aspect
[0021] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for detecting the state of fluff on the surface of a napped fabric based on machine vision as described in the first aspect is implemented.
[0022] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0023] In the present invention, firstly, the surface image is enhanced by a generative adversarial network model with a zero-centered gradient penalty term, which reduces problems such as gradient explosion and mode collapse, enables the generator to generate high-quality images in a more stable environment, can more accurately capture and restore image details, thereby improving the final image quality and fidelity, and then completes the expansion of the training set to enhance the model training effect and generalization ability. After that, the traditional focusing method based on the shape of the abnormal state is replaced by a multi-feature extraction module with a spatial feature extraction unit and a frequency feature extraction unit, effectively extracting the local features and global features of the fabric to better capture the abnormal state, and then inputting it into the random forest module to learn the linear and nonlinear correlation between the features and the abnormal state, so that the random forest module can accurately identify the abnormal state based on the features, and can improve the detection accuracy of the abnormal state. In addition, in the training process of the model, the hyperparameters of the random forest module are adjusted in combination with an adaptive genetic algorithm with a simulated annealing optimization algorithm and a Bayesian optimization algorithm to avoid the formation of a local optimal solution, capture the nonlinear dependency between the features, ensure the feasibility and reliability of subsequent model detection, improve the automation and accuracy of fluff state detection, ensure production quality, and enhance corporate competitiveness. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 A schematic flow chart of a method for detecting the state of fluff on the surface of a napped fabric based on machine vision provided by an embodiment of the present invention;
[0026] Figure 2 A structural schematic diagram of a fabric abnormal state detection model provided by an embodiment of the present invention;
[0027] Figure 3 A schematic structural diagram of a system for detecting the fluff state on the surface of napped fabric based on machine vision provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The technical solution of the present invention is described below in conjunction with the accompanying drawings.
[0029] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.
[0030] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0031] Reference Manual Attached Figure 1 , showing a flow chart of a method for detecting the fluff state on the surface of a napped fabric based on machine vision provided by an embodiment of the present invention.
[0032] The embodiment of the present invention provides a method for detecting the state of fluff on the surface of a napped fabric based on machine vision. The method can be implemented by a device for detecting the state of fluff on the surface of a napped fabric based on machine vision. The device for detecting the state of fluff on the surface of a napped fabric based on machine vision can be a terminal or a server. The processing flow of the method for detecting the state of fluff on the surface of a napped fabric based on machine vision can include the following steps:
[0033] S1: Collect multiple surface images of napped fabrics with various fabric abnormality labels.
[0034] Among them, fabric abnormal state labels refer to labels or annotations used to mark and distinguish different types of abnormalities on the fabric surface during fabric surface detection. Each label corresponds to a specific abnormal situation. These labels can clearly identify specific problems on the fabric surface. Fabric abnormal state labels include fuzz wear, fuzz pilling, inconsistent fuzz direction, inconsistent fuzz gloss, and inconsistent fuzz density. These labels can help the machine vision system accurately judge and classify the abnormal state of the fabric so that these problems can be effectively identified and handled during the detection process.
[0035] S2: Image enhancement of surface images via a generative adversarial network model with a zero-centered gradient penalty in the discriminator.
[0036] It should be noted that by introducing a zero-centered gradient penalty term, the generative adversarial network significantly improves the stability of training and the generalization ability of the model, reduces problems such as gradient explosion and mode collapse, and enables the generator to generate high-quality images in a more stable environment. Especially in image enhancement tasks, it can more accurately capture and restore image details, thereby improving the final image quality and realism. This model not only ensures the diversity of generation, but also improves the realism of the generated images.
[0037] By adding a zero-centered gradient penalty term to the discriminator's objective function, the discriminator's performance in the entire data space is made more balanced, reducing excessive punishment for false data, thereby improving generalization ability, and making the discriminator's gradient distribution more balanced during the learning process, that is, keeping the center of the gradient approaching zero on all samples, reducing excessive gradient punishment for false data, and avoiding the discriminator from being too "strict" when facing false data, so that the generator can generate high-quality data in a more relaxed environment, thereby helping the discriminator to evaluate real data and false data more fairly. Such a discriminator not only performs well on training data, but also can better adapt to new and unseen data, that is, improves generalization ability.
[0038] In a possible implementation, the generative adversarial network model includes a generator and a discriminator, wherein the generator is used to output a generated image, and the discriminator is used to output the authenticity of the generated image.
[0039] S2 specifically includes:
[0040] S201: Determine the generator loss function and the discriminator loss function:
[0041]
[0042] in, represents the discriminator loss function, represents the adversarial loss function of the generative adversarial network model, represents the gradient penalty term, log represents the logarithmic function, A real image representing the discriminator output x is the probability of a real image, Generated image representing the discriminator output is the probability of a real image, Indicates that the calculation is based on the real data distribution The real image sampled from x The expected value of Represents the calculation from the noise distribution Random noise sampled in z The expected value of represents the penalty weight parameter, Represents the calculation from the interpolated data distribution Interpolated data sampled in The expected value of Indicates taking the L2 norm, represents the interpolated data gradient, Interpolated data representing the discriminator output is the probability of a real image, represents the interpolation ratio, Represents the generator loss function.
[0043] in, By making the gradient of the discriminator close to 0 at all input points, the size of the gradient is limited to prevent gradient explosion or gradient disappearance. The role of the gradient penalty is to make the discriminator perform more smoothly on different input data, especially when facing false data, so as not to be too "harsh", thereby improving the stability of the model.
[0044] S202: Input the surface image into the generative adversarial network model, and train the generative adversarial network model with the goal that the generator loss function value is less than a preset generator loss function value and the discriminator loss function value is less than a preset discriminator loss function value.
[0045] It should be noted that those skilled in the art can set the size of the preset generator loss function value and the preset discriminator loss function value according to actual needs, and the present invention is not limited here.
[0046] S203: Re-input the surface image into the trained generative adversarial network model, and output an enhanced surface image.
[0047] It should be noted that this generative adversarial network model effectively avoids the common gradient vanishing and mode collapse problems in traditional GAN by introducing gradient penalty terms, and improves the stability of the model. In addition, the use of interpolated images helps the generator to better learn the relationship between real data and generated data, making the generated images more realistic and diverse. This improvement enables the model to perform well in high-quality image generation and image enhancement tasks, while reducing instability during training and enhancing generalization capabilities. By adjusting the gradient of the discriminator, it ensures that the generator has better generalization capabilities when generating high-quality images, especially in image enhancement tasks, it can capture details more accurately, making the generated images more realistic and diverse, and improving the robustness and detection accuracy of the overall model.
[0048] Refer to the instruction manual Figure 2 , shows a structural schematic diagram of a fabric abnormal state detection model provided by an embodiment of the present invention.
[0049] S3: Build a fabric abnormal state detection model.
[0050] Among them, the fabric abnormal state detection model has an interconnected multi-feature extraction module and a random forest module, and the multi-feature extraction module includes a spatial feature extraction unit and a frequency feature extraction unit, wherein the spatial feature extraction unit and the frequency feature extraction unit are used to extract spatial features and frequency features respectively.
[0051] It should be noted that the combination of the spatial feature extraction unit and the frequency feature extraction unit can comprehensively capture the geometric shape, texture changes and periodic anomalies of the fabric surface, making the model more accurate in detecting anomalies such as fuzz wear, pilling, and gloss inconsistency. At the same time, the random forest module combines multi-feature information for classification, which improves the robustness and generalization ability of detection and adapts to complex actual production environments.
[0052] S4: The training set consisting of the enhanced surface image and the corresponding fabric abnormal state label is input into the fabric abnormal state detection model, the fabric abnormal state detection model is trained, and the hyperparameters of the random forest module are adjusted in combination with the adaptive genetic algorithm with simulated annealing optimization algorithm and Bayesian optimization algorithm until the termination condition is reached.
[0053] It should be noted that in genetic algorithms, although crossover and mutation operations can provide a certain degree of diversity and help the algorithm explore the global solution space, in some complex hyperparameter optimization tasks, genetic algorithms may converge to local optimal solutions prematurely, especially when the search space is large. In order to solve this problem, local search strategies or other optimization algorithms can be combined to jump out of the local optimal solution. Simulated annealing is a global optimization algorithm based on the physical annealing process, which can effectively avoid falling into the local optimal solution. By combining simulated annealing with an adaptive genetic algorithm, local optimal solutions can be explored locally during the execution of the genetic algorithm, thereby jumping out of the local optimal solution and improving the global search capability. In addition, although the genetic algorithm can perform global search, it is essentially based on heuristic search, and it is difficult to capture the complex nonlinear dependencies between hyperparameters. Introducing Bayesian optimization into the genetic algorithm and using its search capability based on a probability model can help the genetic algorithm better capture the nonlinear dependencies between hyperparameters.
[0054] In one possible implementation, the hyperparameters include the number of decision trees, the depth of the decision tree, the maximum number of features used to determine the number of features for a single split selection, the minimum number of split samples, and the minimum number of leaf node samples. The termination condition is that the number of iterations is greater than a preset number of iterations or the prediction accuracy is greater than a preset prediction accuracy.
[0055] It should be noted that by adjusting the number, depth, and number of features of decision trees, the model can flexibly adapt to different data complexities. At the same time, by setting the minimum number of split samples and the minimum number of leaf node samples, overfitting can be effectively prevented. Combined with reasonable termination conditions, the training efficiency is optimized to ensure that the model achieves optimal performance with high accuracy.
[0056] In a possible implementation, S4 specifically includes:
[0057] S401: extracting spatial features and frequency features of the enhanced surface image by using a spatial feature extraction unit and a frequency feature extraction unit respectively.
[0058] It should be noted that spatial features focus on local changes, geometry, and texture of the image, while frequency features can capture periodic changes or detail anomalies of the image as a whole. The combination of the two can capture anomalies in the image from multiple angles. By combining these two types of features, the classification effect of the model can be improved. For example, spatial features may reflect local damage to the fabric, while frequency features may reflect periodic texture changes on the fabric surface. The combination of the two helps to identify anomalies more comprehensively. Spatial features can capture obvious image changes, and frequency features can maintain sensitivity to image details in the presence of large noise. By fusing these two types of features, the robustness of the model under different types of abnormal conditions can be improved.
[0059] In a possible implementation, S401 specifically includes:
[0060] S401A: Preprocessing the enhanced surface image by non-subsampled contourlet transform algorithm:
[0061] in, represents the overall structural information of the enhanced surface image. j The low-frequency components of the layer, The first j The high-frequency components of the layer, H represents a non-subsampling low-pass filter, Indicates j Tier k The high-frequency components in each direction, Indicates that k A non-subsampled directional filter in each direction.
[0062] It should be noted that the image is first decomposed into low-frequency and high-frequency components through a non-subsampled pyramid to extract the global structure and edge details of the image, and then the high-frequency components are decomposed by a non-subsampled directional filter bank to extract details in different directions. Combining multi-scale and multi-directional image decomposition methods is not only suitable for enhancing the local structural information (spatial features) of the image, but also can effectively capture the details and texture information (frequency features) of the image.
[0063] S401B: By improving the gray level co-occurrence matrix, the pre-processed surface image is subjected to feature extraction based on gray level stretching, and spatial features are output, wherein the spatial features include contrast features, energy features, entropy features and inverse moment features:
[0064]
[0065] in, and Respectively represent the pixel points of the preprocessed surface image before and after grayscale stretching at the coordinates ( x , y ), and Respectively represent the maximum grayscale value and the minimum grayscale value in the preprocessed surface image, and Respectively represent the maximum grayscale value of the mapping target and the minimum grayscale value of the mapping target, Represents pixel value i and pixel value j At a given distance d and pixel angle θ The co-occurrence probability under Represents pixel value i and pixel value j The co-occurrence probability of , , and They represent contrast feature, energy feature, entropy feature and inverse moment feature respectively.
[0066] Optionally, and It can be set to 255 and 0. The pixel pair distance is generally set to 1, indicating directly adjacent pixels, and the angles are generally 0°, 45°, 90°, and 135°.
[0067] It should be noted that by stretching the grayscale levels, the details of the image are enhanced, making the texture features more obvious. Especially in the case of high grayscale dynamic range, it can better highlight the local detail changes of the fluff on the surface of the fabric and improve the accuracy and robustness of detection.
[0068] S401C: Extract frequency features based on logarithmic scale compression from the preprocessed surface image by improving Fourier transform, and output frequency features:
[0069]
[0070] in, Represents the preprocessed surface image in the frequency domain coordinates The frequency component at u and v represent the horizontal and vertical coordinates respectively, M and N Respectively represent the width and height of the preprocessed surface image, e represents a natural constant, π represents pi, Indicates taking the absolute value.
[0071] It should be noted that the spectrum is compressed on a logarithmic scale to enhance the detail contrast between low and high frequencies, avoid the details in the fuzz state spectrum being submerged due to the large value of the high-frequency component, and improve the visibility of subtle frequency features.
[0072] Specifically, the global structure and local details in the fabric image can be captured by extracting spatial features through the non-subsampled contourlet transform algorithm and the gray-level co-occurrence matrix. Meanwhile, the periodic changes and detail anomalies on the fabric surface can be better identified by extracting frequency features through the improved Fourier transform. The logarithmic scale compression of high-frequency and low-frequency details improves the sensitivity and accuracy of the detection model to the subtle features of complex images.
[0073] S402: Input the retained features into the random forest module and output the predicted fabric abnormal state label.
[0074] S403: Calculate the prediction accuracy of the random forest module. When the prediction accuracy is lower than the preset prediction accuracy, adjust the hyperparameters through the adaptive genetic algorithm, increase the number of iterations by 1, and return to step S402 until the termination condition is reached.
[0075] It should be noted that those skilled in the art can set the preset prediction accuracy rate according to actual needs, and the present invention is not limited thereto.
[0076] Specifically, combining the extraction of spatial features and frequency features can comprehensively capture fabric surface defects from two perspectives: local changes and overall periodic anomalies, improve detection accuracy, and input these features into random forests for classification, which helps to better identify different abnormal states. At the same time, an adaptive genetic algorithm is used to dynamically optimize hyperparameters to ensure that the model has stronger generalization ability and stable detection effects on different data sets.
[0077] In a possible implementation, the hyperparameters are adjusted by an adaptive genetic algorithm, specifically including:
[0078] S403A: Randomly generate an initial population with multiple chromosomes, where each chromosome is a hyperparameter combination.
[0079] S403B: Perform selection, crossover and mutation operations on each chromosome using the prediction accuracy as the fitness function to update the initial population.
[0080] S403C: Perform local search on each updated chromosome using simulated annealing optimization algorithm.
[0081] Among them, simulated annealing local search helps to perform fine-grained optimization on individuals close to the optimal solution, while the genetic algorithm continues to be responsible for the global search, thus achieving a balance between global search and local optimization.
[0082] In a possible implementation manner, S403C specifically includes:
[0083] S403C1: Generate new chromosomes from updated chromosomes at the initial annealing temperature.
[0084] S403C2: Screening of new chromosomes in combination with the Metropolis criteria:
[0085]
[0086] in, and Respectively represent k Second and k +1 chromosomes obtained after iteration, Indicates belonging to A random number in the interval, T k Indicates k The annealing temperature for the iteration, Indicates k The new chromosome generated by the iteration is and Respectively and The fitness value of .
[0087] S403C3: the number of annealing iterations is increased by 1, the initial annealing temperature is lowered, the screened new chromosome is used as the screened new chromosome set, and the process returns to step S403C2 until the lowered initial annealing temperature is lower than the preset annealing temperature or the number of annealing iterations is greater than the preset annealing iteration number.
[0088] It should be noted that those skilled in the art can set the preset annealing temperature and the preset number of annealing iterations according to actual needs, and the present invention does not limit this herein.
[0089] S403C4: Output the chromosomes obtained by the search.
[0090] It should be noted that the search range is controlled by gradually lowering the temperature to avoid falling into the local optimal solution too early. The Metropolis criterion allows for the acceptance of poor solutions with a certain probability, promoting diversity and thus improving the global search capability. At the same time, the annealing process improves the refinement and stability of the optimization by gradually converging, making the final selected hyperparameter combination closer to the global optimal, effectively improving the performance and adaptability of the model.
[0091] S403D: Establish a Gaussian process model between each hyperparameter combination and the fitness function, and combine the expected improvement EI and the Gaussian process model output to recommend the hyperparameter combination, i.e., the recommended chromosome.
[0092] In a possible implementation manner, S403D specifically includes:
[0093] S403D1: Building a Gaussian process model:
[0094]
[0095] in, represents the Gaussian process model, represents the mean function with value 0, Represents the first chromosome used to measure the generation based on the Gaussian process model Chromosome II The kernel function of the similarity between them, exp represents the exponential function, Indicates the calculation of Euclidean distance, l represents the length scale hyperparameter.
[0096] S403D2: Calculate the expected improvement of the chromosome generated based on the Gaussian process model relative to the current optimal chromosome:
[0097]
[0098] in, Generating chromosomes The expected improvement value, and Respectively represent the fitness values of the generated chromosome and the current most suitable chromosome, Indicates that the Gaussian process model generates chromosomes The standard deviation of the predictions during the process, and They represent the cumulative distribution function and probability density function of the standard normal distribution, Z Indicates that chromosomes are generated in and The standardized difference between .
[0099] S403D3: Output the generated chromosome with the largest expected improvement value as the recommended chromosome.
[0100] It should be noted that the Gaussian process model effectively captures the complex nonlinear relationship between hyperparameter combinations, and can predict the optimization trend of hyperparameters through a small number of samples without a large number of experiments. Combined with the expected improvement (EI) strategy, the hyperparameter combination with the greatest improvement potential is searched first, which reduces the search time while ensuring the accuracy and efficiency of the hyperparameter optimization process. Ultimately, the model performs better in complex optimization tasks.
[0101] S403E: Add the searched chromosomes and recommended chromosomes to the updated initial population, and re-perform the selection operation, crossover operation, and mutation operation.
[0102] S403F: The number of iterations is increased by 1, and the process returns to step S403B until the termination condition is reached.
[0103] Specifically, by combining global search (genetic algorithm) and local fine optimization (simulated annealing), a balance between global and local search is achieved to avoid falling into local optimality. The Gaussian process model accelerates the search process through expected improvement (EI), which can more efficiently capture the complex dependencies of hyperparameters, ultimately optimizing model performance and training efficiency, and ensuring that hyperparameter selection is more accurate and robust.
[0104] S5: Acquire a real-time video frame of the napped fabric to be detected.
[0105] S6: Extracting real-time surface images of abnormal fabric status from real-time video frames.
[0106] Specifically, the real-time surface image of the abnormal state of the fabric can be extracted from the real-time video frame by the YoLo algorithm. First, each frame of the input video image is normalized, the pixel value is scaled to [0,1], and the image is adjusted to the standard size required by the YOLO network. Secondly, the preprocessed image is input into the YOLO network. YOLO divides the image into multiple grids and generates multiple bounding boxes for each grid. Each bounding box contains the object position (center coordinates, width, height) and confidence. At this time, YOLO performs preliminary abnormal area detection on the fabric surface. Then, the bounding box output by the YOLO network is processed by the non-maximum suppression (NMS) algorithm to remove overlapping and repeated boxes and only retain the detection boxes with higher confidence. NMS can effectively filter out the optimal abnormal area and avoid the situation where multiple bounding boxes overlap to mark the same abnormality. Finally, the abnormal area in the image is extracted based on the filtered bounding box. According to the set confidence threshold, the detection box with a confidence higher than the threshold is output, and the fabric surface image with abnormal state is marked as the final output.
[0107] S7: Input the real-time surface image into the trained fabric abnormal state detection model, and output the fabric abnormal state label of the real-time surface image.
[0108] In actual application, by combining image enhancement, feature extraction and optimization algorithms, efficient and accurate detection of the fluff state on the surface of napped fabrics is achieved. The image enhancement step significantly improves the image quality, ensuring that subsequent anomaly detection is more accurate. Multi-feature extraction and random forest classification enable the model to capture complex anomalies on the fabric surface. The optimization algorithm improves the model's training efficiency and global search capabilities, ensures the robustness and generalization of detection, and achieves fast, automated real-time detection, greatly improving production efficiency and detection accuracy.
[0109] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0110] In the present invention, firstly, the surface image is enhanced by a generative adversarial network model with a zero-centered gradient penalty term, which reduces problems such as gradient explosion and mode collapse, enables the generator to generate high-quality images in a more stable environment, can more accurately capture and restore image details, thereby improving the final image quality and fidelity, and then completes the expansion of the training set to enhance the model training effect and generalization ability. After that, the traditional focusing method based on the shape of the abnormal state is replaced by a multi-feature extraction module with a spatial feature extraction unit and a frequency feature extraction unit, effectively extracting the local features and global features of the fabric to better capture the abnormal state, and then inputting it into the random forest module to learn the linear and nonlinear correlation between the features and the abnormal state, so that the random forest module can accurately identify the abnormal state based on the features, and can improve the detection accuracy of the abnormal state. In addition, in the training process of the model, the hyperparameters of the random forest module are adjusted in combination with an adaptive genetic algorithm with a simulated annealing optimization algorithm and a Bayesian optimization algorithm to avoid the formation of a local optimal solution, capture the nonlinear dependency between the features, ensure the feasibility and reliability of subsequent model detection, improve the automation and accuracy of fluff state detection, ensure production quality, and enhance corporate competitiveness.
[0111] Reference Manual Attached Figure 3 , showing a structural schematic diagram of a system for detecting the fluff state on the surface of a napped fabric based on machine vision provided by the present invention.
[0112] The present invention also provides a system 20 for detecting the state of fluff on the surface of a napped fabric based on machine vision, which is applied to the above-mentioned method for detecting the state of fluff on the surface of a napped fabric based on machine vision, and comprises:
[0113] Processor 201.
[0114] The memory 202 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 201, the method for detecting the fluff state on the surface of the napped fabric based on machine vision as in the method embodiment is implemented.
[0115] The machine vision-based brushed fabric surface fuzz state detection system 20 provided by the present invention can execute the above-mentioned machine vision-based brushed fabric surface fuzz state detection method and achieve the same or similar technical effects. To avoid repetition, the present invention will not go into details.
[0116] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0117] In the present invention, firstly, the surface image is enhanced by a generative adversarial network model with a zero-centered gradient penalty term, which reduces problems such as gradient explosion and mode collapse, enables the generator to generate high-quality images in a more stable environment, can more accurately capture and restore image details, thereby improving the final image quality and fidelity, and then completes the expansion of the training set to enhance the model training effect and generalization ability. After that, the traditional focusing method based on the shape of the abnormal state is replaced by a multi-feature extraction module with a spatial feature extraction unit and a frequency feature extraction unit, effectively extracting the local features and global features of the fabric to better capture the abnormal state, and then inputting it into the random forest module to learn the linear and nonlinear correlation between the features and the abnormal state, so that the random forest module can accurately identify the abnormal state based on the features, and can improve the detection accuracy of the abnormal state. In addition, in the training process of the model, the hyperparameters of the random forest module are adjusted in combination with an adaptive genetic algorithm with a simulated annealing optimization algorithm and a Bayesian optimization algorithm to avoid the formation of a local optimal solution, capture the nonlinear dependency between the features, ensure the feasibility and reliability of subsequent model detection, improve the automation and accuracy of fluff state detection, ensure production quality, and enhance corporate competitiveness.
[0118] It should be understood that the processor in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0119] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0120] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0121] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0122] In the present invention, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0123] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0124] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0125] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0126] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0127] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0128] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0129] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0130] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the method for detecting the state of fluff on the surface of a napped fabric based on machine vision as described in the method embodiment is implemented.
[0131] A computer-readable storage medium provided by the present invention can implement the steps and effects of the method for detecting the fluff state on the surface of a napped fabric based on machine vision in the above method embodiment. To avoid repetition, the present invention will not go into details.
[0132] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0133] In the present invention, firstly, the surface image is enhanced by a generative adversarial network model with a zero-centered gradient penalty term, which reduces problems such as gradient explosion and mode collapse, enables the generator to generate high-quality images in a more stable environment, can more accurately capture and restore image details, thereby improving the final image quality and fidelity, and then completes the expansion of the training set to enhance the model training effect and generalization ability. After that, the traditional focusing method based on the shape of the abnormal state is replaced by a multi-feature extraction module with a spatial feature extraction unit and a frequency feature extraction unit, effectively extracting the local features and global features of the fabric to better capture the abnormal state, and then inputting it into the random forest module to learn the linear and nonlinear correlation between the features and the abnormal state, so that the random forest module can accurately identify the abnormal state based on the features, and can improve the detection accuracy of the abnormal state. In addition, in the training process of the model, the hyperparameters of the random forest module are adjusted in combination with an adaptive genetic algorithm with a simulated annealing optimization algorithm and a Bayesian optimization algorithm to avoid the formation of a local optimal solution, capture the nonlinear dependency between the features, ensure the feasibility and reliability of subsequent model detection, improve the automation and accuracy of fluff state detection, ensure production quality, and enhance corporate competitiveness.
[0134] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
[0135] There are a few points to note:
[0136] (1) The drawings of the embodiments of the present invention only involve structures related to the embodiments of the present invention. Other structures may refer to conventional designs.
[0137] (2) For the sake of clarity, in the drawings used to describe the embodiments of the present invention, the thickness of layers or regions is exaggerated or reduced, that is, these drawings are not drawn according to the actual scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being "on" or "under" another element, the element may be "directly" "on" or "under" the other element or there may be intermediate elements.
[0138] (3) In the absence of conflict, the embodiments of the present invention and the features therein may be combined with each other to obtain new embodiments.
[0139] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. The protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for detecting the fluff state of a napped fabric surface based on machine vision, characterized in that: include: S1: Collect multiple surface images of napped fabrics with various fabric abnormality labels; S2: performing image enhancement on the surface image by a generative adversarial network model with a zero-centered gradient penalty term in the discriminator; S3: constructing a fabric abnormal state detection model, wherein the fabric abnormal state detection model has a multi-feature extraction module and a random forest module connected to each other, the multi-feature extraction module includes a spatial feature extraction unit and a frequency feature extraction unit, wherein the spatial feature extraction unit and the frequency feature extraction unit are used to extract spatial features and frequency features respectively; S4: inputting the training set consisting of the enhanced surface image and the corresponding fabric abnormal state label into the fabric abnormal state detection model, training the fabric abnormal state detection model, and adjusting the hyperparameters of the random forest module in combination with an adaptive genetic algorithm having a simulated annealing optimization algorithm and a Bayesian optimization algorithm until a termination condition is reached; S5: Acquire a real-time video frame of the napped fabric to be detected; S6: extracting a real-time surface image of the abnormal state of the fabric from the real-time video frame; S7: inputting the real-time surface image into the trained fabric abnormal state detection model, and outputting the fabric abnormal state label of the real-time surface image; The generative adversarial network model includes a generator and a discriminator, wherein the generator is used to output a generated image, and the discriminator is used to output the authenticity of the generated image; The S2 specifically includes: S201: Determine the generator loss function and the discriminator loss function: in, represents the discriminator loss function, represents the adversarial loss function of the generative adversarial network model, represents the gradient penalty term, log represents the logarithmic function, A real image representing the discriminator output x is the probability of a real image, Generated image representing the discriminator output is the probability of a real image, Indicates that the calculation is based on the real data distribution The real image sampled from x The expected value of Represents the calculation from the noise distribution Random noise sampled in z The expected value of represents the penalty weight parameter, Represents the calculation from the interpolated data distribution Interpolated data sampled in The expected value of Indicates taking the L2 norm, represents the interpolation data gradient, Interpolated data representing the discriminator output is the probability of a real image, represents the interpolation ratio, represents the generator loss function; S202: Inputting the surface image into the generative adversarial network model, training the generative adversarial network model with the goal that the generator loss function value is less than a preset generator loss function value and the discriminator loss function value is less than a preset discriminator loss function value; S203: re-inputting the surface image into the trained generative adversarial network model, and outputting an enhanced surface image; Wherein, the S4 specifically includes: S401: extracting spatial features and frequency features of the enhanced surface image by the spatial feature extraction unit and the frequency feature extraction unit respectively; S402: inputting the retained features into the random forest module, and outputting a predicted fabric abnormal state label; S403: Calculate the prediction accuracy of the random forest module. When the prediction accuracy is lower than the preset prediction accuracy, adjust the hyperparameters by the adaptive genetic algorithm, increase the number of iterations by 1, and return to step S402 until the termination condition is reached. Wherein, the S401 specifically includes: S401A: Preprocessing the enhanced surface image by non-subsampled contourlet transform algorithm: in, represents the overall structural information of the enhanced surface image. j The low-frequency components of the layer, The first j The high-frequency components of the layer, H represents a non-subsampling low-pass filter, Indicates j Tier k The high-frequency components in each direction, Indicates that k non-subsampled directional filters in directions; S401B: performing feature extraction based on grayscale level stretching on the preprocessed surface image by improving the grayscale co-occurrence matrix, and outputting the spatial features, wherein the spatial features include contrast features, energy features, entropy features, and inverse moment features: in, and Respectively represent the pixel points of the preprocessed surface image before and after grayscale stretching at the coordinates ( x , y ), and Respectively represent the maximum grayscale value and the minimum grayscale value in the preprocessed surface image, and Respectively represent the maximum grayscale value of the mapping target and the minimum grayscale value of the mapping target, Represents pixel value i and pixel value j At a given distance d and pixel angle θ The co-occurrence probability under Represents pixel value i and pixel value j The co-occurrence probability of , , and They represent contrast feature, energy feature, entropy feature and inverse moment feature respectively; S401C: extracting frequency features based on logarithmic scale compression from the preprocessed surface image by improving Fourier transform, and outputting the frequency features: in, Represents the preprocessed surface image in the frequency domain coordinates The frequency component at u and v represent the horizontal and vertical coordinates respectively, M and N Respectively represent the width and height of the preprocessed surface image, e represents a natural constant, π represents pi, Indicates taking the absolute value; The step of adjusting the hyperparameters by using the adaptive genetic algorithm specifically includes: S403A: Randomly generate an initial population with multiple chromosomes, where each chromosome is a hyperparameter combination; S403B: performing selection operation, crossover operation and mutation operation on each chromosome using the prediction accuracy as a fitness function to update the initial population; S403C: performing local search on each updated chromosome by using the simulated annealing optimization algorithm; S403D: Establishing a Gaussian process model between each hyperparameter combination and the fitness function, and combining the expected improved EI and the Gaussian process model to output a recommended hyperparameter combination, i.e., a recommended chromosome; S403E: adding the searched chromosome and the recommended chromosome to the updated initial population, and re-performing the selection operation, the crossover operation, and the mutation operation; S403F: The number of iterations is increased by 1, and the process returns to step S403B until the termination condition is reached; Wherein, the S403C specifically includes: S403C1: Generate new chromosomes from updated chromosomes at the initial annealing temperature; S403C2: Screening the new chromosomes in combination with the Metropolis criteria: in, and Respectively represent k Second and k +1 chromosomes obtained after iteration, Indicates belonging to A random number in the interval, T k Indicates k The annealing temperature of the iteration, Indicates k The new chromosome generated by the iteration is and Respectively and The fitness value of S403C3: the number of annealing iterations is increased by 1, the initial annealing temperature is lowered, the screened new chromosome is used as the screened new chromosome set, and the process returns to step S403C2 until the lowered initial annealing temperature is lower than the preset annealing temperature or the number of annealing iterations is greater than the preset annealing iteration number; S403C4: Output the chromosomes found; Wherein, the S403D specifically includes: S403D1: Establish the Gaussian process model: in, represents the Gaussian process model, represents the mean function with value 0, Represents the first chromosome used to measure the generation based on the Gaussian process model Chromosome II The kernel function of the similarity between them, exp represents the exponential function, Indicates the calculation of Euclidean distance, l represents the length scale hyperparameter; S403D2: Calculate the expected improvement value of the chromosome generated based on the Gaussian process model relative to the current optimal chromosome: in, Generating chromosomes The expected improvement value, and Respectively represent the fitness values of the generated chromosome and the current most suitable chromosome, Indicates that the Gaussian process model generates chromosomes The standard deviation of the predictions during the process, and They represent the cumulative distribution function and probability density function of the standard normal distribution, Z Indicates the generation of chromosomes in and The standardized difference between S403D3: Output the generated chromosome with the maximum expected improvement value as the recommended chromosome.
2. The method for detecting the fluff state of the napped fabric surface based on machine vision according to claim 1 is characterized in that: The hyperparameters include the number of decision trees, the depth of the decision tree, the maximum number of features used to determine the number of features for a single split selection, the minimum number of split samples and the minimum number of leaf node samples. The termination condition is that the number of iterations is greater than the preset number of iterations or the prediction accuracy is greater than the preset prediction accuracy.
3. A system for detecting the fluff state of napped fabric surface based on machine vision, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method for detecting the fluff state on the surface of a napped fabric based on machine vision as described in any one of claims 1 to 2 is implemented.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for detecting the fluff state on the surface of a napped fabric based on machine vision as described in any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Method and system for establishing neurological function prognosis prediction model of cerebral hemorrhage patient
CN117174313A