Improved YOLOV7-tiny fabric image flaw detection method and system based on SPD-SE

By introducing the SPD-SE module in the YOLOV7-tiny model, the information loss problem caused by downsampling in the prior art is solved, and a higher accuracy of fabric image defect detection is achieved.

CN119831957AActive Publication Date: 2025-04-15ZHEJIANG UNIV

Patent Information

Application Number
CN202411898064.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-15
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

The prior art downsampling is performed through pooling operations in fabric image defect detection, resulting in nearly half of the information loss, affecting the model detection accuracy.

Method used

Using the improved YOLOV7-tiny model based on SPD-SE, the improved SPD convolution module and SE attention mechanism module are used to realize downsampling without information loss, retain the pixel-level distribution rules of the original feature map and learn the connection between channels.

Benefits of technology

The detection accuracy of the model in fabric image defect detection is improved, useful defect features can be positioned more accurately, and fabric defects can be detected quickly and accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119831957A_ABST
    Figure CN119831957A_ABST
Patent Text Reader

Abstract

The invention discloses an improved YOLOV7-tiny fabric image defect detection method and an improved YOLOV7-tiny fabric image defect detection system based on SPD-SE. The method comprises the following steps: establishing a fabric defect image data set containing fabric defect images and corresponding category labels; dividing the fabric defect image data set into a training set and a verification set according to a preset proportion; an improved YOLOV7-tiny model is constructed; the training set and the verification set are input into the constructed improved YOLOV7-tiny model for training, and the trained improved YOLOV7-tiny model is obtained; and finally, inputting a to-be-detected fabric defect image into the trained improved YOLOV7-tiny model, and outputting a defect detection result of the to-be-detected fabric defect image. According to the method, the phenomenon of loss of fine-grained pixel points in the model down-sampling operation can be avoided, the purpose of down-sampling is achieved on the basis of original information, and then accurate detection of fabric flaws is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep learning image processing, and in particular relates to a fabric image defect detection method and system based on an improved YOLOV7-tiny using SPD-SE. Background Art

[0002] At present, the downsampling technology in major classic models uses pooling operations (maximum pooling or average pooling). Although the pooling operation has low computational complexity and is convenient and fast, it will cause nearly half of the information loss, which has a certain impact on the performance of the model. Based on this, Raja Sunkara et al. introduced a new CNN module tailored for low-resolution images and small objects, called the SPD convolution module (SPD-Conv). This module converts the size dimension and the channel dimension to reduce the size dimension and increase the channel dimension to achieve the generation of the pooling operation. Although the pooling operation has low computational complexity and is convenient and fast, it will cause nearly half of the information loss, which has a certain impact on the performance of the model. Although the SPD convolution module (SPD-Conv) designed by Raja Sunkara et al. cleverly avoids the loss of pixel-level information in the feature map, it disrupts the pixel distribution of the original feature map, which will reduce the detection accuracy of large and medium targets.

[0003] YOLOV7-tiny is suitable for most fields as a target detection model, but because fabric defect features are few and small, the traditional pooling downsampling in YOLOV7-tiny will cause pixel-level feature loss, resulting in reduced model recognition accuracy. Therefore, it is necessary to improve the YOLOV7-tiny network model to ensure that the original few and small defect features can be preserved as much as possible while completing the downsampling operation, so as to improve the model performance and further improve the detection accuracy of fabric image defects. Summary of the invention

[0004] In order to solve the problems existing in the background technology, the purpose of the present invention is to propose a fabric image defect detection method and system based on SPD-SE improved YOLOV7-tiny.

[0005] The technical solution adopted by the present invention is as follows, comprising the following steps:

[0006] Step S1, establishing a fabric defect image dataset, including fabric defect images and their corresponding category labels; dividing the fabric defect image dataset into a training set and a validation set according to a preset ratio;

[0007] Step S2, constructing an improved YOLOV7-tiny model; the improved YOLOV7-tiny model is mainly obtained by improving the backbone feature extraction network in the YOLOV7-tiny model by the SPD convolution module and the SE attention mechanism module;

[0008] Step S3, inputting the training set and the verification set into the constructed improved YOLOV7-tiny model for training to obtain a trained improved YOLOV7-tiny model;

[0009] Step S4: Finally, the fabric defect image to be detected is input into the trained improved YOLOV7-tiny model, and the defect detection result of the fabric defect image to be detected is output.

