Fabric Quality Detection Method, Device, Equipment and Storage Medium

By dividing image blocks in fabric detection and determining the similarity rate using the trained image prediction network, the problem of defect miss detection in the prior art is solved, and a higher detection accuracy is achieved.

CN115731186BActive Publication Date: 2025-07-22CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211464735.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-22
Publication Date
2025-07-22
Estimated Expiration
2042-11-22

AI Technical Summary

Technical Problem

In the prior art, fabric detection methods are prone to miss detection of defects, especially low frequency and emerging defect types, resulting in low detection accuracy.

Method used

By obtaining the images of the fabric to be detected, dividing them into preset number of image blocks, and using the trained image prediction network to determine defects based on the similarity obtained by the fabric qualified image block training, the trained image prediction network predicts the similarity of the image blocks to ensure that all image blocks are not defective.

Benefits of technology

Improve the accuracy of fabric inspection, avoid low frequency and emerging defect miss inspection, and ensure more accurate quality inspection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115731186B_ABST
    Figure CN115731186B_ABST
Patent Text Reader

Abstract

The present application provides a fabric quality detection method, device, equipment and storage medium. The method includes: obtaining a to-be-detected image of the to-be-detected fabric; inputting the to-be-detected image into a trained fabric detection model, and using the trained fabric detection model to divide the to-be-detected image into a preset number of to-be-detected image blocks; using a trained image prediction network to predict and output a third to-be-detected prediction image block of the third to-be-detected image block in each prediction unit; the trained image prediction network is trained according to the qualified image blocks of at least one qualified fabric image; using the trained fabric detection model to determine a first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block; and determining a quality detection result corresponding to the to-be-detected fabric according to each first similarity rate. The method of the present application can improve the detection accuracy of fabrics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to artificial intelligence technology, and in particular, to a method, device, equipment and storage medium for fabric quality detection. Background Art

[0002] In the production process of fabrics such as leather and cloth, due to manufacturing processes or environmental reasons, some fabric products will have defects. It is necessary to conduct quality inspection on the fabrics to detect whether there are defects on the fabric products, and then select defect-free qualified products from the fabric products based on the inspection results.

[0003] In the prior art, a defect detection model trained by a deep learning method is used to conduct quality inspection on fabrics to determine whether there are defects in the fabric products. The defect detection model can quickly detect various types of defects existing on the fabrics. However, for the defect detection model to accurately detect various types of defects existing on the fabrics without missing detections, for each type of defect, a large number of defect samples are required to train the model. For some defect types that appear infrequently on the fabrics and are not easy to collect enough defect samples, the defect detection model is prone to missing detections, resulting in inaccurate detection results. Moreover, after the defect detection model is trained and put into use, once a new type of defect appears on the fabric products, since there are no defect samples of the new type during the training of the defect detection model, the defect detection model will also miss detections for the new type of defect, resulting in inaccurate detection results.

[0004] In summary, the fabric detection method in the prior art has the problem of being prone to missing detections, which in turn leads to a low detection accuracy. Summary of the Invention

[0005] This application provides a method, device, equipment and storage medium for fabric quality detection to solve the problem of low detection accuracy in the prior art.

[0006] According to the first aspect of this application, a method for fabric quality detection is provided, including:

[0007] Obtain a to-be-detected image of the to-be-detected fabric;

[0008] Input the to-be-detected image into a trained fabric detection model, and use the trained fabric detection model to divide the to-be-detected image into a preset number of to-be-detected image blocks;

[0009] Input the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the third predicted image block of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one qualified fabric image.

[0010] Use the trained fabric detection model to determine the first similarity rate between each third predicted image block and its corresponding third image block to be detected.

[0011] Determine the quality detection result corresponding to the fabric to be detected according to each of the first similarity rates.

[0012] As an optional implementation manner, the trained image prediction network further includes a preset image segmentation network, and the output of the preset image segmentation network is connected to the input of the trained image prediction network.

[0013] The step of using the trained fabric detection model to divide a preset number of image blocks to be detected on the image to be detected includes:

[0014] Perform a convolution operation on the image to be detected using the preset image segmentation network to obtain a preset number of image blocks to be detected.

[0015] As an optional implementation manner, before inputting the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, it further includes:

[0016] Obtain the qualified image blocks of at least one qualified fabric image.

[0017] Input the first qualified image block and the second qualified image block in each prediction unit into the image prediction network to be trained, and use the image prediction network to be trained to predict and output the third qualified prediction image block of the third qualified image block in each prediction unit; the first, second, and third qualified image blocks in the prediction unit are adjacent to each other in the first preset direction.

[0018] Train the image prediction network to be trained according to each third qualified prediction image block and each third qualified image block to obtain the trained image prediction network.

[0019] As an optional implementation manner, the trained image prediction network includes a first encoding network, a second encoding network, and a decoding network; the structures and parameters of the first encoding network and the second encoding network are the same.

[0020] Inputting the first image block to be detected and the second image block to be detected in each prediction unit into a trained image prediction network, and using the trained image prediction network to predict and output the third predicted image block of the third image block to be detected in each prediction unit, includes:

[0021] For any one prediction unit, perform the following operations:

[0022] Input the first image block to be detected into the first encoding network, input the second image block to be detected into the second encoding network, use the first encoding network to extract the first encoding feature of the first image block to be detected, and use the second encoding network to extract the second encoding feature of each second image block to be detected;

[0023] Use the decoding network to generate the third predicted image block to be detected according to the first encoding feature and the second encoding feature.

[0024] As an optional implementation manner, both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit;

[0025] The decoding network includes a multi-layer perceptron, a linear mapping unit and at least one upsampling unit, each upsampling unit is sequentially connected to the linear mapping unit, and the number of upsampling units is equal to the number of downsampling units in any one encoding network;

[0026] Using the encoding network to extract the encoding feature of the image block to be detected, includes:

[0027] Use the linear embedding unit to perform dimensional transformation and feature transformation on the input image block to be detected, and input the obtained feature map into the next unit and the linear mapping unit in the decoding network;

[0028] Use each intermediate downsampling unit in the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the corresponding upsampling unit in the decoding network;

[0029] Use the downsampling unit at the end of the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the upsampling unit at the beginning of the decoding network.

[0030] As an optional implementation manner, the using the decoding network to generate the third predicted image block to be detected according to the first encoding feature and the second encoding feature, includes:

[0031] Use the upsampling unit at the beginning of the decoding network to perform upsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the multi-layer perceptron;

[0032] An upsampling unit located in the middle of the decoding network performs downsampling and feature transformation on the feature map input by the previous unit and the feature map input by the corresponding downsampling unit in the encoding network, and inputs the obtained feature map into the next unit and the multi-layer perceptron;

[0033] A linear mapping unit performs dimensionality transformation and feature transformation on the feature map input by the previous unit and the feature map input by the linear embedding unit, and inputs the output feature map into the multi-layer perceptron;

[0034] The multi-layer perceptron generates the to-be-detected prediction image blocks according to the input multiple feature maps.

[0035] As an optional implementation manner, the trained fabric detection model further includes a preset image comparison network, and the input of the preset image comparison network is connected to the output of the trained image prediction network;

[0036] The step of using the trained fabric detection model to determine the first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block includes:

[0037] Input each third to-be-detected image block and its corresponding third to-be-detected prediction image block into the preset image comparison network, and use the preset image comparison network to output the first similarity rate between each third to-be-detected image block and its corresponding third to-be-detected prediction image block.

[0038] As an optional implementation manner, the step of determining the quality detection result corresponding to the to-be-detected fabric according to each of the first similarity rates includes:

[0039] If it is determined that each of the first similarity rates is greater than the preset similarity rate threshold, it is determined that the quality detection result corresponding to the to-be-detected fabric is qualified;

[0040] If it is determined that any one of the first similarity rates is less than the preset similarity rate threshold, it is determined that the quality detection result corresponding to the to-be-detected fabric is unqualified.

[0041] As an optional implementation manner, if it is determined that the quality detection result corresponding to the to-be-detected fabric is unqualified, it further includes:

[0042] Input the third to-be-detected image blocks of each prediction unit and each third to-be-detected image block into the trained image prediction network, and use the trained image prediction network to predict and output the first to-be-detected prediction image block corresponding to the first to-be-detected image block in each prediction unit; the third, second, and first to-be-detected image blocks in the prediction unit are adjacent in sequence in the second preset direction; the second preset direction is opposite to the first preset direction;

[0043] Determine the second similarity rate between each first to-be-detected prediction image block and its corresponding first to-be-detected image block;

[0044] Determine at least one third image block to be detected with a corresponding first similarity rate less than a preset similarity rate threshold as a first difference image block;

[0045] Determine at least one first image block to be detected with a corresponding second similarity rate less than a preset similarity rate threshold as a second difference image block;

[0046] Determine the area where the image block to be detected in the image to be detected, which is determined as both a first difference image block and a second difference image block, as a defective area.

[0047] As an optional implementation manner, after determining at least one first image block to be detected with a corresponding second similarity rate less than a preset similarity rate threshold as a second difference image block, it further includes:

[0048] Input each first difference image block and its corresponding third predicted image block to be detected into a preset image comparison network, and use the preset image comparison network to output a first difference image of the image to be detected;

[0049] Input each second difference image block and its corresponding first predicted image block to be detected into a preset image comparison network, and use the preset image comparison network to output a second difference image of the image to be detected;

[0050] Determine the intersection of the first difference image and the second difference image as the defective shape.

[0051] According to a second aspect of the present application, there is provided a fabric quality detection device, including:

[0052] An acquisition module, configured to acquire an image to be detected of the fabric to be detected;

[0053] A detection module, configured to input the image to be detected into a trained fabric detection model, and use the trained fabric detection model to divide a preset number of image blocks to be detected on the image to be detected; input the first image block to be detected and the second image block to be detected in each prediction unit into a trained image prediction network, and use the trained image prediction network to predict and output a third predicted image block to be detected of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent in a first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image; use the trained fabric detection model to determine the first similarity rate between each third predicted image block to be detected and its corresponding third image block to be detected;

