Cloth defect detection method based on deep learning
By constructing an improved RT-DETR object detection network model, combining the feature extraction of Folk-Planck equations and the hypergraph feature fusion module, the accuracy and speed of cloth defect detection are solved, and efficient detection of complex texture patterns is achieved.
Patent Information
- Application Number
- CN202510555020.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the accuracy of cloth defect detection is low, the speed is slow, and the algorithm calculation complexity is high, making it difficult to effectively detect defects in complex texture modes.
Using a deep learning-based method, an improved RT-DETR object detection network model is constructed, combined with the Fokker-Planck equation feature extraction model and the hypergraph feature fusion module, the detection accuracy and speed are improved through image preprocessing and labeling data set expansion.
It improves the accuracy and performance of cloth defect detection in complex backgrounds, reduces the error detection rate, and achieves efficient defect detection.
Smart Images

Figure BDA0005383177590000021 
Figure BDA0005383177590000031 
Figure BDA0005383177590000032
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloth detection and deep learning technology, and in particular to a cloth defect detection method based on deep learning. Background Art
[0002] Cloth defect detection plays a vital role in the textile production process. Manual detection methods were used in the early days of cloth defect detection. This method is not only time-consuming but also prone to false detection and missed detection. Undetected cloth defects not only affect product functions but also increase production costs. With the development of deep learning, many solutions have been provided to solve this problem, effectively improving the accuracy and speed of cloth defect detection.
[0003] However, with the development of productivity and the improvement of the country's manufacturing level, the shape of cloth has become more complex, the types of defects have increased, and the requirements for cloth defect detection have become higher and higher. The cloth detection in the existing technology has low accuracy, slow detection speed, and high computational complexity of the algorithm, and it is in urgent need of improvement. Summary of the Invention
[0004] In view of the shortcomings of the prior art described above, the purpose of the present invention is to provide a cloth defect detection method based on deep learning, which solves the problems of low accuracy of cloth detection, slow detection speed and high computational complexity of the algorithm.
[0005] To achieve the above objectives and other related objectives, the present invention provides a cloth defect detection method based on deep learning, comprising:
[0006] S1. Use industrial cameras to collect defect images generated during the cloth production process on the established cloth inspection platform to obtain a cloth original image defect dataset;
[0007] S2. performing image preprocessing on the cloth original image defect dataset to expand the cloth original image defect dataset;
[0008] S3, annotating the defect locations and categories of the expanded cloth original image defect dataset, and dividing the annotated cloth original image defect dataset into an image training set, an image test set, and an image verification set according to a preset ratio;
[0009] S4. Using the improved RT-DETR target detection network model as the network model for cloth defect detection, inputting the image training set, image test set, and image verification set into the target detection network model for training, testing, and verification, and obtaining the weight of the trained cloth defect detection network model;
[0010] S5. Input the trained cloth defect detection network model weights into an online defect detection device. If defects are detected in the cloth input into the defect detection device, the defect detection device will mark the detected defect data with the defect position and category labels of step S3, and save the defect data.
[0011] In one embodiment of the present invention, the image preprocessing of the cloth original image defect dataset in step S2 includes:
[0012] The torch framework is used to expand the cloth original image defect dataset by randomly rotating, randomly scaling, and randomly adjusting the brightness and contrast.
[0013] In one embodiment of the present invention, the step S3 of labeling the defect locations and categories of the expanded cloth original image defect dataset includes:
[0014] The Labelimg image annotation tool is used to select different defects on the surface of the expanded cloth original image defect dataset using rectangular boxes and annotate the labels of the defect names.
[0015] In one embodiment of the present invention, the improved RT-DETR target detection network model in step S4 includes a backbone network and a neck network; wherein, a feature extraction model based on the Fokker-Planck equation is constructed in the backbone network, and a hypergraph feature fusion module is constructed in the neck network.
[0016] In one embodiment of the present invention, constructing a feature extraction model based on the Fokker-Planck equation in the backbone network includes:
[0017] Assuming that the two-dimensional particle probability distribution in the potential energy field is expressed as p(x,y,t), that is, the probability density of point (x,y) at time t, the Fokker-Planck equation is expressed as follows:
[0018]
[0019] Among them, A x (x,y) and A y (x,y) are the drift coefficients in the x and y directions respectively, B x (x,y) and B y (x,y) are the diffusion coefficients in the x and y directions, respectively;
[0020] The two-dimensional particle probability distribution in the potential energy field is applied to the image. The two-dimensional particle probability distribution P(x, y, t) is expanded along the image channel dimension, and the generated multi-channel image feature is represented as: P(x, y, c, t);
[0021] Among them, x and y are the spatial positions of image pixels, c is the number of channels, and t is time. Based on the two-dimensional Fokker-Planck equation, the common assumption of Neumann boundary conditions is introduced, that is, D is the entire image range, n is the normal vector of the boundary. If the Neumann boundary condition is satisfied on all boundaries, that is, there is no net flow on the boundary, then any directional drift in the system will be restricted, which is equivalent to setting the drift coefficient to 0. At the same time, in the image information, the image features can be regarded as isotropic, that is, the diffusion coefficients in the x and y directions are the same. x (x,y)=B y (x, y), denoted as λ, so the two-dimensional Fokker-Planck equation is expressed as formula (1-2):
[0022]
[0023] Where λ is the diffusion coefficient;
[0024] The general solution of formula (1-2) is solved by applying Fourier transform to both sides of the equation. The two-dimensional Fourier transform and inverse transform are shown in formulas (1-3) and (1-4).
[0025]
[0026] The time term and space term of the two-dimensional Fokker-Planck equation are Fourier transformed separately, as shown in formula (1-5),
[0027]
[0028] Formula (1-5) is a first-order ordinary differential equation for time t, and the solution is shown in formula (1-6).
[0029]
[0030] Among them, the initial conditions The general solution in the spatial domain is obtained by Fourier transform, as shown in formulas (1-7) and (1-8).
[0031]
[0032] Among them, P t =P(x,y,c,t), P0=P(x,y,c,t)| t=0 , λ is the diffusion coefficient,
[0033] Assuming input features Among them, R is the image, B is the number of batch samples, H and W are the height and width of the feature respectively, C is the number of channels, all samples are accumulated at each spatial position and then divided by the number of samples B to get the frequency embedding representation The time t is set to a fixed value of 1 to speed up the convergence. The calculation process is shown in formula (1-9).
[0034]
[0035] Under the common assumption of Neumann boundary conditions, the Fourier transform Using discrete cosine transform DCT2D instead, the discrete form of the solution of the two-dimensional Fokker-Planck equation is shown in formula (1-10).
[0036]
[0037] In one embodiment of the present invention, constructing and designing a hypergraph feature fusion module in the neck network includes:
[0038] Designing a core-edge hypergraph computing module, including: constructing a hypergraph mapping relationship, performing a core-edge partition in the hypergraph mapping relationship, and constructing a core-edge hypergraph computing module based on the core-edge partition;
[0039] According to the core-edge hypergraph computing module, a hypergraph feature fusion network is constructed.
[0040] In one embodiment of the present invention, constructing a hypergraph mapping relationship includes:
[0041] Hypergraph Represented by its vertex set v and hyperedge set ε, the set around each feature point is constructed using the distance threshold and recorded as ∈-ball. ∈-ball is the jump edge contained in the radius with the central feature point as the center and the specific distance threshold as the radius. The overall set of jump edges can be defined as Among them, the adjacent vertex set of the specified vertex is used It means, ||xy|| d is the distance function, ∫ is a specific distance threshold, Vertex u belongs to vertex set v.
[0042] In one embodiment of the present invention, performing core-edge partitioning in the hypergraph mapping relationship includes:
[0043] Use distance threshold to dynamically divide core-edge nodes. The formulas are (1-11) and (1-12).
[0044]
[0045] Among them, ∫ is a specific distance threshold, core_mask i Indicates whether node i is a core node. A value of 1 indicates that it is a core node, and a value of 0 indicates that it is an edge node. M is the core-edge mask matrix.
[0046] In one embodiment of the present invention, constructing a core-edge hypergraph calculation module according to the core-edge partitioning includes:
[0047] Calculate the Euclidean distance relationship between features and nodes to obtain the distance matrix D;
[0048] Constructing a hypergraph matrix according to the distance matrix D, and enhancing feature information through hypergraph convolution and core-edge mask matrix;
[0049] The original features and enhanced feature information are additively fused to reconstruct the original dimensions.
[0050] In one embodiment of the present invention, constructing a hypergraph feature fusion network according to the core-edge hypergraph computing module includes:
[0051] Assume that the input features of the hypergraph feature fusion network are Among them, X Z is the current feature layer, BZ is the input batch size, CZ is the number of channels corresponding to the Zth feature layer, HZ and WZ are the height and width of the image corresponding to the Zth feature layer. For an input image I, the corresponding feature obtained by the backbone is L I ={L1, L2, L3, L4, L5}, the output feature of the core-edge hypergraph calculation module is recorded as L H , the output features of the graph feature fusion network are: N3, N4, N5.
[0052] As described above, the cloth defect detection method based on deep learning of the present invention has the following beneficial effects:
[0053] (1) The cloth defect detection method based on deep learning of the present invention improves the target detection network to solve the problems of low target defect detection accuracy and high false detection rate faced by the original network under complex backgrounds. A feature extraction model based on the Focke-Planck equation is constructed in the backbone network. Frequency domain information is introduced through the physical model to enhance the network's sensitivity to high-frequency region features with frequency features, effectively improving the modeling ability of complex texture patterns and defect details.
[0054] (2) The deep learning-based cloth defect detection method of the present invention designs a hypergraph feature fusion module in the neck network, uses the hyperedge and vertex relationship to reconstruct the intrinsic relationship between features, and integrates the hypergraph theory with the core-edge idea to strengthen the differential expression of defects and backgrounds, deeply explores the cross-scale contextual semantic relationship, and further improves the network's detection performance for cloth defects in complex backgrounds.
[0055] (3) The cloth defect detection method based on deep learning of the present invention utilizes neural network technology to detect whether the cloth has defects with high detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A workflow diagram of a cloth defect detection method based on deep learning provided in an embodiment of the present application.
[0057] Figure 2 A feature extraction model diagram based on the Fokker-Planck equation for a cloth defect detection method based on deep learning provided in an embodiment of the present application.
[0058] Figure 3 A schematic diagram of the network structure of a hypergraph feature fusion module of a cloth defect detection method based on deep learning provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.
[0060] This section will describe in detail the specific embodiments of the present invention. The preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the accompanying drawings is to supplement the description of the text part of the specification with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it should not be understood as a limitation on the scope of protection of the present invention.
[0061] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", etc., indicating positions or positional relationships, are based on the positions or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the devices or components referred to must have a specific position, be constructed and operated in a specific position. Therefore, they should not be understood as limiting the present invention. The terms "installed", "connected", and "connected" should be understood in a broad sense. For example, they can be fixed connections, detachable connections, or integral connections; they can be mechanical connections or electrical connections; they can be direct connections, indirect connections through an intermediate medium, or internal connections between two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0062] It should be noted that the illustrations provided in the following embodiments are merely schematic illustrations of the basic concept of the present invention. Therefore, the illustrations only show components related to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the type, quantity, and proportion of each component may be changed arbitrarily, and the component layout may also be more complex.
[0063] See also Figure 1 , Figure 1 This is a workflow diagram of a cloth defect detection method based on deep learning provided in an embodiment of the present application. The present invention provides a cloth defect detection method based on deep learning, comprising:
[0064] Step S1: On the constructed cloth inspection platform, an industrial camera is used to collect defect images generated during the cloth production process to obtain a cloth original image defect dataset.
[0065] Step S2: performing image preprocessing on the cloth original image defect dataset to expand the cloth original image defect dataset.
[0066] Step S3: annotate the expanded cloth original image defect dataset with defect locations and categories, and divide the annotated cloth original image defect dataset into an image training set, an image test set, and an image verification set according to a preset ratio.
[0067] Step S4: Use the improved RT-DETR target detection network model as the network model for cloth defect detection, input the image training set, image test set and image verification set into the target detection network model for training, testing and verification, and obtain the trained cloth defect detection network model weight.
[0068] Step S5: input the trained cloth defect detection network model weights into an online defect detection device. If defects are detected in the cloth input into the defect detection device, the defect detection device will mark the detected defect data with the defect position and category labels of step S3, and save the defect data.
[0069] In one embodiment of the present invention, the image preprocessing of the cloth original image defect dataset in step S2 includes: using the torch framework to randomly rotate, randomly scale, randomly adjust the brightness, and expand the contrast of the cloth original image defect dataset in sequence.
[0070] In one embodiment of the present invention, the defect location and category labeling of the expanded cloth original image defect dataset in step S3 includes: using the Labelimg image labeling tool to select different defects existing on the surface of the expanded cloth original image defect dataset with rectangular boxes, and marking labels with the defect names.
[0071] Specifically, the Labelimg image annotation tool is used to annotate the defect locations and categories of the expanded cloth original image defect dataset, and the dataset and annotation files are divided into image training set, image test set, and image verification set in a ratio of 0.75:0.15:0.1.
[0072] In one embodiment of the present invention, the improved RT-DETR target detection network model in step S4 includes a backbone network and a neck network; wherein, a feature extraction model based on the Fokker-Planck equation is constructed in the backbone network, and a hypergraph feature fusion module is constructed in the neck network.
[0073] In step S5, the defect data is saved, and defective products can be found by comparing the product number with the defect detection data.
[0074] See also Figure 2 , Figure 2 A diagram of a feature extraction model based on the Fokker-Planck equation for a cloth defect detection method based on deep learning provided in an embodiment of the present application. The feature extraction model based on the Fokker-Planck equation constructed in the backbone network is specifically as follows:
[0075] To extract image features in the frequency domain, we designed an attention model that follows the physical principle of particle diffusion to achieve cross-domain capture and information transmission of image information. Assume that the two-dimensional probability distribution of particles in a potential energy field is represented by p(x, y, t), which is the probability density of a point (x, y) at time t. The Fokker-Planck equation in classical physics is expressed as Equation (1-23).
[0076]
[0077] Among them, A x (x,y) and A y (x,y) are the drift coefficients in the x and y directions respectively, B x (x,y) and B y (x,y) are the diffusion coefficients in the x and y directions respectively.
[0078] Specifically, the two-dimensional particle probability distribution P(x, y, t) is extended along the image channel dimension, and the generated multi-channel image feature is represented as: P(x, y, c, t), where x and y represent the spatial position of the image pixel, c is the number of channels, and t represents time. Due to the limitation of image information features, the semantic information of the image target will not propagate beyond the image boundary. Therefore, based on the two-dimensional Fokker-Planck equation, the common assumption of Neumann boundary conditions is introduced, that is, D is the entire image range, n is the normal vector of the boundary, if the Neumann boundary condition is satisfied on all boundaries, that is, there is no net flow on the boundary, then any directional drift in the system will be limited, which is equivalent to setting the drift coefficient to 0. At the same time, in the image information, the image features can be regarded as isotropic, that is, the diffusion coefficients in the x and y directions are the same B x (x,y)=B y (x, y), denoted as λ. Therefore, the two-dimensional Fokker-Planck equation is expressed as formula (1-24).
[0079]
[0080] where λ is the diffusion coefficient.
[0081] The general solution of Equation (1-24) can be obtained by applying Fourier transform (FT, expressed as ) to solve. The two-dimensional Fourier transform and inverse transform are shown in equations (1-25) and (1-26).
[0082]
[0083] The time term and space term of the two-dimensional Fokker-Planck equation are Fourier transformed separately, as shown in Equation (1-27).
[0084]
[0085] Equation (1-27) is a first-order ordinary differential equation for time t, and the solution is shown in Equation (1-28).
[0086]
[0087] Among them, the initial conditions Finally, the general solution in the spatial domain is obtained through Fourier transform, as shown in Equations (1-29) and (1-30).
[0088]
[0089] Among them, P t =P(x,y,c,t), P0=P(x,y,c,t)| t=0 , λ is the diffusion coefficient.
[0090] In order to extract global features and enhance the robustness of the model, the spatial information of all samples is averaged, hoping to capture the consistency across samples and reduce the impact of individual sample noise on the model. Assuming the input feature Where R represents the image, B is the number of batch samples, H and W are the height and width of the feature, and C is the number of channels. First, all samples are accumulated at each spatial position and then divided by the number of samples B to obtain the frequency embedding representation Time t is set to a fixed value of 1 to speed up the convergence. The calculation process is shown in formula (1-31).
[0091]
[0092] And because under the common assumption of Neumann boundary conditions, the Fourier transform Discrete Cosine Transform DCT 2D , DCT 2D Instead, the discrete form of the solution of the two-dimensional Fokker-Planck equation is shown in (1-32).
[0093]
[0094] According to the above content, the feature extraction model based on the Fokker-Planck equation is designed as follows Figure 2 As shown in the figure, the feature extraction model based on the Fokker-Planck equation consists of five parts, stage1 to stage5, where stage1 consists of three 3×3 convolutions and 3×3 Maxpool layers, and stage2 to stage5 have the same structure. The expression is as follows, assuming that the input feature is represented by X F ∈R B×C×H×W , where B represents the batch size, C represents the number of channels, and H and W represent the height and width of the image. The feature extraction model based on the Fokker-Planck equation is expressed as shown in Equations (1-33) and (1-34).
[0095] Q=c3(c3(X F ))+c1(M2(X F )) (1-33)
[0096] Y F =c1(c1(Q))+1DCT 2D (DCT 2D (Q)·w) (1-34)
[0097] Among them, c1 is a 1×1 convolution, c3 is a 3×3 convolution, M2 is a maximum pooling layer with a step size of 2, and X F is the input tensor, Y F is the output tensor.
[0098] See also Figure 3 , Figure 3 A schematic diagram of the network structure of a hypergraph feature fusion module for a deep learning-based cloth defect detection method provided in an embodiment of the present application. The hypergraph feature fusion module constructed and designed in the neck network includes:
[0099] Designing a core-edge hypergraph computing module, including: constructing a hypergraph mapping relationship, performing a core-edge partition in the hypergraph mapping relationship, and constructing a core-edge hypergraph computing module based on the core-edge partition;
[0100] According to the core-edge hypergraph computing module, a hypergraph feature fusion network is constructed.
[0101] (1) Core-Edge Hypergraph Computing Module
[0102] A) Construct hypergraph mapping relationship. It is usually represented by its vertex set v and hyperedge set ε. In order to simulate the feature relationship of the semantic space, a distance threshold is used to construct a set around each feature point, which is recorded as ∈-ball. ∈-ball is represented as the jump edges contained in the radius with the central feature point as the center and a specific distance threshold as the radius. The overall set of jump edges can be defined as The adjacent vertex set of the specified vertex is used Indicates. ||xy|| d is the distance function. ∫ is a specific distance threshold, Indicates that vertex u belongs to vertex set v.
[0103] B) Core-Edge Division
[0104] In the feature space of a hypergraph, there is typically a core-edge node structure. Core nodes are connected to the rest of the hyperedges, while a group of edge nodes are closely connected to the core but have fewer internal connections. The core-edge partitioning method can effectively structurally partition the complex relationships between features. Therefore, core nodes and corresponding hyperedges are considered to represent the main features of the image. Therefore, a distance threshold is used to dynamically partition the core-edge nodes. The specific calculation is shown in Equations (1-35) and (1-36).
[0105]
[0106] Among them, ∫ is a specific distance threshold, core_mask iIndicates whether node i is a core node (a value of 1 indicates a core node, and a value of 0 indicates an edge node). M is the core-edge mask matrix. Feature information transfer is weighted based on the core-edge node division. Core nodes are given greater weight during feature aggregation, ensuring they have a greater influence on the final output.
[0107] C) Building a core-edge hypergraph computing module
[0108] The Core-Periphery Hypergraph Computational Module (CPHM) uses spatial hypergraph convolution with residual connections to learn vertex features. First, the Euclidean distances between features and nodes are calculated to obtain the distance matrix D. Next, a hypergraph matrix is constructed, and feature information is enhanced through hypergraph convolution and a core-edge mask matrix. Finally, the original features are additively fused with the enhanced features to reconstruct the original dimensions. Hyperedge generation is dynamically adjusted using a distance threshold, allowing node interactions to be adaptively adjusted based on data characteristics. This flexibility enables the module to adapt to diverse data distributions. Through its unique hypergraph structure and core-edge strategy, the Core-Periphery Hypergraph Computational Module assigns different weights to feature information transmission based on core and edge nodes, giving core nodes greater influence and edge nodes relatively less. This design effectively enhances information capture and feature representation when processing data with complex internal connections. The specific calculations are shown in Equations (1-37) to (1-42).
[0109] D=cdist(X,X)(1-37)
[0110]
[0111]
[0112] X final =X′+X (1-42)
[0113] in, represents the node feature matrix, cdist(·) represents the distance function, D represents the distance matrix, and HG represents the hypergraph matrix, which represents the connection relationship between nodes. If the distance between node i and node j is less than the distance threshold, the connection between them is 1, otherwise it is 0. H is the adjacency matrix of the hypergraph node, which represents the information transfer from hyperedge to node. Tis the transpose of the node adjacency matrix, representing the information transfer from the node to the hyperedge, ⊙ is element-wise multiplication, E represents the message transfer from the node to the hyperedge, the feature of each hyperedge is the weighted average of its adjacent features, and the weight parameter is adjusted by the core-edge mask, X′ represents the message transfer from the hyperedge to the node, and the hyperedge feature is aggregated through the adjacency matrix and the core-edge mask to update the new node feature X′. final This represents features processed by the core-edge hypergraph computation module, fusing the original features with the enhanced features through skip connections. Features are aggregated from nodes to hyperedges, then back to nodes through hyperedges. Finally, the updated node features are residually connected to the original features. This enhances information propagation and improves feature expression, enabling the model to capture more complex and abstract patterns and relationships.
[0114] (2) Hypergraph Feature Fusion Network
[0115] Assume that the input features of the hypergraph feature fusion network model are where X Z Represents the current feature layer, BZ is the input batch size, CZ is the number of channels corresponding to the Zth feature layer, HZ and WZ are the height and width of the image corresponding to the Zth feature layer. For an input image I, the corresponding feature obtained by the backbone is L I ={L 1, L 2, L 3, L 4, L5}, the output feature after the core-edge hypergraph computing module is recorded as L H , the output features of the hypergraph feature fusion network model are recorded as: N 3, N 4, N5.
[0116] First, send L5 to the AIFI module to generate Y5, and then {L 1, L 2, L 3, L 4, Y5} performs splicing operation to construct mixed feature X mixed , the mixed feature X mixed And the correlation matrix H is fed into the core-edge hypergraph computation module CPHM to generate high-order perceptual features L H , and finally use the interactive network to convert X hyper The feature fusion interaction with the backbone network is used to obtain the final N3, N4, and N5. The specific calculation is shown in formula (1-43). The hypergraph feature fusion network model is as follows: Figure 3 As shown, F stands for Fusion module.
[0117]
[0118] Where φ(·) represents the interaction network. High-order perceptual features L H The Q3 and Q4 features are generated through upsampling and downsampling, and then fused with the backbone network features L3, L4, and L5 respectively through the Fusion module. Finally, a top-down feature fusion operation is performed to generate features N3, N4, and N5. The interactive network is shown in Equations (1-44) to (1-46).
[0119] N3=F(U(L H ),L3)(1-44)
[0120] N4=F(D(N3),F(L H ,L4)) (1-45)
[0121] N5=F(D(N4),F(D(L H ),L5)) (1-46)
[0122] Among them, U represents upsampling, D represents downsampling, and F represents the Fusion module.
[0123] Similar to the principle of the cloth defect detection method based on deep learning of the present invention, the present invention also provides a cloth defect detection system based on deep learning, comprising:
[0124] The acquisition module is used to use an industrial camera to collect defect images generated during the cloth production process on the constructed cloth inspection platform to obtain a dataset of original cloth image defects;
[0125] An image preprocessing module, configured to perform image preprocessing on the cloth original image defect dataset to expand the cloth original image defect dataset;
[0126] The labeling module is used to label the defect locations and categories of the expanded cloth original image defect dataset, and divide the labeled cloth original image defect dataset into an image training set, an image test set, and an image verification set according to a preset ratio;
[0127] A training module is used to use the improved RT-DETR target detection network model as the network model for cloth defect detection, input the image training set, image test set and image verification set into the target detection network model for training, testing and verification, and obtain the weight of the trained cloth defect detection network model;
[0128] The defect detection module is used to input the trained cloth defect detection network model weights into an online defect detection device. If a defect is detected in the cloth input into the defect detection device, the defect detection device will mark the detected defect data with the defect position and category label of step S3, and save the defect data.
[0129] In summary, the cloth defect detection method based on deep learning of the present invention improves the target detection network to address the problems of low target defect detection accuracy and high false detection rate faced by the original network under complex backgrounds. A feature extraction model based on the Focke-Planck equation is constructed in the backbone network, and frequency domain information is introduced through the physical model. The frequency characteristics are used to enhance the network's sensitivity to high-frequency area features, thereby effectively improving the modeling ability of complex texture patterns and defect details.
[0130] The technical principles of the present invention have been described above with reference to specific embodiments. These descriptions are intended solely to illustrate the principles of the present invention and are not to be construed in any way as limiting the scope of protection of the present invention. Based on the explanations herein, those skilled in the art will be able to devise other specific embodiments of the present invention without inventive effort, and such equivalent variations or substitutions are intended to be encompassed within the scope of the claims of this application.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A cloth defect detection method based on deep learning, characterized in that: include: S1. Use industrial cameras to collect defect images generated during the cloth production process on the established cloth inspection platform to obtain a cloth original image defect dataset; S2. performing image preprocessing on the cloth original image defect dataset to expand the cloth original image defect dataset; S3, annotating the defect locations and categories of the expanded cloth original image defect dataset, and dividing the annotated cloth original image defect dataset into an image training set, an image test set, and an image verification set according to a preset ratio; S4. Using the improved RT-DETR target detection network model as the network model for cloth defect detection, inputting the image training set, image test set, and image verification set into the target detection network model for training, testing, and verification, and obtaining the weight of the trained cloth defect detection network model; S5. Input the trained cloth defect detection network model weights into an online defect detection device. If defects are detected in the cloth input into the defect detection device, the defect detection device will mark the detected defect data with the defect position and category labels of step S3, and save the defect data.
2. The cloth defect detection method based on deep learning according to claim 1, characterized in that: The image preprocessing of the cloth original image defect dataset in step S2 includes: The torch framework is used to expand the cloth original image defect dataset by randomly rotating, randomly scaling, and randomly adjusting the brightness and contrast.
3. The cloth defect detection method based on deep learning according to claim 1, characterized in that: The step S3 of labeling the defect locations and categories of the expanded cloth original image defect dataset includes: The Labelimg image annotation tool is used to select different defects on the surface of the expanded cloth original image defect dataset using rectangular boxes and annotate the labels of the defect names.
4. The cloth defect detection method based on deep learning according to claim 1, characterized in that: The improved RT-DETR target detection network model in step S4 includes a backbone network and a neck network; wherein, a feature extraction model based on the Fokker-Planck equation is constructed in the backbone network, and a hypergraph feature fusion module is constructed in the neck network.
5. The cloth defect detection method based on deep learning according to claim 4, characterized in that: Constructing a feature extraction model based on the Fokker-Planck equation in the backbone network includes: Assuming that the two-dimensional particle probability distribution in the potential energy field is expressed as p(x,y,t), that is, the probability density of point (x,y) at time t, the Fokker-Planck equation is expressed as follows: Among them, A x (x,y) and A y (x,y) are the drift coefficients in the x and y directions respectively, B x (x,y) and B y (x,y) are the diffusion coefficients in the x and y directions, respectively; The two-dimensional particle probability distribution in the potential energy field is applied to the image. The two-dimensional particle probability distribution P(x, y, t) is expanded along the image channel dimension, and the generated multi-channel image feature is represented as: P(x, y, c, t); Among them, x and y are the spatial positions of image pixels, c is the number of channels, and t is time. Based on the two-dimensional Fokker-Planck equation, the common assumption of Neumann boundary conditions is introduced, that is, D is the entire image range, n is the normal vector of the boundary. If the Neumann boundary condition is satisfied on all boundaries, that is, there is no net flow on the boundary, then any directional drift in the system will be restricted, which is equivalent to setting the drift coefficient to 0. At the same time, in the image information, the image features can be regarded as isotropic, that is, the diffusion coefficients in the x and y directions are the same. x (x,y)=B y (x, y), denoted as λ, so the two-dimensional Fokker-Planck equation is expressed as formula (1-2): Where λ is the diffusion coefficient; The general solution of formula (1-2) is solved by applying Fourier transform to both sides of the equation. The two-dimensional Fourier transform and inverse transform are shown in formulas (1-3) and (1-4). The time term and space term of the two-dimensional Fokker-Planck equation are Fourier transformed separately, as shown in formula (1-5), Formula (1-5) is a first-order ordinary differential equation for time t, and the solution is shown in formula (1-6). Among them, the initial conditions The general solution in the spatial domain is obtained by Fourier transform, as shown in formulas (1-7) and (1-8). Among them, P t =P(x,y,c,t), P0=P(x,y,c,t)| t=0 , λ is the diffusion coefficient, Assuming input features Among them, R is the image, B is the number of batch samples, H and W are the height and width of the feature respectively, C is the number of channels, all samples are accumulated at each spatial position and then divided by the number of samples B to get the frequency embedding representation The time t is set to a fixed value of 1 to speed up the convergence. The calculation process is shown in formula (1-9). Under the common assumption of Neumann boundary conditions, the Fourier transform Discrete Cosine Transform DCT 2D Instead, the discrete form of the solution of the two-dimensional Fokker-Planck equation is shown in formula (1-10), 6. The cloth defect detection method based on deep learning according to claim 5, characterized in that: The hypergraph feature fusion module constructed and designed in the neck network includes: Designing a core-edge hypergraph computing module, including: constructing a hypergraph mapping relationship, performing a core-edge partition in the hypergraph mapping relationship, and constructing a core-edge hypergraph computing module based on the core-edge partition; According to the core-edge hypergraph computing module, a hypergraph feature fusion network is constructed.
7. The cloth defect detection method based on deep learning according to claim 6, characterized in that: The constructing of the hypergraph mapping relationship includes: Hypergraph Represented by its vertex set v and hyperedge set ε, the set around each feature point is constructed using the distance threshold and recorded as ∈-ball. ∈-ball is the jump edge contained in the radius with the central feature point as the center and the specific distance threshold as the radius. The overall set of jump edges can be defined as Among them, the adjacent vertex set of the specified vertex is used It means, ||xy|| d is the distance function, ∫ is a specific distance threshold, Vertex u belongs to vertex set v.
8. The cloth defect detection method based on deep learning according to claim 7, characterized in that: The core-edge partitioning in the hypergraph mapping relationship includes: Use distance threshold to dynamically divide core-edge nodes. The formulas are (1-11) and (1-12). Among them, ∫ is a specific distance threshold, core_mask i Indicates whether node i is a core node. A value of 1 indicates that it is a core node, and a value of 0 indicates that it is an edge node. M is the core-edge mask matrix.
9. The cloth defect detection method based on deep learning according to claim 8, characterized in that: The core-edge hypergraph calculation module constructed according to the core-edge partitioning includes: Calculate the Euclidean distance relationship between features and nodes to obtain the distance matrix D; Constructing a hypergraph matrix according to the distance matrix D, and enhancing feature information through hypergraph convolution and core-edge mask matrix; The original features and enhanced feature information are additively fused to reconstruct the original dimensions.
10. The cloth defect detection method based on deep learning according to claim 9, characterized in that: The constructing of a hypergraph feature fusion network according to the core-edge hypergraph computing module includes: Assume that the input features of the hypergraph feature fusion network are Among them, X Z is the current feature layer, B Z is the input batch size, C Z is the number of channels corresponding to the Zth feature layer, H Z and W Z is the height and width of the image corresponding to the Zth feature layer. For an input image I, the corresponding feature obtained by the backbone is L I ={L1, L2, L3, L4, L5}, the output feature of the core-edge hypergraph calculation module is recorded as L H , the output features of the graph feature fusion network are: N3, N4, N5.