[0010] In step S2, the improved YOLOV7-tiny model is obtained by replacing the first two MX modules in the backbone feature extraction network of the YOLOV7-tiny model with SPD-SE modules; the SPD-SE module is mainly composed of an improved SPD convolution module and an SE attention mechanism module; the improved SPD convolution module is used to convert the size dimension and channel dimension of the input original feature map, while increasing the number of feature map channels and reducing the size dimension, thereby achieving compression of the feature map size; the SE attention mechanism module first obtains the weight value of each channel of the compressed feature map, and then uses the channel weight value to assign weights to the feature map to generate a weighted feature map, and the size of the weighted feature map is completely consistent with the size of the compressed feature map.

[0011] The SPD-SE module in step S2 is constructed as follows:

[0012] Step S21: First, for the original feature map X with the input dimension of S×S×C, the improved SPD convolution module downsamples the original feature map using the sampling factor scale, and divides the original feature map X into scale 2 sub-feature maps; where S represents the side length of the original feature map and C represents the number of channels;

[0013] Step S22: Then, scale 2 The sub-feature maps are merged along the channel dimension to form a new compressed feature map X0, where the spatial dimension of the compressed feature map X0 is 1 / scale of the original feature map X, and the channel dimension is the scale of the original feature map X. 2 times;

[0014] Step S23: Next, the dimension is S / scale×S / scale×scale 2The compressed feature map X0 of C is input into the SE attention mechanism module. The SE attention mechanism module first performs a global average pooling operation on the compressed feature map X0, so that the compressed feature map X0 is compressed in the spatial dimension to form a dimension of 1×1×scale 2 The feature map X' of C is then passed through two consecutive fully connected layers to obtain a feature map with channel attention;

[0015] Step S24: Finally, the feature map with channel attention and the compressed feature map X0 input by the SE attention mechanism module are multiplied by the weight coefficient channel by channel, and the final output has channel attention and the dimension is S / scale×S / scale×scale 2 Target feature map of C.

[0016] In step S21, the improved SPD convolution module uses the sampling factor scale to divide the original feature map into multiple sub-feature maps in the following specific manner: in the spatial dimension, the two side length directions of the original feature map X are equally divided using the sampling factor scale as the number of divisions, and no division is performed in the channel dimension, so that the original feature map X is evenly divided into scale 2 Sub-feature graph.

[0017] When the improved YOLOV7-tiny model is trained using the training set and the validation set in step S3, the parameters of the improved YOLOV7-tiny model are updated by back propagation. The back propagation process calculates the error between the predicted value outputs and the true label labels through the loss function MPDIoU, and optimizes the parameters of the improved YOLOV7-tiny model by the gradient descent method to complete the training of the improved YOLOV7-tiny model.

[0018] In step S3, the number of epochs during training of the improved YOLOV7-tiny model is 300, the batch size is 16, the DataLoader is 16, the initial learning rate is 0.0001, the optimizer is Adam, and the input image pixel of the model is 640×640.

[0019] A fabric image defect detection system for implementing the above method comprises:

[0020] A data acquisition module is used to acquire a fabric defect image dataset including fabric defect images and their corresponding category labels, and divide the fabric defect image dataset into a training set and a verification set according to a preset ratio;

[0021] A model acquisition module is used to replace the first two MX modules in the backbone feature extraction network of the YOLOV7-tiny model with SPD-SE modules to obtain an improved YOLOV7-tiny model, wherein the SPD-SE module includes an improved SPD convolution module and an SE attention mechanism module;

[0022] A model optimization module, used for inputting the training set and the verification set into the constructed improved YOLOV7-tiny model for training, so as to obtain a trained improved YOLOV7-tiny model;

[0023] The data acquisition module is used to input the fabric defect image to be detected into the trained improved YOLOV7-tiny model, and output the defect detection result of the fabric defect image to be detected.

[0024] The present invention provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, the improved YOLOV7-tiny fabric image defect detection method based on SPD-SE as described in any of the above schemes can be implemented.

[0025] The present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE as described in any of the above schemes is implemented.

[0026] The present invention provides a computer electronic device, which includes a memory and a processor;

[0027] The memory is used to store computer programs;

[0028] The processor is used to implement the fabric image defect detection method of the improved YOLOV7-tiny based on SPD-SE as described in any of the above schemes when executing the computer program.