[0054] A first determination module, configured to determine the detection result according to each of the first similarity rates.

[0055] According to a third aspect of the present application, there is provided an electronic device, including: a processor and a memory communicatively connected to the processor;

[0056] The memory stores computer-executable instructions;

[0057] The processor executes the computer-executable instructions stored in the memory to implement the fabric quality detection method described in the first aspect.

[0058] According to a fourth aspect of the present application, there is provided a computer-readable storage medium storing computer-executable instructions, which are used to implement the fabric quality detection method described in the first aspect when executed by a processor.

[0059] The fabric quality detection method, device, equipment and storage medium provided by this application obtain a to-be-detected image of the to-be-detected fabric; input the to-be-detected image into a trained fabric detection model, and use the trained fabric detection model to divide the to-be-detected image into a preset number of to-be-detected image blocks; input the first to-be-detected image block and the second to-be-detected image block in each prediction unit into a trained image prediction network, and use the trained image prediction network to predict and output the third to-be-detected prediction image block of the third to-be-detected image block in each prediction unit; the first, second, and third to-be-detected image blocks in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image; use the trained fabric detection model to determine the first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block; determine the quality detection result corresponding to the to-be-detected fabric according to each of the first similarity rates. Since the to-be-detected fabric has regular textures or patterns, therefore, the trained image prediction network can be used to predict the third to-be-detected image block in the preset unit according to the correlation between the first and second to-be-detected image blocks in the prediction unit. And the trained image prediction network is trained according to the qualified image blocks of the fabric qualified image. Therefore, the trained image prediction network can only predict a flawless third to-be-detected prediction image block when both the first and second to-be-detected image blocks are flawless image blocks. Once there is a flaw in any one of the first and second to-be-detected image blocks, the trained image prediction network cannot predict a flawless third to-be-detected image block. Furthermore, only when the first, second, and third to-be-detected image blocks are all flawless, the third to-be-detected prediction image block predicted by the trained image prediction network will be similar to the third to-be-detected image block. In this way, once there are low-frequency or newly emerged flaws in the to-be-detected fabric, the third to-be-detected prediction image block will not be similar to the third to-be-detected image block. Furthermore, according to the first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block in the to-be-detected image, it can be determined whether there are flaws in the to-be-detected fabric. Therefore, the solution of this application will not miss the detection of low-frequency flaws and new flaws in the to-be-detected fabric, and can determine a more accurate quality detection result corresponding to the to-be-detected fabric. In summary, the technical solution of this application can determine a more accurate fabric quality detection result and improve the detection accuracy of the fabric. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0061] Figure 1 is a network architecture diagram corresponding to the application scenario of the fabric quality detection method provided by the embodiment of the present application;

[0062] Figure 2 is a schematic flowchart of the fabric quality detection method provided in Embodiment 1 of the present application;

[0063] Figure 3 is a schematic diagram of dividing the image to be detected into image blocks to be detected on the image to be detected provided in Embodiment 1 of the present application;

[0064] Figure 4 is a schematic flowchart of the fabric quality detection method provided in Embodiment 2 of the present application;

[0065] Figure 5 is a schematic flowchart of the fabric quality detection method provided in Embodiment 3 of the present application;

[0066] Figure 6 is a schematic diagram of the structure of the trained image prediction network provided in Embodiment 3 of the present application;

[0067] Figure 7 is a schematic diagram of the structure of the first preset image comparison network provided in Embodiment 4 of the present application;

[0068] Figure 8 is a schematic flowchart of the fabric quality detection method provided in Embodiment 5 of the present application;

[0069] Figure 9 is a schematic diagram of the structure of the second preset image comparison network provided in Embodiment 5 of the present application;

[0070] Figure 10 is a schematic diagram of the structure of the fabric quality detection device provided in Embodiment 6 of the present application;

[0071] Figure 11 is a schematic diagram of the structure of the electronic device provided in Embodiment 7 of the present application.

[0072] Through the above-mentioned drawings, the specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Description of the Specific Embodiment

[0073] The following provides a detailed description and analysis of the prior art related to the present application.

[0074] In the production process of fabrics with regular textures or patterns such as leather and cloth, due to manufacturing processes or the surrounding environment, some defects may occur in the produced fabrics. Fabrics with defects do not meet the quality inspection requirements, and it is necessary to remove the fabrics with defects during the quality inspection of the fabrics and select the qualified fabrics without defects.

[0075] After the fabric production is completed, experienced staff can observe the fabric visually to detect whether there are defects. Fabric images can also be collected by an industrial camera on a high-speed production line, and artificial intelligence algorithms, such as defect detection models, are used to detect the defects existing in the fabric.

[0076] In the above method of detection by staff, since it is difficult for staff to maintain a high degree of concentration for a long time, and moreover, the fabric on the production line is often in a high-speed movement state. For relatively large defects, staff can easily observe them, but for relatively small defects, it is not easy to observe them. Therefore, it is very easy for staff to miss detecting defective fabrics, resulting in defective fabrics being mixed into qualified fabrics.

[0077] In the above method of detection by artificial intelligence algorithms, since artificial intelligence algorithms are based on deep learning, they need to be trained with a large number of samples before they can be used. In the actual production process, there are many types of defects in fabrics, and the occurrence frequencies of different types of defects are also different. For defects with a high occurrence frequency, it is easy to collect sufficient defect samples. However, for some defects with a low occurrence frequency, it is not easy to collect samples, either unable to support the training of the defect detection model, or the trained defect detection model has a low recognition rate for defects with a low occurrence frequency, and there will be a situation of missing the detection of defective fabrics during use. And after a new type of defect appears in the fabric, it is necessary to re-collect samples of the new type of defect to train the defect detection model, otherwise the defect detection model cannot recognize the newly appeared type of defect, and then there will be a situation of missing the detection of defective fabrics.

[0078] In summary, the fabric detection methods in the prior art are prone to missing the detection of defective fabrics.

[0079] Therefore, in the face of the problems in the prior art, through creative research, in order to accurately detect defective fabrics, when there are many types of defects and the occurrence frequencies are unstable, it is impossible to determine defective fabrics by detecting the defects existing in the fabric. Only by detecting whether the fabric is similar to the qualified fabric to determine whether there are defects in the fabric can defective fabrics be accurately determined, and then an accurate fabric quality detection result can be determined.

[0080] Therefore, the inventor proposes the technical solution of this application. By obtaining the image to be detected of the fabric to be detected; inputting the image to be detected into the trained fabric detection model, and using the trained fabric detection model to divide the image to be detected into a preset number of image blocks to be detected on the image to be detected; inputting the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and using the trained image prediction network to predict and output the third predicted image block to be detected of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one qualified fabric image; using the trained fabric detection model to determine the first similarity rate between each third predicted image block to be detected and its corresponding third image block to be detected; determining the quality detection result corresponding to the fabric to be detected according to each first similarity rate. Since the fabric to be detected has regular textures or patterns, therefore, the trained image prediction network can be used to predict the third image block to be detected in the preset unit according to the correlation between the first and second image blocks to be detected in the prediction unit. And the trained image prediction network is trained according to the qualified image blocks of the qualified fabric images. Therefore, the trained image prediction network can only predict a flawless third predicted image block to be detected when both the first and second image blocks to be detected are flawless image blocks. Once there is a flaw in any one of the first and second image blocks to be detected, the trained image prediction network cannot predict a flawless third image block to be detected. Furthermore, only when the first, second, and third image blocks to be detected are all flawless, the third predicted image block to be detected predicted by the trained image prediction network will be similar to the third image block to be detected. In this way, once there are flaws with low occurrence frequency or newly emerged in the fabric to be detected, the third predicted image block to be detected will not be similar to the third image block to be detected. Furthermore, according to the first similarity rate between each third predicted image block to be detected in the image to be detected and its corresponding third image block to be detected, it can be determined whether there are flaws in the fabric to be detected. Therefore, the solution of this application will not miss the detection of low-frequency flaws and new flaws in the fabric to be detected, and can determine a more accurate quality detection result corresponding to the fabric to be detected. In summary, the technical solution of this application can determine a more accurate fabric quality detection result and improve the detection accuracy of the fabric.

[0081] The fabric quality detection method, device, equipment and storage medium provided by this application are aimed at solving the above technical problems in the prior art. The following uses specific embodiments to detail the technical solution of this application and how the technical solution of this application solves the above technical problems. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0082] The network architecture and application scenario of the fabric quality detection method provided by the embodiments of the present application will be introduced below. When the following description involves the accompanying drawings, unless otherwise indicated, the same data in different drawings represent the same or similar elements.

[0083] Figure 1 It is a network architecture diagram corresponding to the application scenario of the fabric quality detection method provided by the embodiments of the present application. As Figure 1 shown, a network architecture corresponding to an application scenario provided by the embodiments of the present application includes: a photography device 11 and an electronic device 12. The photography device 11 is communicatively connected to the electronic device 12. The photography device 11 may be a part of the electronic device 12. For example, it is a camera or a lens of the electronic device 12, etc.

[0084] The electronic device 12 is configured with a trained fabric detection model 14.

[0085] The photography device 11 captures a to-be-detected image of the to-be-detected fabric 13 and sends it to the electronic device 12.

[0086] After the electronic device 12 obtains the to-be-detected image of the to-be-detected fabric, the electronic device 12 inputs the to-be-detected image into the trained fabric detection model 14, and uses the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image; and inputs the first to-be-detected image block and the second to-be-detected image block in each prediction unit into the trained image prediction network, and uses the trained image prediction network to predict and output the third to-be-detected prediction image block of the third to-be-detected image block in each prediction unit. The first, second, and third to-be-detected image blocks in the prediction unit are adjacent to each other in a first preset direction. The trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image.

[0087] The electronic device 12 uses the trained fabric detection model 14 to determine a first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block. Then, according to each of the first similarity rates, a quality detection result corresponding to the to-be-detected fabric 13 is determined.

[0088] The embodiments of the present application will be described below with reference to the accompanying drawings. The embodiments described in the following do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0089] Embodiment 1

[0090] Figure 2 It is a flowchart of the fabric quality detection method provided by Embodiment 1 of the present application. Figure 3It is a schematic diagram of dividing a to-be-detected image block on a to-be-detected image according to Embodiment 1 of the present application. As Figure 2 shown, the execution subject of the present application is a fabric quality detection device, which is located in an electronic device. The fabric quality detection method provided in this embodiment includes steps 201 to 205.

[0091] Step 201, obtain a to-be-detected image of the to-be-detected fabric.

[0092] In this embodiment, the to-be-detected image is an image of the to-be-detected fabric taken under normal lighting conditions. The electronic device may include a camera and capture the to-be-detected fabric through the camera to obtain the to-be-detected image. The electronic device may also be connected to a photographic device such as an industrial camera and receive the to-be-detected image sent by the photographic device. Alternatively, the electronic device may also receive the to-be-detected image uploaded by the user.

[0093] Step 202, input the to-be-detected image into a trained fabric detection model, and use the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image.

[0094] In this embodiment, a trained fabric detection model is configured on the electronic device. The trained fabric detection can divide a preset number of to-be-detected image blocks on the to-be-detected image. The size of the to-be-detected image block is related to the size of the texture, background pattern, etc. of the to-be-detected fabric. Generally, the smaller the texture or background pattern, the smaller the scale of the divided to-be-detected image blocks, so as to accurately detect defective fabrics subsequently.

[0095] As an optional implementation manner, the trained image prediction network further includes a preset image segmentation network. The output of the preset image segmentation network is connected to the input of the trained image prediction network, and refines "using the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image" in step 202, and the refinement includes step 2021.

[0096] Step 2021, perform a convolution operation on the to-be-detected image using the preset image segmentation network to obtain a preset number of to-be-detected image blocks.

[0097] In this embodiment, the preset image segmentation network may be a single-layer convolution network, perform a convolution operation on the to-be-detected image, and obtain a preset number of to-be-detected image blocks. The preset number can be determined according to the size of the to-be-detected fabric and the size of the texture or pattern of the to-be-detected fabric. Exemplarily, a schematic diagram of dividing to-be-detected image blocks on the to-be-detected image after being divided by the preset image segmentation network is as Figure 3 shown. In Figure 3 , the preset image segmentation network divides the to-be-detected image into 64 image blocks of 8×8.

[0098] The fabric quality detection method provided in this embodiment performs a convolution operation on the image to be detected by using a preset image segmentation network, and obtains a preset number of image blocks to be detected. Since the preset image segmentation network can quickly divide a preset number of image blocks to be detected on the image to be detected, the efficiency of fabric quality detection can be improved.

[0099] Step 203: Input the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the third predicted image block of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image.

[0100] In this embodiment, the prediction unit is determined according to the image blocks to be detected on the image to be detected and the first preset direction. The prediction unit includes a first image block to be detected, a second image block to be detected, and a third image block to be detected that are adjacent to each other in sequence. Since the fabric to be detected is a fabric with regular textures or patterns, the trained image prediction network can predict the third image block to be detected according to the correlation between the first image block to be detected and the second image block to be detected.

[0101] It can be understood that due to the existence of edges in the image to be detected, the number of the third predicted image blocks will be slightly less than the number of the third image blocks to be detected. Exemplarily, the image to be detected is divided into 64 image blocks to be detected in an 8×8 format. The image blocks to be detected are numbered in the order from left to right and from top to bottom. If the first preset direction is from left to right, for the image blocks to be detected in the first row, the image blocks to be detected numbered 1, 2, and 3 form a prediction unit, the image blocks to be detected numbered 2, 3, and 4 form a prediction unit, and so on. The image blocks to be detected numbered 6, 7, and 8 form a preset unit. There are 6 prediction units in the first row, and there are 48 prediction units in the image to be detected, and a total of 48 third predicted image blocks can be predicted. The two leftmost image blocks to be detected in each row do not have corresponding predicted image blocks to be detected. For this situation, in the actual application process of the method in this embodiment, the image to be detected is often divided into a relatively large number of image blocks to be detected. Only the two image blocks to be detected located at the edges of each row are lost, which will not affect the overall result. Moreover, for the image blocks to be detected in each prediction unit, whether the predicted third predicted image block is similar to the third image block to be detected can reflect whether there are defects in the three image blocks to be detected in this prediction unit.

[0102] Optionally, for a to-be-detected image block that has no corresponding to-be-detected predicted image block in the first preset direction. For example, for the two to-be-detected image blocks numbered 1 and 2 in the above example, when inputting the third to-be-detected image block and the second to-be-detected image block in the prediction unit into the trained image prediction network, the trained image prediction network is used to predict and output the first to-be-detected predicted image block in the prediction unit. Specifically, for the to-be-detected image block numbered 1, the to-be-detected image blocks numbered 2 and 3 can be input into the trained image prediction network, and the trained image prediction network is used to output the to-be-detected predicted image block corresponding to the to-be-detected image block numbered 1.

[0103] In this embodiment, the trained image prediction network is trained using qualified image blocks of at least one qualified fabric image. A qualified fabric image is an image of a qualified fabric without defects. A qualified image block is an image block divided on the qualified fabric image.

[0104] When both the first to-be-detected image block and the second to-be-detected image block in the prediction unit are image blocks without defects, the trained image prediction network can predict a third to-be-detected predicted image block without defects. When the third to-be-detected image block in the prediction unit is an image block without defects, the third to-be-detected predicted image block is similar to the third to-be-detected image block. When the third to-be-detected image block is an image block with defects, the third to-be-detected predicted image block is not similar to the third to-be-detected image block.

[0105] When any one of the first to-be-detected image block and the second to-be-detected image block has defects, the trained image prediction network cannot predict a third to-be-detected predicted image block without defects. At this time, regardless of whether the third to-be-detected image block is an image block with defects or an image block to be detected without defects, the predicted third to-be-detected predicted image block is not similar to the third to-be-detected image block.

[0106] Step 204: Use the trained fabric detection model to determine the first similarity rate between each third to-be-detected predicted image block and its corresponding third to-be-detected image block.

[0107] In this embodiment, the trained fabric detection model may include a trained image comparison network. The trained image comparison network can be trained using a public dataset and is used to obtain the similarity rate between any two images.

[0108] Step 205: Determine the quality detection result corresponding to the to-be-detected fabric according to each first similarity rate.

[0109] As an optional implementation manner, step 205 includes the following steps:

[0110] Step 2051: If it is determined that all the first similarity rates are greater than the preset similarity rate threshold, then determine that the quality inspection result corresponding to the fabric to be inspected is qualified.

[0111] Step 2052: If it is determined that there is any first similarity rate less than the preset similarity rate threshold, then determine that the quality inspection result corresponding to the fabric to be inspected is unqualified.

[0112] In this embodiment, the preset similarity rate threshold can be an empirical value, which is used to reflect whether the third predicted image block to be inspected predicted by the trained image prediction network is similar to the third image block to be inspected in the image to be inspected. Fabrics with different textures or patterns can correspond to different preset similarity rate thresholds. If the first similarity rate between the predicted image block to be inspected and its corresponding image block to be inspected is greater than the preset similarity rate threshold, then the predicted image block to be inspected is similar to its corresponding image block to be inspected. On the contrary, if the first similarity rate is less than the preset similarity rate threshold, then the predicted image block to be inspected is not similar to its corresponding image block to be inspected.

[0113] Here, the predicted image block to be inspected is trained based on the qualified image blocks of at least one fabric qualified image. Only when both the first image block to be inspected and the second image block to be inspected are flawless image blocks can a flawless third predicted image block to be inspected be predicted. Therefore, only when the first, second, and third image blocks to be inspected of the prediction unit are all flawless image blocks, the third predicted image block to be inspected is similar to the third image block to be inspected. Therefore, when all the first similarity rates are greater than the preset similarity rate threshold, determine that the quality inspection result corresponding to the fabric to be inspected is qualified. When there is any first similarity rate less than the preset similarity rate threshold, determine that the quality inspection result corresponding to the fabric to be inspected is unqualified, and the quality inspection result of the fabric to be inspected can be quickly determined.

[0114] The fabric quality detection method provided in this embodiment includes obtaining a to-be-detected image of the to-be-detected fabric; inputting the to-be-detected image into a trained fabric detection model, and using the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image; inputting the first to-be-detected image block and the second to-be-detected image block in each prediction unit into a trained image prediction network, and using the trained image prediction network to predict and output a third to-be-detected predicted image block of the third to-be-detected image block in each prediction unit; the first, second, and third to-be-detected image blocks in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image; using the trained fabric detection model to determine a first similarity rate between each third to-be-detected predicted image block and its corresponding third to-be-detected image block; determining a quality detection result corresponding to the to-be-detected fabric according to each first similarity rate. Since the to-be-detected fabric has regular textures or patterns, the trained image prediction network can be used to predict the third to-be-detected image block in the preset unit according to the correlation between the first and second to-be-detected image blocks in the prediction unit. And the trained image prediction network is trained according to the qualified image blocks of the fabric qualified image. Therefore, the trained image prediction network can only predict a flawless third to-be-detected predicted image block when both the first and second to-be-detected image blocks are flawless image blocks. Once there is a flaw in any one of the first and second to-be-detected image blocks, the trained image prediction network cannot predict a flawless third to-be-detected image block. Furthermore, only when the first, second, and third to-be-detected image blocks are all flawless, the third to-be-detected predicted image block predicted by the trained image prediction network will be similar to the third to-be-detected image block. In this way, once there are low-frequency or newly emerged flaws in the to-be-detected fabric, the third to-be-detected predicted image block will not be similar to the third to-be-detected image block. Furthermore, according to the first similarity rate between each third to-be-detected predicted image block and its corresponding third to-be-detected image block in the to-be-detected image, it can be determined whether there are flaws in the to-be-detected fabric. Therefore, the solution of this application will not miss any low-frequency flaws and new flaws in the to-be-detected fabric, and can determine a more accurate quality detection result corresponding to the to-be-detected fabric. In summary, the technical solution of this application can determine a more accurate fabric quality detection result and improve the detection accuracy of the fabric.