[0029] At present, all the excellent image target detection network models are inseparable from cross-scale feature fusion. And downsampling is an indispensable operation in the process of cross-scale feature fusion. The purpose of downsampling is to generate a thumbnail of the corresponding image for better feature fusion. However, in this process, existing technologies (such as maximum pooling technology) all achieve the purpose of downsampling by screening and discarding part of the pixel information. The loss of half of the information will seriously affect the detection accuracy of the model. In response to the above problems, the present invention proposes a downsampling module with no information loss-SPD-SE. This module can avoid the loss of fine-grained pixel points in the downsampling operation, complete the purpose of downsampling on the original information, and then realize the accurate detection of fabric defects.

[0030] The present invention proposes a downsampling module SPD-SE with no information loss. This downsampling module SPD-SE is divided into two parts: one involves improving the sampling method of the classic Spatial Pyramid Dilated Convolution (SPD) module, so that SPD can retain the pixel-level distribution law of the original feature map to the greatest extent. The other is to introduce the SE attention mechanism to learn the connection between the channels after sampling and splicing.

[0031] S1) Spatial Pyramid Dilated Convolution (SPD) module: A new type of CNN module tailored for low-resolution images and small objects, called the SPD convolution module (SPD-Conv). This module converts the size dimension and the channel dimension, thereby reducing the size dimension and increasing the channel dimension to achieve the purpose of generating the corresponding image thumbnail. However, the classic SPD convolution module uses an interval sampling method when downsampling the original feature map X of dimension S×S×C: for example, when scale=2, it means segmentation pixel by pixel, with 2 as a cycle. There will be S / 2 cycles in the x direction of the feature map, and the same in the y direction. In this way, the original feature layer will be divided into S / 2 cycles. 2 / 4 feature maps, each small feature map is divided into f 0,1 , f 1,1 f 0,0 , f 1,1 , and then recombine the feature maps with the same number to form 4 feature maps, and then connect these feature maps in the channel dimension to form a complete feature map.

[0032] This method cleverly avoids the loss of pixel-level information in the feature map, but disrupts the pixel distribution of the original feature map, which will reduce the detection accuracy of large and medium-sized targets. Therefore, it is necessary to improve the sampling method.

[0033] S2) SPD module improvements

[0034] The original SPD module sampling step adopts the principle of equal interval sampling, which will disrupt the original feature layout. After improvement, we directly divide the original feature map X into scale 2 = 4 consecutive sub-feature maps. The same principle of size dimension and channel dimension conversion is used to achieve the purpose of downsampling. However, we do not use interval sampling, but convert the original feature Figure 4Divide equally to retain the original pixel distribution to the maximum extent. Then, according to the SPD post-processing operation, the equally divided feature sub-graphs are spliced ​​in the channel dimension. At this point, compared with the SPD convolution, we retain four feature sub-graphs with complete pixel distribution. However, compared with the original feature graph, the relationship information between the four equally divided feature sub-graphs is split and lost. Therefore, we introduce the SE channel attention mechanism module (placed at the e figure in the improved SPD-SE module structure diagram) to learn to supplement the direct relationship division of the channel.

[0035] The beneficial effects of the present invention are:

[0036] The present invention improves the downsampling capability of the SPD convolution module by improving the SPD convolution module. After the multi-dimensional fabric defect features are downsampled, the SE channel attention mechanism is combined to divide the importance of the defect feature channels, so that the model can more accurately locate the useful defect features after downsampling, improve the recognition rate of fabric defects, and can quickly and accurately detect fabric defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 is a flow chart of the steps of the present invention;

[0038] Figure 2 It is a structural diagram of the SPD-SE module of the present invention;

[0039] Figure 3 It is a structural diagram of the improved YOLOV7-tiny model of the present invention;

[0040] Figure 4 It is a graph of the experimental thermal results of various network models of this embodiment;

[0041] Figure 5 It is a system block diagram of the present invention. DETAILED DESCRIPTION

[0042] The present invention is described in detail below in conjunction with specific implementation cases. The following implementation cases will help those skilled in the art to further understand the present invention, but will not limit the present invention in any form.

[0043] like Figure 1 As shown, in a preferred implementation of the present invention, the above-mentioned fabric image defect detection method based on SPD-SE improved YOLOV7-tiny includes the following steps S1 to S4. The specific implementation process is described below.

[0044] Step S1, establishing a fabric defect image dataset, including fabric defect images and their corresponding category labels; dividing the fabric defect image dataset into a training set and a validation set according to a preset ratio of 7:3;