[0115] Embodiment 2

[0116] Figure 4 It is a schematic flowchart of the fabric quality detection method provided in Embodiment 2 of this application. As Figure 4 shown, the fabric quality detection method provided in this embodiment further includes steps 301 to 303 on the basis of Embodiment 1.

[0117] Step 301: Obtain qualified image blocks of at least one qualified fabric image.

[0118] In this embodiment, an electronic device can capture multiple flawless fabric images under different lighting conditions to obtain multiple qualified fabric images. Alternatively, at least one qualified fabric image can be pre-stored in the electronic device, and then the electronic device uses a preset image segmentation network to divide a preset number of image blocks to be detected on each qualified fabric image. It is also possible to directly pre-store at least one qualified fabric image with the image blocks to be detected already divided in the electronic device. This embodiment does not make any limitations in this regard.

[0119] Step 302: Input the first qualified image block and the second qualified image block in each prediction unit into the image prediction network to be trained, and use the image prediction network to be trained to predict and output the third qualified prediction image block of the third qualified image block in each prediction unit; the first, second, and third qualified image blocks in the prediction unit are adjacent to each other in the first preset direction.

[0120] Step 303: Train the image prediction network to be trained based on each third qualified prediction image block and each third qualified image block to obtain a trained image prediction network.

[0121] In this embodiment, the parameters of the image prediction network to be trained can be random. After using the image prediction network to be trained to predict and output the third qualified prediction image block of the third qualified image block in each prediction unit, the parameters of the image prediction network to be trained can be adjusted according to whether the qualified similarity rate between each third qualified prediction image block and each third qualified image block is greater than a preset threshold, until the qualified similarity rate between the third qualified prediction image blocks predicted and output by the image prediction network to be trained and the corresponding third qualified image blocks is greater than the preset threshold, and a trained image prediction network is obtained.

[0122] The fabric quality detection method provided in this embodiment obtains qualified image blocks of at least one qualified fabric image; inputs the first qualified image block and the second qualified image block in each prediction unit into the image prediction network to be trained, and uses the image prediction network to be trained to predict and output the third qualified prediction image block of the third qualified image block in each prediction unit; the first, second, and third qualified image blocks in the prediction unit are adjacent to each other in the first preset direction; trains the image prediction network to be trained based on each third qualified prediction image block and each third qualified image block to obtain a trained image prediction network. Since the image prediction network to be trained is trained through the qualified image blocks, the qualified similarity rate between the third qualified prediction image blocks predicted by the trained image prediction network and the third qualified image blocks is greater than the preset threshold. Therefore, it is possible to determine whether there are defective image blocks to be detected in each prediction unit based on the first similarity rate between the third image blocks to be detected predicted by the trained image prediction network and the third image blocks to be detected.

[0123] Example 3

[0124] Figure 5 is a schematic flowchart of the fabric quality detection method provided in Example 3 of the present application. Figure 6 is a schematic structural diagram of the trained image prediction network provided in Example 3 of the present application. As Figure 5 shown, for the fabric quality detection method provided in this embodiment, based on any of the above embodiments, the trained image prediction network includes a first encoding network, a second encoding network, and a decoding network. The structures and parameters of the first encoding network and the second encoding network are the same, and step 203 is refined. Then, step 203 is refined to include the following steps:

[0125] For any prediction unit, perform the following operations:

[0126] Step 401, input the first image block to be detected into the first encoding network, input the second image block to be detected into the second encoding network, extract the first encoding feature of the first image block to be detected by using the first encoding network, and extract the second encoding features of the second image blocks to be detected by using the second encoding network;

[0127] Step 402, use the decoding network to generate a third predicted image block to be detected according to the first encoding feature and the second encoding feature.

[0128] In this embodiment, in the prediction unit, there is an order relationship among the first image block to be detected, the second image block to be detected, and the third image block to be detected. "First", "second", and "third" are used to identify the adjacent order of the three image blocks to be detected in the prediction unit in the first preset direction.

[0129] In the trained image prediction network, there is no difference between the first encoding module and the second encoding module. "First" and "second" in the first encoding module and the second encoding module are for distinguishing and facilitating the description of the two encoding modules in the trained image prediction network, and should not be understood as indicating or implying importance or order.

[0130] In this embodiment, the encoding feature may be a color feature, a texture feature, a shape feature, etc. in the image block to be detected. Since the fabric to be detected is a fabric with regular texture or pattern, there is a correlation between two adjacent image blocks to be detected in the fabric to be detected. Furthermore, after the first encoding module and the second encoding module extract the first encoding feature and the second encoding feature, the decoding module can find the correlation between the adjacent image blocks to be detected according to the first encoding feature and the second encoding feature, and predict the third image block to be detected in the prediction unit according to the correlation between the adjacent image blocks to be detected to obtain the third predicted image block to be detected.

[0131] The fabric quality detection method provided in this embodiment, the trained image prediction network includes a first encoding network, a second encoding network, and a decoding network; the structures and parameters of the first encoding network and the second encoding network are the same; for any prediction unit, the following operations are performed: input the first image block to be detected into the first encoding network, input the second image block to be detected into the second encoding network, use the first encoding network to extract the first encoding feature of the first image block to be detected, and use the second encoding network to extract the second encoding features of each second image block to be detected; use the decoding network to generate a third predicted image block to be detected according to the first encoding feature and the second encoding feature. Since the first and second encoding networks with the same network structure and parameters are used to extract the first encoding feature and the second encoding feature of the first and second image blocks to be detected respectively, and then the third predicted image block to be detected is predicted according to the first encoding feature and the second encoding feature, therefore, when both the first image block to be detected and the second image block to be detected are flawless, a flawless third predicted image block to be detected can be predicted, so that the subsequent similarity rate between the third image block to be detected and the third predicted image block to be detected can be used to determine whether there is a defective image block to be detected in this prediction unit.

[0132] As an optional implementation manner, on the basis of Embodiment 3, both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit; the decoding network includes a linear mapping unit and at least one upsampling unit, and each upsampling unit is sequentially connected to the linear mapping unit, and the number of upsampling units is equal to the number of downsampling units in any one encoding network; and the step of "using the first encoding network to extract the first encoding feature of the first image block to be detected, and using the second encoding network to extract the second encoding features of each second image block to be detected" in step 401, that is, "using the encoding network to extract the encoding feature of the image block to be detected" is refined, and the refinement includes steps 4011 to 4013.

[0133] Step 4011, use the linear embedding unit to perform dimensional transformation and feature transformation on the input image block to be detected, and input the obtained feature map into the next unit and the linear mapping unit in the decoding network.

[0134] Step 4012, use each downsampling unit located in the middle of the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the corresponding upsampling unit in the decoding network.

[0135] Step 4013, use the downsampling unit located at the end of the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the upsampling unit located at the beginning of the decoding network.

[0136] In this embodiment, both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit. The decoding network includes a linear mapping unit and at least one upsampling unit, and each upsampling unit is sequentially connected to the linear mapping unit. The number of upsampling units is equal to the number of downsampling units in any one of the encoding networks.

[0137] Exemplarily, as Figure 6 shown, the trained image prediction network 60 includes a first encoding network 61, a second encoding network 62, and an encoding network 63.

[0138] The first encoding network 61 includes a linear embedding unit 610 and at least one downsampling unit: 611,..., 61n, and the linear embedding unit 610 is sequentially connected to each downsampling unit. Here, n represents the number of downsampling units in the first encoding network.

[0139] The second encoding network 62 includes a linear embedding unit 620 and at least one downsampling unit: 621,..., 62n, and the linear embedding unit 620 is sequentially connected to each downsampling unit. Here, since the structures and parameters of the first encoding network and the second encoding network are the same, n also represents the number of downsampling units in the second encoding network.

[0140] The encoding network 63 includes a linear mapping unit 630 and at least one upsampling unit: 631,..., 63n. Here, n represents the number of upsampling units in the decoding network. Since the number of upsampling units is equal to the number of downsampling units in any one of the encoding networks, n also represents the number of upsampling units in the decoding network.

[0141] The linear embedding unit is used to perform dimensional transformation on the input image block to be detected.

[0142] The upsampling unit is used to upsample the feature map.

[0143] The downsampling unit is used to downsample the feature map.

[0144] The linear mapping unit is used to perform dimensional transformation on the feature map.

[0145] Exemplarily, the dimension of the image to be detected is H×W×C, where H×W represents the resolution of the image to be detected, H represents the number of pixels in the height direction, W represents the number of pixels in the width direction, and C represents the number of color channels of the image to be detected. For example, the number of channels of a color image to be detected encoded in the RGB format is 3, and the number of channels of a black-and-white image to be detected is 1.

[0146] If the color image to be detected is divided into 16 image blocks to be detected of 4×4, the image dimension of each image block to be detected is (H / 4)×(W / 4)×3. Then the linear embedding unit can change the image resolution of the image block to be detected to (H / 4)×(W / 4)×1, and can perform feature transformation on the image block to be detected with the changed dimension to obtain the feature map of the image block to be detected. At the same time, the linear embedding unit inputs the obtained feature map into the next unit and the linear mapping unit in the decoding network.

[0147] Here, the next unit refers to the upsampling unit in the encoding network after the linear embedding unit. If the number of downsampling units in the encoding network is one, the downsampling unit after the linear embedding unit is also the downsampling unit at the end of the encoding network.

[0148] For example Figure 6 As shown in, the linear embedding unit 610 inputs the obtained feature map into the downsampling unit 611, and the linear embedding unit 620 inputs the obtained feature map into the downsampling unit 612 and the linear mapping unit 630 of the decoding network 63.

[0149] In this embodiment, the dimension transformation in the linear embedding unit can be implemented by a linear embedding layer (abbreviated as LE layer), and the feature transformation can be implemented by a feature transformation module (abbreviated as ST block).

[0150] In this embodiment, the downsampling unit in the middle of the encoding network refers to the downsampling unit between the linear embedding unit and the downsampling unit at the end of the encoding network. Each downsampling unit in the middle of the encoding network performs downsampling and feature transformation on the feature map input by the previous downsampling unit or linear embedding unit, and inputs the obtained feature map into the next downsampling unit and the corresponding upsampling unit in the decoding network. It can be understood that if the number of downsampling units in the encoding network is 1, there is no downsampling unit in the middle of the encoding network.

[0151] Exemplarily, as Figure 6 shown, the downsampling unit in the middle between the linear embedding unit 610 and the downsampling unit 61n at the end of the first encoding network is the downsampling unit in the middle of the first encoding network, and the downsampling unit in the middle between the linear embedding unit 620 and the downsampling unit 62n at the end of the second encoding network is the downsampling unit in the middle of the second encoding network.

[0152] In this embodiment, the downsampling unit at the end of the encoding network refers to the last unit in the encoding network, and the output feature map is used to input into the decoding network, specifically, input into the upsampling unit at the beginning of the decoding network. Exemplarily, for exampleFigure 6 As shown, the downsampling unit 61n is a downsampling unit located at the end of the first encoding network, and the feature map output by the downsampling unit 61n is input into the upsampling unit 631 at the beginning of the decoding network 63. The downsampling unit 62n is a downsampling unit located at the end of the second encoding network, and the feature map output by the downsampling unit 62n is input into the upsampling unit 631 at the beginning of the decoding network 63.

[0153] In this embodiment, the layer number of the upsampling unit corresponding to the downsampling unit in the decoding network is opposite to the layer number of the downsampling unit in the encoding network. Exemplarily, when the upsampling unit is the second layer in the encoding network, its corresponding upsampling unit is the second-to-last layer in the cross-section network. Exemplarily, as Figure 6 shown, the downsampling unit 631 is the second layer in the first encoding network, and its corresponding upsampling unit is the upsampling unit 63n, which is the second-to-last layer in the decoding network. The downsampling unit 632 is the second layer in the second encoding network, and its corresponding upsampling unit is the upsampling unit 632n, which is the second-to-last layer in the decoding network.

[0154] In this embodiment, the downsampling unit may be composed of a sequentially connected Patch Merging layer and a Swin Transform block layer. Patch Merging is a downsampling operation. Exemplarily, the image resolution can be changed from (H / 4)*(W / 4)*C to (H / 8)*(W / 8)*2C.

[0155] In this embodiment, the feature maps output by each unit in the encoding network are the encoded features of the image blocks to be detected extracted by the encoding network.

[0156] The fabric quality detection method provided in this embodiment, where both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit; the decoding network includes a linear mapping unit and at least one upsampling unit, and each upsampling unit is sequentially connected to the linear mapping unit, and the number of upsampling units is equal to the number of downsampling units in any one of the encoding networks; the linear embedding unit is used to perform dimensionality transformation and feature transformation on the input image block to be detected, and the obtained feature map is input into the next unit and the linear mapping unit in the decoding network; each downsampling unit located in the middle of the encoding network is used to perform downsampling and feature transformation on the input feature map, and the obtained feature map is input into the next unit and the corresponding upsampling unit in the decoding network; the downsampling unit located at the end of the encoding network is used to perform downsampling and feature transformation on the input feature map, and the obtained feature map is input into the upsampling unit located at the beginning of the decoding network. Since the encoding network uses a linear embedding unit and at least one downsampling unit to perform dimensionality transformation and multiple feature transformations on the image block to be detected, and obtains the feature map of the image block to be detected, that is, the encoded feature of the image block to be detected, therefore, more accurate features of the image block to be detected can be extracted, thus laying a foundation for accurately predicting the third image block to be detected subsequently.

[0157] As an optional implementation manner, based on any one of the above embodiments, the decoding network further includes a multi-layer perceptron, and the step 402 of "using the decoding network to generate the third image block to be detected according to the first encoded feature and the second encoded feature" is refined, and the refinement includes steps 4021 to 4024.

[0158] Step 4021, use the upsampling unit located at the beginning of the decoding network to perform upsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the multi-layer perceptron.

[0159] Step 4022, use the upsampling unit located in the middle of the decoding network to perform downsampling and feature transformation on the feature map input by the previous unit and the feature map input by the corresponding downsampling unit in the encoding network, and input the obtained feature map into the next unit and the multi-layer perceptron.

[0160] Step 4023, use the linear mapping unit to perform dimensionality transformation and feature transformation on the feature map input by the previous unit and the feature map input by the linear embedding unit, and input the output feature map into the multi-layer perceptron.

[0161] Step 4024, use the multi-layer perceptron to generate the image block to be detected according to the input multiple feature maps.

[0162] In this embodiment, the decoding network further includes a multilayer perceptron (MLP for short). The MLP is connected to the linear mapping unit and each upsampling unit in the decoding network. The MLP is used to fuse the feature maps output by each unit in the decoding network to form the final predicted image block to be detected.

[0163] Exemplarily, as Figure 6 shown, the feature maps output by the linear mapping unit 630 and the feature maps output by each upsampling unit 631 to 63n are input into the MLP 64.

[0164] In this embodiment, the upsampling unit at the head end of the decoding network is the first layer in the decoding network. Its input end is connected to the output ends of the first encoding network and the second encoding network. The feature maps output by the first encoding network and the second encoding network serve as the input feature maps of the upsampling unit at the head end of the decoding network; its output end is connected to the input end of the next unit in the decoding network and the input end of the MLP. Here, the next unit refers to the upsampling unit or the linear mapping unit in the decoding network that comes after the upsampling unit at the head end of the decoding network.

[0165] Exemplarily, as Figure 6 shown, the input end of the upsampling unit 631 at the head end of the decoding network 63 is connected to the output ends of the first encoding network 61 and the second encoding network 62. The outputs of the downsampling unit 61n and the downsampling unit 62n serve as the input of the upsampling unit 631. When the number of upsampling units in the encoding network is one, the output of the upsampling unit 631 serves as the input of the linear mapping unit 630 and the MLP 64. When the number of upsampling units in the encoding network is multiple, the input of the upsampling unit 631 serves as the input of the next upsampling unit connected to the upsampling unit 631 and the MLP 64.

[0166] In this embodiment, the upsampling unit can perform an upsampling operation on the input feature map, doubling the number of pixels in both the height direction and the width direction of the feature map, and at the same time, reducing the number of channels to half of the original. Among them, the upsampling unit may include a Patch Expanding layer (PE layer for short) and a Swin Transformer layer (ST layer for short) connected in sequence. Among them, Patch Expanding is an upsampling operation that can double the number of pixels in the height direction H and the width direction W of the feature map, while reducing the number of channels C to half of the original.

[0167] In this embodiment, the dimensionality transformation in the linear mapping unit can be implemented by a Linear Projection layer (abbreviated as LP layer), and the feature transformation can be implemented by a Swin Transform block (abbreviated as ST block). Among them, the Linear Projection layer can downsample the dimensionality of the input feature map from 3C to C.

[0168] The fabric quality detection method provided in this embodiment further includes a multi-layer perceptron through the decoding network; the upsampling unit located at the head of the decoding network performs upsampling and feature transformation on the input feature map, and inputs the obtained feature map into the next unit and the multi-layer perceptron; the upsampling unit located in the middle of the decoding network performs downsampling and feature transformation on the feature map input by the previous unit and the feature map input by the corresponding downsampling unit in the encoding network, and inputs the obtained feature map into the next unit and the multi-layer perceptron; the linear mapping unit performs dimensionality transformation and feature transformation on the feature map input by the previous unit and the feature map input by the linear embedding unit, and inputs the output feature map into the multi-layer perceptron; the multi-layer perceptron generates the to-be-detected prediction image block according to the input multiple feature maps. Since the decoding network performs dimensionality transformation and multi-feature transformation on the feature maps output by the two encoding networks through at least one upsampling unit and a linear mapping unit, learns the mutual relationship between the features extracted by the two encoders, and has stronger adaptability to texture changes, and finally inputs the output feature map into the multi-layer perceptron, and the multi-layer perceptron fuses the features output by each unit of the decoding network. Therefore, it can make the trained image prediction network have stronger adaptability to texture changes, and then predict a more accurate to-be-detected prediction image block.

[0169] Embodiment 4

[0170] Figure 7 It is a schematic structural diagram of the first preset image comparison network provided according to Embodiment 4 of the present application. The fabric quality detection method provided in this embodiment, on the basis of any of the above embodiments, the trained fabric detection model further includes a preset image comparison network, the input of the preset image comparison network is connected to the output of the trained image prediction network, and step 204 is refined, and step 204 is refined to include step 2041.

[0171] Step 2041, each third to-be-detected image block and its corresponding third to-be-detected prediction image block are input into the preset image comparison network, and the preset image comparison network outputs the first similarity rate between each third to-be-detected image block and its corresponding third to-be-detected prediction image block.

[0172] In this embodiment, the third image block to be detected and its corresponding third predicted image block to be detected are input into a preset image comparison network. The preset image comparison network may include a feature extraction network and a decision network. The feature extraction network can extract the original image features of the third image block to be detected and the predicted image features of the third predicted image block to be detected respectively. The decision network can fuse the original image features and the predicted image features and output the first similarity rate between the third image block to be detected and its corresponding third predicted image block to be detected.

[0173] Exemplarily, the structure of the preset image comparison network can be as Figure 7 shown in the first preset image comparison network in, including a first feature extraction network 71, a second feature extraction network 72, and a decision network 73.