[0045] The fabric defect image dataset in this embodiment is selected from the TILDA dataset, and the TILDA dataset needs to be parsed and converted into the Yolo format readable by the YOLOV7-tiny model; after the above fabric defect image dataset is divided according to the ratio of 7:3, the training set and the validation set are preprocessed respectively. Specifically, each fabric defect image in the fabric defect image dataset is first cropped into a shape of 640×640 using the transform transformation, and then the cropped fabric defect image is converted into the form of a tensor tensor matrix, and then the DataLoader data is loaded with batch_size=16. The batch_size here refers to the data size input each time the network is trained in deep learning.

[0046] Step S2, constructing an improved YOLOV7-tiny model; the improved YOLOV7-tiny model is obtained by improving the backbone feature extraction network in the YOLOV7-tiny model based on the SPD-Conv module and the SE attention mechanism module;

[0047] It should be noted that, considering that all the current excellent image target detection network models are inseparable from cross-scale feature fusion, downsampling is an indispensable operation in the process of cross-scale feature fusion. The purpose of downsampling is to generate a thumbnail of the corresponding image for better feature fusion. However, in this process, existing technologies (such as maximum pooling technology) all achieve the purpose of downsampling by screening and discarding part of the pixel information. The loss of half of the information will seriously affect the detection accuracy of the model. In response to the above problems, the present invention proposes a downsampling module with no information loss-the SPD-SE module. This module can avoid the loss of fine-grained pixel points in the downsampling operation, complete the purpose of downsampling on the original information, and then realize the accurate detection of fabric defects.

[0048] In an embodiment of the present invention, the improved YOLOV7-tiny model specifically improves the backbone feature extraction network in the YOLOV7-tiny model. Specifically, Figure 3As shown in the figure, two SPD-SE modules are introduced to replace the first two MX modules to form an improved YOLOV7-tiny model. The SPD-SE module is divided into two parts: one involves improving the sampling method of the classic Spatial Pyramid Dilated Convolution (SPD) module, so that SPD can retain the pixel-level distribution law of the original feature map to the greatest extent, thereby constructing an improved SPD convolution module SPD-Conv; the other is to introduce the SE attention mechanism to learn the connection between the channels after sampling and splicing, thereby constructing the SE attention mechanism module. Among them, the improved SPD convolution module in the SPD-SE module mainly improves the sampling method of the classic SPD convolution module, and the SE attention mechanism module in the SPD-SE module directly adopts the classic SE attention mechanism module without improvement. Specifically, the improved SPD convolution module is used to convert the size dimension and channel dimension of the input original feature map, reducing the size dimension while increasing the number of feature map channels, thereby compressing the feature map size; the SE attention mechanism module first obtains the weight value of each channel of the compressed feature map, and then uses the channel weight value to assign weights to the feature map to generate a weighted feature map. The size of the weighted feature map is exactly the same as the size of the compressed feature map.

[0049] like Figure 2 As shown, in this embodiment of the present invention, the construction method in the SPD-SE module in step S2 is as follows:

[0050] S21. First, for the original feature map X with the input dimension of S×S×C, the improved SPD convolution module downsamples the original feature map using the sampling factor scale and divides the original feature map X into scale 2 sub-feature maps; where S represents the side length of the original feature map and C represents the number of channels;

[0051] S22, then, scale 2 The sub-feature maps are merged along the channel dimension to form a new compressed feature map X0. The spatial dimension of the compressed feature map X0 is 1 / scale of the original feature map X, and the channel dimension is the scale of the original feature map X. 2 times;

[0052] S23, then, the dimension is S / scale×S / scale×scale 2 The compressed feature map X0 of C is input into the SE attention mechanism module. The SE attention mechanism module first performs a global average pooling operation on the compressed feature map X0, so that the compressed feature map X0 is compressed in the spatial dimension to form a dimension of 1×1×scale 2The feature map X' of C is then passed through two consecutive fully connected layers to obtain a feature map with channel attention;

[0053] S24. Finally, the feature map with channel attention and the compressed feature map X0 input by the SE attention mechanism module are multiplied by the weight coefficient channel by channel, and the final output has channel attention and the dimension is S / scale×S / scale×scale 2 Target feature map of C.