[0174] The first feature extraction network 71 and the second feature extraction network 71 have the same network structure. The first feature extraction network 71 includes 3 convolutional layers: convolutional layer 711, convolutional layer 713, convolutional layer 715, and 3 pooling layers: pooling layer 712, 714. The second feature extraction network 72 includes 3 convolutional layers: convolutional layer 721, convolutional layer 723, convolutional layer 725, and 3 pooling layers: pooling layer 722, 724. Among them, convolutional layer 711 and convolutional layer 721 may have different weights, convolutional layer 713 and convolutional layer 723 may have different weights, and convolutional layer 715 and convolutional layer 725 may share weights. The pooling layer may include a maxpooling operation.

[0175] Among them, each convolutional layer includes three operations: conv, BN, and Relu. Conv is a convolutional operation, BN is short for batchnormalization, which is a normalization operation, and Relu is an activation operation.

[0176] The decision network 73 includes a feature fusion (Concat) layer 731 and 2 fully connected (Fullyconnection) layers connected in sequence: fully connected layer 732 and fully connected layer 733.

[0177] The output end of the feature fusion layer 731 is connected to the inputs of the fully connected layer 732 and the fully connected layer 733. The feature fusion layer 731 can use the Concat operation to fuse the original image features and the predicted image features extracted by the first feature extraction network 71 and the second feature extraction network 72 to obtain fused features.

[0178] The fully connected layer 732 and the fully connected layer 733 can perform downsampling operations on the fused features fused by the feature fusion layer 731 and output the first similarity rate.

[0179] The fabric quality detection method provided in this embodiment further includes a preset image comparison network through the trained fabric detection model. The input of the preset image comparison network is connected to the output of the trained image prediction network. Each third image block to be detected and its corresponding third predicted image block to be detected are input into the preset image comparison network, and the preset image comparison network outputs the first similarity rate between each third image block to be detected and its corresponding third predicted image block to be detected. Since the preset image comparison network outputs the first similarity rate, an accurate first similarity rate can be obtained quickly.

[0180] Embodiment 5

[0181] Figure 8 is a schematic flowchart of the fabric quality detection method provided in Embodiment 5 of the present application. Figure 9 is a schematic structural diagram of the second preset image comparison network provided in Embodiment 5 of the present application. As Figure 8 shown, based on any of the above embodiments, for the fabric quality detection method provided in this embodiment, if it is determined that the quality detection result corresponding to the fabric to be detected is unqualified, it further includes steps 501 to 505.

[0182] Step 501: Input each third image block to be detected of each prediction unit and each third image block to be detected into the trained image prediction network, and use the trained image prediction network to predict and output the first predicted image block corresponding to the first image block to be detected in each prediction unit. The third, second, and first image blocks to be detected in the prediction unit are adjacent in sequence in the second preset direction. The second preset direction is opposite to the first preset direction.

[0183] In this embodiment, the second preset direction is opposite to the first preset direction. For example, if the first preset direction is from left to right, then the second preset direction is from right to left; if the first preset direction is from top to bottom, then the second preset direction is from bottom to top. The first, second, and third image blocks to be detected in each prediction unit are the first, second, and third image blocks to be detected in the first direction.

[0184] Since the image blocks to be detected are predicted from one direction, when the similarity rate between the third image block to be detected and its corresponding third predicted image block to be detected is less than the preset threshold, it is impossible to determine whether there are defects on the third image block to be detected or on the first and / or second image blocks to be detected. Therefore, by predicting each third image block to be detected and each first image block to be detected from the opposite first preset direction and second preset direction respectively, the area with defects can be determined according to the prediction, avoiding the situation where the area with defects predicted when predicting from only one direction is larger than the actual area with defects.

[0185] Step 502: Determine the second similarity rate between each first to-be-detected predicted image block and its corresponding first to-be-detected image block.

[0186] In this embodiment, the second similarity rate can be determined by the same method as the first similarity rate.

[0187] Step 503: Determine at least one third to-be-detected image block with a corresponding first similarity rate less than the preset similarity rate threshold as a first difference image block.

[0188] Step 504: Determine at least one first to-be-detected image block with a corresponding second similarity rate less than the preset similarity rate threshold as a second difference image block.

[0189] In this embodiment, the first difference image block is a to-be-detected image block where the third to-be-detected image block and the third to-be-detected predicted image block are not similar when predicting from the first preset direction, and there may be defects on these to-be-detected image blocks.

[0190] In this embodiment, the second difference image block is a to-be-detected image block where the first to-be-detected image block and the first to-be-detected predicted image block are not similar when predicting from the second preset direction, and there may be defects on these to-be-detected image blocks.

[0191] It can be understood that in the to-be-detected image, except for the first two to-be-detected image blocks in the first preset direction, there are corresponding third to-be-detected predicted image blocks for other to-be-detected image blocks. Except for the first two to-be-detected image blocks in the second preset direction, there are corresponding first to-be-detected predicted image blocks for other to-be-detected image blocks. Therefore, except for the first two to-be-detected image blocks in the first preset direction and the first two to-be-detected image blocks in the second preset direction, there are corresponding first to-be-detected predicted image blocks and third to-be-detected predicted image blocks for other to-be-detected image blocks.

[0192] Step 505: Determine the area where the to-be-detected image block that is determined to be a first difference image block and a second difference image block in the to-be-detected image as a defect area.

[0193] In this embodiment, when the image block to be detected is determined to be the first differential image block and the second differential image block, it can be determined that the corresponding first similarity rate of the image block to be detected is less than the preset similarity rate threshold, and the corresponding second similarity rate is less than the preset similarity rate threshold. Therefore, it can be determined that there are defects on the image block to be detected, and the situation where the third predicted image block to be detected of the image block to be detected is not similar to it caused by the defects on the first and second image blocks to be detected in the prediction unit where the image block to be detected is located, and the situation where the first predicted image block to be detected of the image block to be detected is not similar to it caused by the defects on the third and second image blocks to be detected in the prediction unit where the image block to be detected is located can be excluded. Here, not being similar means that the similarity rate is less than the preset similarity rate threshold.

[0194] Here, since the defects in the fabric generally appear continuously, the size of the image block to be detected is determined according to the texture and pattern size of the fabric. Among five adjacent image blocks to be detected A, B, C, D, and E, generally, there will not be a situation where there is an image block to be detected without defects between two image blocks to be detected with defects. For example, B and D are image blocks to be detected with defects, and C is an image block without defects. Even if there is a situation where there is an image block to be detected without defects between two image blocks to be detected with defects, the defect area determined by the method in this embodiment will not have the problem of edge expansion at the edge and is relatively accurate.

[0195] In this embodiment, the defect area is the position of the defect in the image to be detected. After determining the defect area, the defect area can be output, and the staff can observe the defects in the image block to be detected according to the defect area to determine the subsequent processing method. For example, the area with defects can be cut off, or the defects can be repaired.

[0196] The fabric quality detection method provided in this embodiment, if it is determined that the quality detection result corresponding to the fabric to be detected is unqualified, then input the third image blocks to be detected of each prediction unit and each third image block to be detected into the trained image prediction network, and use the trained image prediction network to predict and output the first predicted image blocks corresponding to the first image blocks to be detected in each prediction unit; the third, second, and first image blocks to be detected in the prediction unit are adjacent in sequence in the second preset direction; the second preset direction is opposite to the first preset direction; determine the second similarity rate between each first predicted image block and its corresponding first image block to be detected; determine at least one third image block to be detected with a corresponding first similarity rate less than the preset similarity rate threshold as the first difference image block; determine at least one first image block to be detected with a corresponding second similarity rate less than the preset similarity rate threshold as the second difference image block; determine the area where the image block to be detected, which is determined to be the first difference image block and the second difference image block, is located in the image to be detected as the defect area. Since the first difference image block and the second difference image block are determined respectively in two opposite preset directions, and then the image block to be detected that is determined to be the first difference image block and the second difference image block is determined as the defect area, therefore, it is possible to avoid the expansion of the defect area when determining the defect area from only one preset direction and determine the accurate defect area.

[0197] As an optional implementation manner, after step 504, steps 601 to 603 are further included.

[0198] Step 601, input each first difference image block and its corresponding third predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the first difference image of the image to be detected.

[0199] In this embodiment, after determining the first difference image blocks with differences, each difference image block and its corresponding third image block to be detected can also be input into the preset image comparison network, and the preset image comparison network outputs the first difference image according to this. The first difference image includes the differences between each first difference image block and its corresponding third image block to be detected. For example, if there is a crack in the first difference image block and there is no crack in the third image block to be detected, then the first difference image includes the crack segmented from the first difference image block.

[0200] Step 602, input each second difference image block and its corresponding first predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the second difference image of the image to be detected.

[0201] In this embodiment, the second difference image includes the differences between each second difference image block and its corresponding first image block to be detected.

[0202] In this embodiment, the structure of the preset image comparison network may be the second preset image comparison network as shown in Figure 9 . The second preset image comparison network includes a first feature extraction network 71, a second feature extraction network 72, and a decision network 93. The first feature extraction network 71 and the second feature extraction network 72 are the same as the first feature extraction network 71 and the second feature extraction network 72 in the first preset image comparison network shown in Figure 7 , which will not be elaborated here. In the decision network 93, it includes a feature fusion (Concat) layer 731 and two fully connected layers connected in sequence: a fully connected layer 732 and a fully connected layer 733. The feature fusion layer 731, the fully connected layer 732, and the fully connected layer 733 are the same as the feature fusion layer 731, the fully connected layer 732, and the fully connected layer 733 in the first preset image comparison network shown in Figure 7 , which will not be elaborated here. The decision network 93 further includes a convolutional layer 932 and a convolutional layer 933 connected in sequence. The input end of the convolutional layer 932 is connected to the output end of the feature fusion layer 731. The convolutional layer 932 includes three operations: conv, BN, and Relu. The convolutional layer 933 includes three operations: conv, BN, and sigmoid. Among them, Relu is an activation operation using the Relu activation function, and sigmoid is an activation operation using the sigmoid activation function. While the fully connected layers 732 and 733 perform downsampling operations on the fused features after the feature fusion layer 731 fuses and output the first similarity rate, the decision network 93 performs a convolutional transformation on the fused features after the feature fusion layer 931 fuses through the convolutional layer 932 and the convolutional layer 933 to obtain the difference image between the image block to be detected and the predicted image block to be detected.