[0054] It should be noted that the Spatial Pyramid Dilated Convolution (SPD) module is a new type of CNN module tailored for low-resolution images and small objects, called the SPD convolution module (SPD-Conv). This module converts the size dimension and the channel dimension, thereby reducing the size dimension and increasing the channel dimension to achieve the purpose of generating the corresponding image thumbnail. However, the classic SPD convolution module uses an interval sampling method when downsampling the original feature map X of dimension S×S×C: for example, when scale=2, it means pixel-by-pixel segmentation, with 2 as a cycle. There will be S / 2 cycles in the x direction of the feature map, and the same in the y direction. In this way, the original feature layer will be divided into S / 2 cycles. 2 / 4 feature maps, each small feature map is divided into f 0,1 , f 1,1 f 0,0 , f 1,1 , and then recombining the feature maps with the same number to form 4 feature maps, and then connecting these feature maps in the channel dimension to form a complete feature map. This method cleverly avoids the loss of pixel-level information of the feature map, but disrupts the pixel distribution of the original feature map, which will reduce the detection accuracy of large and medium targets. Therefore, it is necessary to improve the sampling method.

[0055] In this embodiment, considering that the sampling step of the classic SPD convolution module adopts the principle of equal interval sampling, this method will disrupt the original feature layout. After improvement, the present invention directly divides the original feature map X into scale 2 = 4 consecutive sub-feature maps. The same principle of size dimension and channel dimension conversion is used to achieve the purpose of downsampling. However, interval sampling is not adopted, but the original feature Figure 4Divide equally to retain the original pixel distribution to the maximum extent. Then, according to the SPD post-processing operation, the equally divided feature subgraphs are spliced ​​in the channel dimension. At this time, compared with the SPD convolution, the present invention retains four feature subgraphs with complete pixel distribution. However, compared with the original feature graph, the relationship information between the four equally divided feature subgraphs is split and lost. Therefore, the present invention introduces the SE channel attention mechanism module (placed at the e figure in the improved SPD-SE module structure diagram) to learn the direct relationship division of the supplementary channel.

[0056] In step S21, the improved SPD convolution module uses the sampling factor scale to divide the original feature map into multiple sub-feature maps in the following specific manner: in the spatial dimension, the two side length directions of the original feature map X are equally divided using the sampling factor scale as the number of divisions, and no division is performed in the channel dimension, so that the original feature map X is evenly divided into scale 2 Sub-feature graph.

[0057] Step S3, input the training set and the verification set into the constructed improved YOLOV7-tiny model for training, and obtain the trained improved YOLOV7-tiny model;

[0058] In step S3, when the improved YOLOV7-tiny model is trained using the training set and the validation set, the parameters of the improved YOLOV7-tiny model are updated by back propagation. The back propagation process calculates the error between the predicted value outputs and the true label labels through the MPDIoU loss function, and optimizes the parameters (i.e., gradient values) of the improved YOLOV7-tiny model by the gradient descent method to complete the training of the improved YOLOV7-tiny model.

[0059] Specifically, when training the YOLOV7-tiny model, all gradients are initialized to 0, and the model is trained to obtain the predicted value outputs; the loss loss is calculated by the outputs and the true label labels, and then back propagation is performed to update the gradient.

[0060] In step S3, the number of epochs for training the improved YOLOV7-tiny model is 300, the batch size is 16, the DataLoader is 16, the initial learning rate is 0.0001, the optimizer is Adam, and the input image pixels of the model are 640×640.

[0061] Step S4: Finally, the fabric defect image to be detected is input into the trained improved YOLOV7-tiny model, and the defect detection result of the fabric defect image to be detected is output.

[0062] In order to better demonstrate the specific implementation and technical effects of the present invention, a fabric image defect detection method based on SPD-SE and improved YOLOV7-tiny shown in steps S1 to S4 in the above preferred implementation is applied to a specific example.

[0063] Example

[0064] The specific implementation process of the fabric image defect detection method based on SPD-SE improved YOLOV7-tiny adopted in this embodiment is as described above and will not be repeated here.

[0065] In this embodiment, different models are compared with the method of the present invention, and the fabric experimental thermal diagrams obtained by different models are as follows: Figure 4 shown. Figure 4 In the figure, image1-image2 represent two test images; the MaxPooling column represents the fabric image defect detection result diagram using the pooling layer of the original YOLOV7-tiny; the SPD column represents the fabric image defect detection result diagram obtained by using the classic SPD module of Raja Sunkara et al.; the SPD-SE column represents the fabric image defect detection result diagram obtained by using the improved YOLOV7-tiny model of the present invention.

[0066] from Figure 4 It can be clearly seen that the SPD module has a certain improvement in recognition accuracy compared with the pooled downsampling, but the model focus area (the red area in the figure) is large and complex; the SPD-SE downsampling module of the present invention not only improves the recognition accuracy, but also strengthens the focus on useful features, so that the model's attention is greatly shifted to useful features, and the defect detection of fabric images can be more accurately achieved.

[0067] It should also be noted that the fabric image defect detection method based on SPD-SE and improved YOLOV7-tiny in the above embodiment can essentially be executed by a computer program or module. Therefore, similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a fabric image defect detection system based on SPD-SE and improved YOLOV7-tiny corresponding to the fabric image defect detection method based on SPD-SE and improved YOLOV7-tiny provided in the above embodiment, such as Figure 5 As shown, it includes:

[0068] A data acquisition module is used to acquire a fabric defect image dataset including fabric defect images and their corresponding category labels, and divide the fabric defect image dataset into a training set and a verification set according to a preset ratio;

[0069] A model acquisition module is used to replace the first two MX modules in the backbone feature extraction network of the YOLOV7-tiny model with SPD-SE modules to obtain an improved YOLOV7-tiny model, wherein the SPD-SE module includes an improved SPD convolution module and an SE attention mechanism module;

[0070] A model optimization module, used for inputting the training set and the verification set into the constructed improved YOLOV7-tiny model for training, so as to obtain a trained improved YOLOV7-tiny model;

[0071] The data acquisition module is used to input the fabric defect image to be detected into the trained improved YOLOV7-tiny model, and output the defect detection result of the fabric defect image to be detected.

[0072] It can be understood that the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE described in S1 to S4 above can be substantially implemented by a computer program. Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer program product corresponding to the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE provided in the above embodiment, which includes a computer program / instruction. When the computer program / instruction is executed by a processor, the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE as described in the above embodiment can be implemented.

[0073] Similarly, based on the same inventive concept, another preferred embodiment of the present invention further provides a computer electronic device corresponding to the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE provided in the above embodiment, which includes a memory and a processor;

[0074] The memory is used to store computer programs;

[0075] The processor is used to implement the fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE in the above embodiment when executing the computer program.

[0076] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an 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, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0077] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the improved YOLOV7-tiny fabric image defect detection method based on SPD-SE provided in the above embodiment, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the improved YOLOV7-tiny fabric image defect detection method based on SPD-SE in the above embodiment can be implemented.

[0078] It is understandable that the above storage medium may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. The storage medium may also be a U disk, a mobile hard disk, a magnetic disk or an optical disk, etc., which can store program codes.

[0079] It is understandable that the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0080] It should also be noted that those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the various embodiments provided in this application, the division of steps or modules in the system and method is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or steps can be combined or integrated together, and a module or step can also be split.

[0081] The embodiments described above are merely descriptions of preferred implementations of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should fall within the protection scope of the present invention.

Claims

1. A fabric image defect detection method based on SPD-SE improved YOLOV7-tiny, characterized in that: The following steps are involved: Step S1, establishing a fabric defect image dataset, including fabric defect images and their corresponding category labels; dividing the fabric defect image dataset into a training set and a validation set according to a preset ratio; Step S2, constructing an improved YOLOV7-tiny model; the improved YOLOV7-tiny model is mainly obtained by improving the backbone feature extraction network in the YOLOV7-tiny model by the SPD convolution module and the SE attention mechanism module; Step S3, inputting the training set and the verification set into the constructed improved YOLOV7-tiny model for training to obtain a trained improved YOLOV7-tiny model; Step S4: Finally, the fabric defect image to be detected is input into the trained improved YOLOV7-tiny model, and the defect detection result of the fabric defect image to be detected is output.

2. The fabric image defect detection method based on improved YOLOV7-tiny of SPD-SE according to claim 1, characterized in that: In step S2, the improved YOLOV7-tiny model is obtained by replacing the first two MX modules in the backbone feature extraction network of the YOLOV7-tiny model with SPD-SE modules; the SPD-SE module is mainly composed of an improved SPD convolution module and an SE attention mechanism module; the improved SPD convolution module is used to convert the size dimension and channel dimension of the input original feature map, while increasing the number of feature map channels and reducing the size dimension, thereby achieving compression of the feature map size; the SE attention mechanism module first obtains the weight value of each channel of the compressed feature map, and then uses the channel weight value to assign weights to the feature map to generate a weighted feature map, and the size of the weighted feature map is completely consistent with the size of the compressed feature map.