[0203] Step 603 determines the intersection of the first difference image and the second difference image as the defect shape.

[0204] In this embodiment, after comparing the similarities between the first difference image and the second difference image, that is, the intersection, the shape of the defect in the image to be detected can be determined, that is, the shape of the defect in the fabric to be detected.

[0205] The fabric quality detection method provided in this embodiment inputs each first difference image block and its corresponding third image block to be detected and predicted into a preset image comparison network, and uses the preset image comparison network to output the first difference image of the image to be detected; inputs each second difference image block and its corresponding first image block to be detected and predicted into the preset image comparison network, and uses the preset image comparison network to output the second difference image of the image to be detected; determines the intersection of the first difference image and the second difference image as the defect shape. Since the first difference image can reflect the difference between each third image block to be detected and predicted and each third image block to be detected, and the second difference image can reflect the difference between each first image block to be detected and predicted and each first image block to be detected, therefore, the intersection between the first difference image and the second difference image can reflect the difference between each image block to be detected and the qualified image block. Furthermore, determining the intersection of the first difference image and the second difference image as the defect shape can determine the shape of the defect in the image to be detected, helping the staff to quickly locate the defect in the fabric to be detected.

[0206] As an alternative implementation, the quality detection result corresponding to the fabric to be detected can also be determined through the following steps:

[0207] Obtain the image to be detected of the fabric to be detected;

[0208] Input the image to be detected into the trained fabric detection model, and use the trained fabric detection model to divide a preset number of image blocks to be detected on the image to be detected;

[0209] Input the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the third image block to be detected and predicted of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent in sequence in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one fabric qualified image;

[0210] Input the third image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the first image block to be detected and predicted of the first image block to be detected in each prediction unit; the third, second, and first image blocks to be detected in the prediction unit are adjacent in sequence in the second preset direction; the second preset direction is opposite to the first preset direction;

[0211] Use the trained fabric detection model to determine the first similarity rate between each third image block to be detected and predicted and its corresponding third image block to be detected, and the second similarity rate between each first image block to be detected and predicted and its corresponding first image block to be detected;

[0212] Determine the quality inspection result corresponding to the fabric to be inspected according to each first similarity rate and each second similarity rate.

[0213] In this embodiment, it is also possible to perform predictions on each third image block to be inspected and each first image block to be inspected from two opposite first preset directions and second preset directions respectively, and determine the quality inspection result corresponding to the fabric to be inspected according to each first similarity rate and each second similarity rate, which can ensure that there is a corresponding first predicted image block to be inspected or a third predicted image block to be inspected for each image block to be inspected in the image to be inspected.

[0214] In this embodiment, the methods for determining each third predicted image block to be inspected, each first predicted image block to be inspected, each first similarity rate, and each second similarity rate can be the same as those in any of the above embodiments, and will not be elaborated here.

[0215] In this embodiment, when each first similarity rate is greater than the preset similarity rate threshold and each second preset similarity rate is greater than the preset threshold, it is determined that the quality inspection result corresponding to the fabric to be inspected is qualified. When there is any first similarity rate less than the preset similarity rate threshold or any second similarity rate less than the preset similarity rate threshold, it is determined that the quality inspection result corresponding to the fabric to be inspected is unqualified.

[0216] The method provided in this embodiment can determine whether there are defects on each image block to be inspected in the image to be inspected, and further determine a more accurate quality inspection result corresponding to the fabric to be inspected.

[0217] Embodiment Six

[0218] Figure 10 It is a schematic structural diagram of a fabric quality inspection device provided in Embodiment Six of the present application. As Figure 10 shown, the fabric quality inspection device 100 provided in this embodiment includes: an acquisition module 101, a detection module 102, and a first determination module 103.

[0219] The acquisition module 101 is configured to acquire an image to be inspected of the fabric to be inspected.

[0220] The detection module 102 is configured to input the image to be detected into the trained fabric detection model, and use the trained fabric detection model to divide a preset number of image blocks to be detected on the image to be detected; input the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the third predicted image block of the third image block to be detected in each prediction unit; the first, second, and third image blocks to be detected in the prediction unit are adjacent to each other in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one qualified fabric image; use the trained fabric detection model to determine the first similarity rate between each third predicted image block to be detected and its corresponding third image block to be detected.

[0221] The first determination module 103 is configured to determine the detection result according to each first similarity rate.

[0222] As an optional implementation manner, the trained image prediction network further includes a preset image block network, and the output of the preset image block network is connected to the input of the trained image prediction network; the detection module 102 is specifically configured to: perform a convolution operation on the image to be detected by using the preset image block network to obtain a preset number of image blocks to be detected.

[0223] As an optional implementation manner, the fabric quality detection device 100 further includes a training module, and the training module is configured to: obtain the qualified image blocks of at least one qualified fabric image; input the first qualified image block and the second qualified image block in each prediction unit into the image prediction network to be trained, and use the image prediction network to be trained to predict and output the third qualified prediction image block of the third qualified image block in each prediction unit; the first, second, and third qualified image blocks in the prediction unit are adjacent to each other in the first preset direction; train the image prediction network to be trained according to each third qualified prediction image block and each third qualified image block to obtain the trained image prediction network.

[0224] As an optional implementation manner, the trained image prediction network includes a first encoding network, a second encoding network, and a decoding network; the structures and parameters of the first encoding network and the second encoding network are the same; the detection module 102 is specifically further configured to: for any one prediction unit, perform the following operations: input the first image block to be detected into the first encoding network, input the second image block to be detected into the second encoding network, use the first encoding network to extract the first encoding feature of the first image block to be detected, and use the second encoding network to extract the second encoding feature of each second image block to be detected; use the decoding network to generate the third predicted image block to be detected according to the first encoding feature and the second encoding feature.

[0225] As an alternative implementation, both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit; the decoding network includes a linear mapping unit and at least one upsampling unit, and each upsampling unit is sequentially connected to the linear mapping unit, and the number of upsampling units is equal to the number of downsampling units in any one of the encoding networks; the detection module 102 is further specifically configured to: use the linear embedding unit to perform dimensional transformation and feature transformation on the input image block to be detected, and input the obtained feature map into the next unit and the linear mapping unit in the decoding network; use each of the downsampling units located in the middle of the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the corresponding upsampling unit in the decoding network; use the downsampling unit located at the end of the encoding network to perform downsampling and feature transformation on the input feature map, and input the obtained feature map into the upsampling unit located at the beginning of the decoding network.

[0226] As an alternative implementation, the decoding network further includes a multi-layer perceptron, and the detection module 102 is further specifically configured to: use the upsampling unit located at the beginning of the decoding network to perform upsampling and feature transformation on the input feature map, and input the obtained feature map into the next unit and the multi-layer perceptron; use the upsampling units located in the middle of the decoding network to perform downsampling and feature transformation on the feature map input by the previous unit and the feature map input by the corresponding downsampling unit in the encoding network, and input the obtained feature map into the next unit and the multi-layer perceptron; use the linear mapping unit to perform dimensional transformation and feature transformation on the feature map input by the previous unit and the feature map input by the linear embedding unit, and input the output feature map into the multi-layer perceptron; use the multi-layer perceptron to generate the image block to be detected and predicted based on the input multiple feature maps.

[0227] As an alternative implementation, the trained fabric detection model further includes a preset image comparison network, and the input of the preset image comparison network is connected to the output of the trained image prediction network; the detection module 102 is further specifically configured to: input each third image block to be detected and its corresponding third predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the first similarity rate between each third image block to be detected and its corresponding third predicted image block to be detected.

[0228] As an alternative implementation, the first determination module 103 is specifically configured to: if it is determined that each first similarity rate is greater than the preset similarity rate threshold, determine that the quality detection result corresponding to the fabric to be detected is qualified; if it is determined that there is any one first similarity rate less than the preset similarity rate threshold, determine that the quality detection result corresponding to the fabric to be detected is unqualified.

[0229] As an alternative implementation, the fabric quality detection device further includes a second determination module. The second determination module is configured to, if it is determined that the quality detection result corresponding to the fabric to be detected is unqualified, input the third image blocks to be detected of each prediction unit and the third image blocks to be detected into the trained image prediction network, and use the trained image prediction network to predict and output the first predicted image blocks corresponding to the first image blocks to be detected in each prediction unit; the third, second, and first image blocks to be detected in the prediction unit are adjacent to each other in the second preset direction in sequence; the second preset direction is opposite to the first preset direction; determine the second similarity rate between each first predicted image block and its corresponding first image block to be detected; determine at least one third image block to be detected with a corresponding first similarity rate less than the preset similarity rate threshold as the first differential image block; determine at least one first image block to be detected with a corresponding second similarity rate less than the preset similarity rate threshold as the second differential image block; and determine the area where the image block to be detected in the image to be detected, which is determined to be the first differential image block and the second differential image block, is the defect area.

[0230] As an alternative implementation, the fabric quality detection device further includes a third determination module. The third determination module is configured to input each first differential image block and its corresponding third predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the first differential image of the image to be detected; input each second differential image block and its corresponding first predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the second differential image of the image to be detected; and determine the intersection of the first differential image and the second differential image as the defect shape.

[0231] The fabric quality detection device provided in this embodiment can execute the fabric quality detection method provided in any of the above embodiments. The specific implementation manners and principles are similar and will not be elaborated here.

[0232] Embodiment VII

[0233] Figure 11 is a schematic structural diagram of an electronic device according to Embodiment VII of the present application. As Figure 11 shown, the electronic device 110 provided in this embodiment includes a processor 112 and a memory 111 communicatively connected to the processor 112.

[0234] The memory 111 stores computer execution instructions.

[0235] The processor 112 executes the computer execution instructions stored in the memory 111 to implement the fabric quality detection method provided in any of the above embodiments. The specific implementation manners and principles are similar and will not be elaborated here.

[0236] Communication connection between the memory 111 and the processor 112 can be achieved through a bus.

[0237] The memory 111 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk, etc.

[0238] In an exemplary embodiment, the electronic device 110 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components for performing the above method.

[0239] Embodiments of the present application also provide a computer-readable storage medium storing computer-executable instructions, which are used to implement the fabric quality detection method provided in any of the above embodiments when executed by a processor. Exemplarily, the computer-readable storage medium can be read-only memory (ROM), random access memory (RAM), magnetic tape, floppy disk, optical data storage device, etc.

[0240] It should be understood that the above device embodiments are merely illustrative, and the devices of the present application can also be implemented in other ways. For example, the division of modules in the above embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple modules can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0241] In addition, without special description, in each embodiment of the present application, the functional modules can be integrated into one module, or each module can exist physically alone, or two or more modules can be integrated together. The above integrated module can be implemented in the form of hardware or in the form of a software program module.

[0242] It should be understood that the above device embodiments are merely illustrative, and the devices of the present application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0243] In addition, unless otherwise specified, in each embodiment of the present application, each functional unit / module can be integrated into one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above integrated unit / module can be implemented in the form of hardware or in the form of a software program module.

[0244] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0245] Furthermore, it should be noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0246] Those skilled in the art will readily think of other implementation schemes of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include the common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0247] It should be understood that the present application is not limited to the exact structure already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A method for fabric quality inspection, characterized in that, Including: Obtain a to-be-detected image of the to-be-detected fabric; Input the to-be-detected image into a trained fabric detection model, and use the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image; Input the first to-be-detected image block and the second to-be-detected image block in each prediction unit into a trained image prediction network, and use the trained image prediction network to predict and output a third to-be-detected prediction image block of the third to-be-detected image block in each prediction unit; wherein, the prediction unit is determined according to each to-be-detected image block on the to-be-detected image and a first preset direction, and the first, second, and third to-be-detected image blocks in the prediction unit are adjacent in sequence in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to qualified image blocks of at least one qualified fabric image; Use the trained fabric detection model to determine a first similarity rate between each third to-be-detected prediction image block and its corresponding third to-be-detected image block; Determine a quality detection result corresponding to the to-be-detected fabric according to each of the first similarity rates; The trained image prediction network includes a first encoding network, a second encoding network, and a decoding network; the structures and parameters of the first encoding network and the second encoding network are the same; the step of inputting the first to-be-detected image block and the second to-be-detected image block in each prediction unit into the trained image prediction network, and using the trained image prediction network to predict and output a third to-be-detected prediction image block of the third to-be-detected image block in each prediction unit includes: For any one prediction unit, perform the following operations: Input the first to-be-detected image block into the first encoding network, input the second to-be-detected image block into the second encoding network, use the first encoding network to extract a first encoding feature of the first to-be-detected image block, and use the second encoding network to extract a second encoding feature of each second to-be-detected image block; Use the decoding network to generate a third to-be-detected prediction image block according to the first encoding feature and the second encoding feature.

2. The method according to claim 1, characterized in that The trained fabric detection model further includes a preset image block division network, and the output of the preset image block division network is connected to the input of the trained image prediction network; The step of using the trained fabric detection model to divide a preset number of to-be-detected image blocks on the to-be-detected image includes: Perform a convolution operation on the to-be-detected image by using the preset image block division network to obtain a preset number of to-be-detected image blocks.

3. The method according to claim 1, wherein Before inputting the first to-be-detected image block and the second to-be-detected image block in each prediction unit into the trained image prediction network, it further includes: Obtain qualified image blocks of at least one qualified fabric image; Input the first qualified image block and the second qualified image block in each prediction unit into a to-be-trained image prediction network, and use the to-be-trained image prediction network to predict and output a third qualified prediction image block of the third qualified image block in each prediction unit; the first, second, and third qualified image blocks in the prediction unit are adjacent in sequence in the first preset direction; Train the to-be-trained image prediction network according to each third qualified prediction image block and each third qualified image block to obtain a trained image prediction network.

4. The method according to claim 1, wherein Both the first encoding network and the second encoding network include a linear embedding unit and at least one downsampling unit, and the linear embedding unit is sequentially connected to each downsampling unit; The decoding network includes a linear mapping unit and at least one upsampling unit, and each upsampling unit is sequentially connected to the linear mapping unit. The number of upsampling units is equal to the number of downsampling units in any one of the encoding networks; Extracting the encoding features of the image block to be detected by using the encoding network, including: Performing dimensionality transformation and feature transformation on the input image block to be detected by using the linear embedding unit, and inputting the obtained feature map into the next unit and the linear mapping unit in the decoding network; Performing downsampling and feature transformation on the input feature map by using each downsampling unit located in the middle of the encoding network, and inputting the obtained feature map into the next unit and the corresponding upsampling unit in the decoding network; Performing downsampling and feature transformation on the input feature map by using the downsampling unit located at the end of the encoding network, and inputting the obtained feature map into the upsampling unit located at the beginning of the decoding network.

5. The method according to claim 4, wherein The decoding network further includes a multi-layer perceptron. Generating the third predicted image block to be detected by using the decoding network according to the first encoding feature and the second encoding feature, including: Performing upsampling and feature transformation on the input feature map by using the upsampling unit located at the beginning of the decoding network, and inputting the obtained feature map into the next unit and the multi-layer perceptron; Performing downsampling and feature transformation on the feature map input by the previous unit and the feature map input by the corresponding downsampling unit in the encoding network by using the upsampling unit located in the middle of the decoding network, and inputting the obtained feature map into the next unit and the multi-layer perceptron; Performing dimensionality transformation and feature transformation on the feature map input by the previous unit and the feature map input by the linear embedding unit by using the linear mapping unit, and inputting the output feature map into the multi-layer perceptron; Generating the predicted image block to be detected by using the multi-layer perceptron according to the input multiple feature maps.

6. The method according to claim 1, characterized in that, The trained fabric detection model further includes a preset image comparison network, and the input of the preset image comparison network is connected to the output of the trained image prediction network; Determining the first similarity rate between each third predicted image block to be detected and its corresponding third image block to be detected by using the trained fabric detection model, including: Inputting each third image block to be detected and its corresponding third predicted image block to be detected into the preset image comparison network, and using the preset image comparison network to output the first similarity rate between each third image block to be detected and its corresponding third predicted image block to be detected.

7. The method according to claim 1, wherein Determining the quality detection result corresponding to the fabric to be detected according to each of the first similarity rates, including: If it is determined that each of the first similarity rates is greater than the preset similarity rate threshold, then determining that the quality detection result corresponding to the fabric to be detected is qualified; If it is determined that there is any one of the first similarity rates less than the preset similarity rate threshold, then determining that the quality detection result corresponding to the fabric to be detected is unqualified.

8. The method according to claim 7, characterized in that, If it is determined that the quality detection result corresponding to the fabric to be detected is unqualified, then it further includes: Input the third image block to be detected of each prediction unit and each third image block to be detected into the trained image prediction network, and use the trained image prediction network to predict and output the first predicted image block corresponding to the first image block to be detected in each prediction unit; the third, second, and first image blocks to be detected in the prediction unit are adjacent in sequence in the second preset direction; the second preset direction is opposite to the first preset direction; Determine the second similarity rate between each first predicted image block to be detected and its corresponding first image block to be detected; Determine at least one third image block to be detected with a corresponding first similarity rate less than the preset similarity rate threshold as the first difference image block; Determine at least one first image block to be detected with a corresponding second similarity rate less than the preset similarity rate threshold as the second difference image block; In the image to be detected, determine the area where the image block to be detected that is determined as the first difference image block and the second difference image block is located as the defective area.

9. The method according to claim 8, characterized in that, After determining at least one first image block to be detected with a corresponding second similarity rate less than the preset similarity rate threshold as the second difference image block, it further includes: Input each first difference image block and its corresponding third predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the first difference image of the image to be detected; Input each second difference image block and its corresponding first predicted image block to be detected into the preset image comparison network, and use the preset image comparison network to output the second difference image of the image to be detected; Determine the intersection of the first difference image and the second difference image as the defective shape.

10. A fabric quality detection device, characterized in that, It includes: An acquisition module for acquiring the image to be detected of the fabric to be detected; A detection module for inputting the image to be detected into the trained fabric detection model, and using the trained fabric detection model to divide a preset number of image blocks to be detected on the image to be detected; input the first image block to be detected and the second image block to be detected in each prediction unit into the trained image prediction network, and use the trained image prediction network to predict and output the third predicted image block to be detected of the third image block to be detected in each prediction unit; wherein, the prediction unit is determined according to each image block to be detected on the image to be detected and the first preset direction, and the first, second, and third image blocks to be detected in the prediction unit are adjacent in sequence in the first preset direction; the trained image prediction network is included in the trained fabric detection model and is trained according to the qualified image blocks of at least one qualified fabric image; use the trained fabric detection model to determine the first similarity rate between each third predicted image block to be detected and its corresponding third image block to be detected; A first determination module for determining the quality detection result corresponding to the fabric to be detected according to each of the first similarity rates; The trained image prediction network includes a first encoding network, a second encoding network, and a decoding network; the structures and parameters of the first encoding network and the second encoding network are the same; the detection module is specifically configured to perform the following operations for any prediction unit: input a first image block to be detected into the first encoding network, input a second image block to be detected into the second encoding network, extract first encoding features of the first image block to be detected by using the first encoding network, and extract second encoding features of each second image block to be detected by using the second encoding network; generate a third image block to be detected and predicted according to the first encoding features and the second encoding features by using the decoding network.

11. An electronic device, characterized in that, Comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-9.

Citation Information

Patent Citations

  • Texture image surface defect detection method based on depth convolution auto-encoder

    CN111815601A

  • Method and device for encoding or decoding image

    US20210160522A1