3. The fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE according to claim 2, characterized in that: The SPD-SE module in step S2 is constructed as follows: Step S21: First, for the original feature map X with the input dimension of S×S×C, the improved SPD convolution module downsamples the original feature map using the sampling factor scale, and divides the original feature map X into scale 2 sub-feature maps; where S represents the side length of the original feature map and C represents the number of channels; Step S22: Then, scale 2 The sub-feature maps are merged along the channel dimension to form a new compressed feature map X0, where the spatial dimension of the compressed feature map X0 is 1 / scale of the original feature map X, and the channel dimension is the scale of the original feature map X. 2 times; Step S23: Next, the dimension is S / scale×S / scale×scale 2 The compressed feature map X0 of C is input into the SE attention mechanism module. The SE attention mechanism module first performs a global average pooling operation on the compressed feature map X0, so that the compressed feature map X0 is compressed in the spatial dimension to form a dimension of 1×1×scale 2 The feature map X' of C is then passed through two consecutive fully connected layers to obtain a feature map with channel attention; Step S24: Finally, the feature map with channel attention and the compressed feature map X0 input by the SE attention mechanism module are multiplied by the weight coefficient channel by channel, and the final output has channel attention and the dimension is S / scale×S / scale×scale 2 Target feature map of C.

4. The fabric image defect detection method based on the improved YOLOV7-tiny of SPD-SE according to claim 3, characterized in that: In step S21, the improved SPD convolution module uses the sampling factor scale to divide the original feature map into multiple sub-feature maps in the following specific manner: in the spatial dimension, the two side length directions of the original feature map X are equally divided using the sampling factor scale as the number of divisions, and no division is performed in the channel dimension, so that the original feature map X is evenly divided into scale 2 Sub-feature graph.

5. The fabric image defect detection method based on improved YOLOV7-tiny of SPD-SE according to claim 1, characterized in that: When the improved YOLOV7-tiny model is trained using the training set and the validation set in step S3, the parameters of the improved YOLOV7-tiny model are updated by back propagation. The back propagation process calculates the error between the predicted value outputs and the true label labels through the loss function MPDIoU, and optimizes the parameters of the improved YOLOV7-tiny model by the gradient descent method to complete the training of the improved YOLOV7-tiny model.

6. The fabric image defect detection method based on improved YOLOV7-tiny of SPD-SE according to claim 1, characterized in that: In step S3, the number of epochs during training of the improved YOLOV7-tiny model is 300, the batch size is 16, the DataLoader is 16, the initial learning rate is 0.0001, the optimizer is Adam, and the input image pixel of the model is 640×640.

7. A fabric image defect detection system for implementing the method according to any one of claims 1 to 7, characterized in that: include: A data acquisition module is used to acquire a fabric defect image dataset including fabric defect images and their corresponding category labels, and divide the fabric defect image dataset into a training set and a verification set according to a preset ratio; A model acquisition module is used to replace the first two MX modules in the backbone feature extraction network of the YOLOV7-tiny model with SPD-SE modules to obtain an improved YOLOV7-tiny model, wherein the SPD-SE module includes an improved SPD convolution module and an SE attention mechanism module; A model optimization module, used for inputting the training set and the verification set into the constructed improved YOLOV7-tiny model for training, so as to obtain a trained improved YOLOV7-tiny model; The data acquisition module is used to input the fabric defect image to be detected into the trained improved YOLOV7-tiny model, and output the defect detection result of the fabric defect image to be detected.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the fabric image defect detection method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the fabric image defect detection method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • SAR image aircraft target detection method based on improved YOLOv5

    CN116630798A

  • Metal surface defect detection method, readable medium and device

    CN116703848A

  • Fabric defect detection method based on improved YOLOv7-Tiny network model

    CN117173111A

  • Lightweight overwater target detection method and device and medium

    CN117649544A

  • Cloth defect detection method based on improved YOLOv5

    CN117893517A

Cited By

  • Improved YOLO11s-based insulator defect detection method in snowy day weak light environment

    CN120525869A

  • Fabric quality grade evaluation method and system based on surface defects

    CN121169895A

  • Eye fundus image coloring method, computer readable storage medium and electronic equipment

    CN122453948A