Cloth defect identification method, device and equipment and storage medium

By automatically identifying defects in knitted fabrics, using feature extraction and comparison of texture units, and combining type judgment networks, the shortcomings of artificial visual inspection in the prior art are solved, the detection speed and accuracy are improved, and the false detection and missed detection rates are reduced.

CN119941683APending Publication Date: 2025-05-06李红兵 +3
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510033121.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-09
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

In the prior art, defect identification of knitted fabrics relies on manual visual inspection, resulting in slow detection speed, high error detection rate and missed detection rate, and the inability to achieve unified detection standards, resulting in poor detection accuracy.

Method used

By determining the texture units in the preset flawless cloth image, calculate its reference color histogram, HOG histogram, gradient map and color map; then, the corresponding feature extraction and comparison of the cloth image to be inspected is performed, and the network is judged based on the preset type, and the defect type of the image block is determined.

Benefits of technology

The speed and accuracy of cloth defect detection are improved, the error detection rate and missed detection rate are reduced, and a unified detection standard based on automation is realized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119941683A_ABST
    Figure CN119941683A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image recognition, in particular to a cloth flaw recognition method, device and equipment and a storage medium, and the method comprises the steps: determining a texture unit in a flawless cloth image, and calculating a reference color histogram and a reference HOG histogram of the texture unit; generating a reference gradient mapping graph based on the gradient of each pixel in the texture unit, and generating a reference color mapping graph based on the color channel information of each pixel and the size of the texture unit; determining a to-be-detected color histogram, a to-be-detected HOG histogram, a to-be-detected gradient map and a to-be-detected color map corresponding to each image block in the to-be-detected cloth image; and determining the flaw type based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the to-be-detected color histogram, the to-be-detected HOG histogram, the to-be-detected gradient map, the to-be-detected color map and the type judgment network. The defect detection speed and the detection accuracy of the cloth can be improved, and the false detection rate and the missing detection rate of the cloth defect detection can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition technology, and in particular to a cloth defect recognition method, device, equipment and storage medium. Background Art

[0002] In the automated production process of knitted fabrics, various unforeseen factors and abnormal situations, such as mechanical failure, raw material problems or changes in environmental conditions, may cause various defects in the finished knitted fabrics. Defects will not only affect the quality of the knitted fabrics, but also cause waste of resources and increased costs, and reduce production efficiency and customer satisfaction. Therefore, after the knitted fabrics are produced, they need to be identified for defects.

[0003] At present, the method of defect identification for knitted fabrics is as follows: after the knitted fabrics are produced, the quality inspector manually visually inspects the defect points on the knitted fabrics and records the inspected defect points; then, the recorded defect points are compared with the preset defect point template to determine the defect type and severity of the recorded defect points; wherein, the defect point template covers the typical features of common defect points, which are used for comparison with the detected defect points; if it is found through comparison that the detected defect point does not exist in the preset defect point template, the quality inspector independently determines the defect type and severity of the defect point based on his own experience.

[0004] However, detecting defects on knitted fabrics through manual visual inspection is not only slow (generally 20 meters per minute), but also limited by the mental state of the inspectors (such as fatigue, tension, etc.), which will lead to high false detection and missed detection rates. In addition, manual visual inspection is also unable to achieve consistency based on unified inspection standards, resulting in poor detection accuracy. Summary of the invention

[0005] In order to improve the speed and accuracy of cloth defect detection and reduce the false detection rate and missed detection rate of cloth defect detection, the present application provides a cloth defect recognition method, device, equipment and storage medium.

[0006] In a first aspect, the present application provides a method for identifying cloth defects, comprising:

[0007] Determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit;

[0008] Generate a reference gradient map based on the gradient of each pixel in the texture unit, and generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the size of the texture unit;

[0009] Determine the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit;

[0010] Based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, the defect type corresponding to the image block is determined.

[0011] In a second aspect, the present application provides a cloth defect recognition device, comprising:

[0012] A histogram calculation module, used to determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit;

[0013] A mapping generation module, used to generate a reference gradient mapping map based on the gradient of each pixel in the texture unit, and to generate a reference color mapping map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size;

[0014] An image block processing module, used to determine the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit;

[0015] A type determination module is used to determine the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

[0016] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.

[0018] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0019] The above-mentioned cloth defect recognition method, device, equipment and storage medium determine the texture unit in a preset flawless cloth image, calculate the reference color histogram and reference HOG histogram corresponding to the texture unit; generate a reference gradient map based on the gradient of each pixel in the texture unit, and generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size; determine the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked and the color map to be checked corresponding to each image block in the cloth image to be checked; wherein the size of the image block is the same as the texture unit size; based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, determine the defect type corresponding to the image block. Through the above implementation, the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units in the defect-free cloth image and the image blocks in the cloth image to be inspected are respectively generated by image processing, and then the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units and the image blocks are compared by difference to determine the difference between the image block and the corresponding texture unit, thereby determining whether the image block has defects, and processing the defective image blocks through a preset type judgment network to determine the specific defect type; in this way, the participation of manual visual inspection is eliminated, which is not only convenient for improving the defect detection speed and detection accuracy of cloth, but also convenient for reducing the false detection rate and missed detection rate of cloth defect detection.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A flow chart of a cloth defect identification method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram for reflecting the positional relationship between a reference pixel and a corresponding pixel provided in an embodiment of the present application;

[0024] Figure 3 A defect schematic diagram provided in an embodiment of the present application;

[0025] Figure 4 Another defect schematic diagram provided in an embodiment of the present application;

[0026] Figure 5 A schematic diagram of a report showing defect types provided in an embodiment of the present application;

[0027] Figure 6 This is a structural schematic diagram of a cloth defect identification device provided in an embodiment of the present application;

[0028] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present application;

[0029] Figure 8 This is a diagram of the internal structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0032] In this article, the term "and / or" is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship.

[0033] Embodiment 1

[0034] Figure 1A flow chart of a cloth defect recognition method provided in Example 1 of the present application, referring to Figure 1 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:

[0035] S110, determining a texture unit in a preset flawless cloth image, and calculating a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0036] The preset flawless cloth image is a knitted cloth image without any flaws detected manually, or a knitted cloth image without any flaws detected by other flaw recognition; the overall pattern on the knitted cloth is composed of a plurality of repeated pattern units, and the repeated pattern unit is recorded as a texture unit. In order to facilitate the judgment of whether the cloth to be inspected has flaws, the texture unit on the cloth to be inspected can be compared with the corresponding texture unit on the flawless cloth for image features. To this end, the color histogram and HOG histogram of the texture unit in the flawless cloth image need to be calculated first, and the color histogram corresponding to the texture unit in the flawless cloth image is recorded as the reference color histogram, and the HOG histogram corresponding to the texture unit in the flawless cloth image is recorded as the reference HOG histogram.

[0037] The step of calculating a reference color histogram corresponding to a texture unit comprises:

[0038] Determine the preset grayscale value partitions corresponding to each color channel value of the pixel in the texture unit.

[0039] Among them, a pixel is a pixel point in a texture unit, and a texture unit is composed of multiple pixels; a pixel has a corresponding color space, and this embodiment adopts an RGB color space; each pixel has three color channels in this embodiment, namely, an R channel, a G channel, and a B channel, and the corresponding values ​​of different color channels of each pixel are color channel values; for example, if the value (i.e., grayscale value) corresponding to a pixel in the R channel is 13, then the color channel value of the R channel of the pixel is 13. It should be noted that the grayscale value corresponding to each color channel is divided into 256 levels, i.e., level 0-255; in order to reduce the data dimension and computational complexity, so as to improve the efficiency of cloth defect recognition, this embodiment pre-divides the 256 grayscale values ​​corresponding to each color channel into 16 grayscale value preset partitions, and each grayscale value preset partition contains 16 grayscale values.

[0040] For example, taking one of the color channels as an example, such as the R channel, the first grayscale value preset partition corresponding to the R channel is level 0-level 15, the second grayscale value preset partition is level 16-level 31, ... the 16th grayscale value preset partition is level 240-level 255; if a color channel value corresponding to the R channel is 13, since 13 is in the first grayscale value preset partition corresponding to the R channel, the grayscale value preset partition corresponding to the color channel value is also the first grayscale value preset partition corresponding to the R channel.

[0041] The number of color channel values ​​corresponding to each grayscale value preset partition is counted to obtain a channel value number statistical result.

[0042] Among them, by determining the gray value preset partitions corresponding to each color channel value of the pixel in the texture unit, the color channel values ​​of the three color channels of each pixel corresponding to each other can be allocated to the corresponding gray value preset partitions. In this way, each gray value preset partition has a corresponding number of color channel values, and the number of color channel values ​​in each gray value preset partition is used as the channel value number statistics result; illustratively, the channel value number statistics result is as follows:

[0043]

[0044] Construct a reference color histogram based on the channel value quantity statistics.

[0045] Among them, the gray value preset partition is used as the parameter of the x-axis of the rectangular coordinate system, and the number of color channel values ​​is used as the parameter of the y-axis of the rectangular coordinate system. In this way, a corresponding statistical graph can be generated according to the above channel value number statistical results, which is recorded as a reference color histogram.

[0046] The step of calculating the reference HOG histogram corresponding to the texture unit includes:

[0047] The gradient of each pixel in the texture unit is calculated, wherein the gradient includes the gradient intensity (ie, the gradient magnitude) and the gradient direction.

[0048] Wherein, the texture unit is a color image. In order to calculate the gradient of each pixel in the texture unit, the texture unit needs to be converted into a corresponding grayscale image, and the grayscale image is recorded as a primary grayscale image. In order to reduce the image noise in the primary grayscale image, this embodiment also performs Gaussian smoothing on the primary grayscale image to obtain a target grayscale image. Further, each pixel in the target grayscale image is processed by a preset Sobel operator to calculate the horizontal gradient G of each pixel. x With vertical gradient G y ; Among them, the calculation formula of gradient strength G is:

[0049]

[0050] Among them, the calculation formula of the gradient direction θ is:

[0051] θ=arctan(G x / G y ).

[0052] A preset direction interval corresponding to the gradient direction of each pixel in the preset pixel unit is determined, and a pixel unit histogram is obtained based on the gradient strengths corresponding to the gradient directions in the preset direction intervals.

[0053] Among them, the pixel unit is a collection of several adjacent pixels, and the texture unit includes multiple pixel units; the gradient direction represents an angle, and in order to reduce the data dimension and calculation complexity, each gradient direction needs to be assigned to the corresponding direction preset interval, so that each direction preset interval is assigned a certain number of gradient directions; further, the sum of the gradient intensities corresponding to each gradient direction in each direction preset interval is calculated to obtain the intensity sum as the calculation result; then the direction preset interval is used as the x-axis parameter of the rectangular coordinate system, and the intensity sum is used as the y-axis parameter of the rectangular coordinate system, and the calculation result is displayed on the rectangular coordinate system as a pixel unit histogram.

[0054] The pixel unit histogram corresponding to each pixel unit in the preset pixel block is normalized to obtain a block histogram.

[0055] Among them, a pixel block is a collection of several adjacent pixel units, and a texture unit includes multiple pixel blocks. In order to improve the robustness of defect recognition, it is necessary to normalize the multiple pixel unit histograms corresponding to each pixel block. In this embodiment, the L1 norm or the L2 norm can be used for normalization. In other embodiments, the normalization method is not specifically limited. The multiple pixel unit histograms corresponding to the pixel block are connected together as a block vector, and then the block vector is normalized to obtain a block histogram.

[0056] A reference HOG histogram is obtained based on the block histogram.

[0057] The HOG histogram can be obtained by connecting and combining the block histograms corresponding to each pixel block, and the HOG histogram is recorded as the reference HOG histogram.

[0058] S120, generating a reference gradient map based on the gradient of each pixel in the texture unit, and generating a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size.

[0059] Among them, after the colored texture unit is converted into the target grayscale image, the gradient of each pixel in the target grayscale image can be further calculated. The specific calculation process can be found in step S110 and will not be repeated here. The gradient includes gradient intensity G and gradient direction θ. In order to facilitate the judgment of whether there are defects on the cloth to be inspected, it is necessary to compare the gradient mapping map corresponding to the defect-free cloth image with the gradient mapping map corresponding to the cloth image to be inspected. The gradient mapping map is used to represent the number of pixels belonging to a certain gradient direction range and a certain gradient intensity range in the image of the texture unit size, wherein different gradient direction ranges and gradient intensity ranges have multiple combinations, and the number of pixels corresponding to different combinations are all displayed on the gradient mapping map, and the gradient mapping map corresponding to the texture unit of the defect-free cloth image is recorded as the reference gradient mapping map.

[0060] Among them, the texture unit has its corresponding size, which is recorded as the texture unit size. In this embodiment, the texture unit size specifically includes the texture unit height H and the texture unit width W. Taking a pixel in the texture unit as an example, the corresponding pixel of the pixel on the flawless cloth image can be determined through the texture unit size, and the color mapping map can be calculated through the color channel information of the pixel on the texture unit and the color channel information of the corresponding pixel of the pixel on the flawless cloth image; wherein the color channel information includes the grayscale value of the R channel, the grayscale value of the G channel and the grayscale value of the B channel, and the color mapping map is used to characterize the comparison relationship between the color channel information of each pixel in the texture unit and its corresponding pixel; by comparing the color mapping map corresponding to the flawless cloth image with the color mapping map corresponding to the cloth image to be inspected, it can be used to finally detect whether there are defects on the cloth to be inspected; and the color mapping map corresponding to the texture unit of the flawless cloth image is recorded as the reference color mapping map.

[0061] S130, determining a color histogram to be inspected, a HOG histogram to be inspected, a gradient map to be inspected and a color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit.

[0062] Among them, the cloth image to be inspected is also the image of the cloth that needs to be inspected for defects. In this embodiment, a linear array camera is specifically used to scan the produced cloth image, so as to obtain a high-precision cloth image to be inspected. In order to facilitate the comparison of the image features (color histogram, HOG histogram, gradient map and color map) of the cloth image to be inspected with the cloth image to be inspected, so as to detect the defects of the cloth to be inspected, it is necessary to first divide the cloth image to be inspected according to the texture unit size, so as to divide the image blocks on the cloth image to be inspected whose positions and sizes correspond to the texture units on the defect-free cloth image; for each image block, the color histogram, HOG histogram, gradient map and color map of the image block are calculated, and it is necessary to explain The calculation process of the color histogram, HOG histogram, gradient map and color map corresponding to the image block is the same as the calculation process of the color histogram, HOG histogram, gradient map and color map corresponding to the texture unit, which can be referred to as step S110 and step S120, and will not be repeated here; and the color histogram, HOG histogram, gradient map and color map corresponding to the image block are correspondingly recorded as the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked and the color map to be checked, respectively.

[0063] S140, determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

[0064] Among them, by comparing the reference color histogram, reference HOG histogram, reference gradient map and reference color map of the defect-free cloth image with the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to the cloth image to be inspected, a corresponding comparison result can be obtained, and according to the comparison result, it can be determined whether the cloth to be inspected has defects; in the case of judging that there are defects, the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to the cloth image to be inspected can be further processed by a preset type judgment network to determine the defect type corresponding to the inspected cloth image.

[0065] It should be noted that, in this embodiment, by determining a texture unit in a preset flawless cloth image, a reference color histogram and a reference HOG histogram corresponding to the texture unit are calculated; a reference gradient map is generated based on the gradient of each pixel in the texture unit, and a reference color map corresponding to the texture unit is generated based on the color channel information of each pixel in the flawless cloth image and the texture unit size; a color histogram to be checked, a HOG histogram to be checked, a gradient map to be checked and a color map to be checked corresponding to each image block in the cloth image to be checked are determined; wherein the size of the image block is the same as the texture unit size; based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, the defect type corresponding to the image block is determined. Through the above implementation, the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units in the defect-free cloth image and the image blocks in the cloth image to be inspected are respectively generated by image processing, and then the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units and the image blocks are compared by difference to determine the difference between the image block and the corresponding texture unit, thereby determining whether the image block has defects, and processing the defective image blocks through a preset type judgment network to determine the specific defect type; in this way, the participation of manual visual inspection is eliminated, which is not only convenient for improving the defect detection speed and detection accuracy of cloth, but also convenient for reducing the false detection rate and missed detection rate of cloth defect detection.

[0066] Embodiment 2

[0067] A cloth defect recognition method provided in the second embodiment of the present application optimizes the "generating a reference gradient map based on the gradient of each pixel in the texture unit" in the first embodiment; it should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments, and the method includes:

[0068] S210, determining a texture unit in a preset flawless cloth image, and calculating a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0069] S221. Determine a gradient of each pixel in the texture unit, where the gradient includes a gradient intensity and a gradient direction.

[0070] Wherein, the texture unit is a color image. In order to calculate the gradient corresponding to each pixel in the texture unit, it is necessary to first convert the texture unit into a corresponding grayscale image as a primary grayscale image. In order to reduce the image noise in the primary grayscale image, this embodiment also performs Gaussian smoothing on the primary grayscale image to obtain a target grayscale image. Then, the gradient of each pixel in the target grayscale image is calculated. The gradient is a vector. The gradient intensity is also the gradient size. The direction of the vector is also the gradient direction. It should be noted that the process of calculating the gradient is the same as the above embodiment, and will not be described in detail.

[0071] S222: Determine a preset intensity range corresponding to the gradient intensity, and also determine a preset direction range corresponding to the gradient direction.

[0072] In order to generate the reference gradient map, the gradient intensity of each pixel in the texture unit needs to be assigned to the corresponding preset intensity interval, and the gradient direction of each pixel in the texture unit needs to be assigned to the corresponding preset direction interval; in this embodiment, 60 preset intensity intervals are preset for the gradient intensity, and 60 preset direction intervals are preset for the gradient direction, the length of each preset direction interval is 6 degrees, the first preset direction interval is 0 degrees-5 degrees, the second preset direction interval is 6 degrees-11 degrees, .... Exemplarily, if the gradient intensity corresponding to a pixel is 21, and a preset intensity interval is 20-25, and the gradient direction corresponding to the pixel is 4 degrees, it can be determined that the preset intensity interval corresponding to the pixel is 20-25, and the corresponding preset direction interval is 0 degrees-5 degrees.

[0073] S223 , counting pixel sets corresponding to interval combinations consisting of different preset intensity intervals and preset direction intervals to obtain a reference gradient mapping image.

[0074] Among them, different preset intensity intervals and different preset direction intervals can constitute different interval combinations, and different interval combinations can correspond to a certain number of pixels, and the certain number of pixels corresponding to the interval combination are recorded as the pixel set corresponding to the interval combination; for example, assuming that the gradient intensity corresponding to pixel A is 21 and the gradient direction is 1 degree, and the gradient intensity corresponding to pixel B is 22 and the gradient direction is 2 degrees, then both pixel A and pixel B will be assigned to the interval combination with a preset intensity interval of 20-25 and a preset direction interval of 0 degrees-5 degrees. At this time, the number of pixels in the pixel set corresponding to the interval combination is 2. The interval combination is used as the x-axis parameter of the rectangular coordinate system, and the number of pixels corresponding to the interval combination is used as the y-axis parameter of the rectangular coordinate system. In the rectangular coordinate system, the number of pixels in the pixel set corresponding to each interval combination is displayed, so as to obtain a corresponding statistical graph, which is used as a reference gradient mapping graph.

[0075] S224: Generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size.

[0076] S230, determining a color histogram to be inspected, a HOG histogram to be inspected, a gradient map to be inspected and a color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit.

[0077] S240, determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

[0078] Embodiment 3

[0079] A cloth defect recognition method provided in the third embodiment of the present application optimizes the "generating a reference color map corresponding to the texture unit based on the color channel information of each pixel in the defect-free cloth image and the texture unit size" in the first embodiment; it should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments, and the method includes:

[0080] S310, determining a texture unit in a preset flawless cloth image, and calculating a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0081] S321. Generate a reference gradient map based on the gradient of each pixel in the texture unit.

[0082] S322: Determine a reference pixel in the texture unit, and determine a corresponding pixel of the reference pixel in the flawless cloth image based on the reference pixel and the texture unit size.

[0083] The reference pixel is any pixel point in the texture unit, and the texture unit size includes the texture unit height H and the texture unit width W. Figure 2 For example, Figure 24 texture units in the defect-free cloth are shown, namely, texture unit 1, texture unit 2, texture unit 3 and texture unit 4; in this embodiment, pixel A in the texture unit is taken as the reference pixel, and pixel B, which is at a distance of the texture unit width W from pixel A in the horizontal direction to the right of pixel A, is taken as the first corresponding pixel of pixel A, and pixel B is located in texture unit 2; pixel C, which is at a distance of the texture unit height H from pixel B in the vertical direction below pixel B, is taken as the second corresponding pixel of pixel A, and pixel C is located in texture unit 3; pixel D, which is at a distance of the texture unit height H from pixel A in the vertical direction below pixel A, is taken as the third corresponding pixel of pixel A, and pixel D is located in texture unit 4; in the above manner, after the reference pixel is determined, the three corresponding pixels corresponding to the reference pixel can be determined by the texture unit size.

[0084] S323: Generate a single-pixel multidimensional vector based on the reference color channel information of the reference pixel and the corresponding color channel information of the corresponding pixel.

[0085] The color channel information of the pixel includes: R channel grayscale value, G channel grayscale value and B channel grayscale value; and the color channel information of the reference pixel is recorded as the reference color channel information, and the color channel information of the corresponding pixel is recorded as the corresponding color channel information; Figure 2 As an example, the reference pixel and three corresponding pixels shown in the figure, the reference color channel information of the reference pixel A includes: the gray value R of the R channel A , G channel gray value G A And the B channel gray value B A ; The corresponding color channel information of the corresponding pixel B includes: R channel gray value R B , G channel gray value G B And the B channel gray value B B ; The corresponding color channel information of the corresponding pixel C includes: R channel gray value R C , G channel gray value G C And the B channel gray value B C ; The corresponding color channel information of the corresponding pixel D includes: R channel gray value R D , G channel gray value G D And the B channel gray value B D .

[0086] The single-pixel multidimensional vector is used to represent a first combination of the R channel grayscale value of the reference pixel and the R channel grayscale value of the corresponding pixel, a second combination of the G channel grayscale value of the reference pixel and the G channel grayscale value of the corresponding pixel, and a third combination of the B channel grayscale value of the reference pixel and the B channel grayscale value of the corresponding pixel. Figure 2 The single pixel multidimensional vector corresponding to the reference pixel A shown is [(R A, R B ), (R A , R C ), (R A , R D );(G A , G B ), (G A , G C ), (G A , G D );(B A , B B ), (B A , B C ), (B A , B D )]; the single-pixel multidimensional vector is a nine-dimensional vector.

[0087] S324: construct a reference color map based on the single-pixel multidimensional vector corresponding to each of the reference pixels.

[0088] The single-pixel multidimensional vectors corresponding to each reference pixel in the texture unit are calculated to obtain a vector set, and further statistics on the vector set can generate a corresponding color map, that is, a reference color map.

[0089] S330, determining the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the texture unit size.

[0090] S340, determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

[0091] Embodiment 4

[0092] A cloth defect recognition method is provided in a fourth embodiment of the present application. The method optimizes the method of “determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network” in the first embodiment; it should be noted that for the part not described in detail in this embodiment, reference may be made to the description of other embodiments. The method includes:

[0093] S410, determining a texture unit in a preset flawless cloth image, and calculating a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0094] S420, generating a reference gradient map based on the gradient of each pixel in the texture unit, and generating a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size.

[0095] S430, determining the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the texture unit size.

[0096] S441, calculating the difference between the reference color histogram and the color histogram to be tested to obtain a first difference map, calculating the difference between the reference HOG histogram and the HOG histogram to be tested to obtain a second difference map, calculating the difference between the reference gradient mapping map and the gradient mapping map to be tested to obtain a third difference map, and calculating the reference color mapping map and the color mapping map to be tested to obtain a fourth difference map.

[0097] Among them, taking a texture unit in a flawless cloth image as an example, the reference color histogram, reference HOG histogram, reference gradient map and reference color map corresponding to the texture unit can be calculated through the above steps of this embodiment; similarly, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked and the color map to be checked of the image block corresponding to the texture unit in the cloth image to be checked can also be calculated; subsequently, by comparing the reference color histogram, the reference HOG histogram, the reference gradient map and the reference color map corresponding to the texture unit with the image The differences between the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked and the color map to be checked of the block can determine whether there is a defect in the image block; to this end, the difference between the reference color histogram and the color histogram to be checked can be calculated to obtain a first difference map; the difference between the reference HOG histogram and the HOG histogram to be checked can be calculated to obtain a second difference map; the difference between the reference gradient map and the gradient map to be checked can be calculated to obtain a third difference map; the reference color map and the color map to be checked can also be calculated to obtain a fourth difference map.

[0098] S442: Determine whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map.

[0099] Among them, after the first difference map, the second difference map, the third difference map and the fourth difference map are calculated in the previous step, further, whether the image block contains defects can be determined through the first difference map, the second difference map, the third difference map and the fourth difference map.

[0100] S443: If yes, determine the defect type corresponding to the image block based on the first difference map, the second difference map, the third difference map, the fourth difference map, and a preset type judgment network.

[0101] Among them, the first difference map, the second difference map, the third difference map and the fourth difference map are processed by a preset type judgment model to determine the defect type corresponding to the image block; in this embodiment, the type judgment model specifically adopts the ResNet network, and the defect types include broken yarn, jumped thread, wrong flower, color difference and stains.

[0102] It should be noted that after the defect is detected in the cloth to be inspected, the present embodiment also displays the defect on a preset display interface, such as Figure 3 and Figure 4 In addition, the defect type of the defect is also displayed in the form of a report, such as Figure 5 As shown, the report content also includes the test number, fabric type and test time.

[0103] Embodiment 5

[0104] A cloth defect recognition method provided in the fifth embodiment of the present application optimizes the "determining whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map" in the fourth embodiment; it should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments, and the method includes:

[0105] S510: Determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0106] S520: Generate a reference gradient map based on the gradient of each pixel in the texture unit, and generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size.

[0107] S530, determining the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the texture unit size.

[0108] S541, calculating the difference between the reference color histogram and the color histogram to be tested to obtain a first difference map, calculating the difference between the reference HOG histogram and the HOG histogram to be tested to obtain a second difference map, calculating the difference between the reference gradient mapping map and the gradient mapping map to be tested to obtain a third difference map, and calculating the reference color mapping map and the color mapping map to be tested to obtain a fourth difference map.

[0109] S5421. Perform binarization processing on the first difference map, the second difference map, the third difference map, and the fourth difference map respectively based on a preset threshold value group to obtain processing results.

[0110] The preset threshold value group includes: a first threshold value for comparing with the first difference map to perform binarization processing on the first difference map, a second threshold value for comparing with the second difference map to perform binarization processing on the second difference map, a third threshold value for comparing with the third difference map to perform binarization processing on the third difference map, and a fourth threshold value for comparing with the fourth difference map to perform binarization processing on the fourth difference map; the difference map is used to characterize the degree of difference between the image of the flawless cloth and the image of the cloth to be inspected in the same image feature, and the binarization processing is to compare the corresponding threshold value with the difference map, so as to process the corresponding difference map into a value of 0 or a value of 1. The set of values ​​obtained after binarization processing of the first difference map, the second difference map, the third difference map and the fourth difference map is the processing result.

[0111] Specifically, determine whether the first difference image is greater than a first threshold value, and if so, Figure 2 The value is processed as 1, otherwise, it is processed as 0; determine whether the second difference image is greater than the second threshold value, if so, the second difference image is converted to Figure 2 The value is processed as 1, otherwise, it is processed as 0; determine whether the third difference image is greater than the third threshold value, if so, the third difference image is converted to Figure 2 The value is processed as 1, otherwise, it is processed as 0; determine whether the fourth difference image is greater than the fourth threshold value, if so, the fourth difference image is Figure 2 The value is processed as 1, otherwise, it is processed as 0.

[0112] S5422: Determine whether the image block contains defects based on the processing result.

[0113] If the number of values ​​1 in the processing result is greater than or equal to 2, it is considered that the corresponding image block contains defects. According to the above steps, it can be determined whether each image block in the image to be detected still has defects.

[0114] S543: If yes, determine the defect type corresponding to the image block based on the first difference map, the second difference map, the third difference map, the fourth difference map, and a preset type judgment network.

[0115] Embodiment 6

[0116] A cloth defect recognition method provided in Example 6 of the present application optimizes the "determining the defect type corresponding to the image block based on the first difference map, the second difference map, the third difference map, the fourth difference map and a preset type judgment network" in Example 4; it should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments, and the method includes:

[0117] S610: Determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit.

[0118] S620: Generate a reference gradient map based on the gradient of each pixel in the texture unit, and generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size.

[0119] S630, determining the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the texture unit size.

[0120] S641. Calculate the difference between the reference color histogram and the color histogram to be tested to obtain a first difference map, calculate the difference between the reference HOG histogram and the HOG histogram to be tested to obtain a second difference map, calculate the difference between the reference gradient mapping map and the gradient mapping map to be tested to obtain a third difference map, and calculate the reference color mapping map and the color mapping map to be tested to obtain a fourth difference map.

[0121] S642: Determine whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map.

[0122] S6431: If yes, merge the first difference map, the second difference map, the third difference map, and the fourth difference map to obtain a multi-channel difference map.

[0123] The merging is to merge the first difference map, the second difference map, the third difference map and the fourth difference map into a four-channel image, and record the four-channel image as a multi-channel difference map.

[0124] S6432. Process the multi-channel difference image based on a preset type judgment network to obtain a defect type corresponding to the image block.

[0125] The preset type determination network may process the multi-channel difference image, thereby identifying the defect type of the defect corresponding to the multi-channel difference image.

[0126] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0127] Embodiment 7

[0128] Based on the same inventive concept, this embodiment also provides a cloth defect recognition device for implementing the cloth defect recognition method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more cloth defect recognition device embodiments provided below can refer to the limitations of the cloth defect recognition method above, and will not be repeated here.

[0129] In this embodiment, Figure 6 As shown, a cloth defect recognition device is provided, comprising:

[0130] A histogram calculation module, used to determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit;

[0131] A mapping generation module, used to generate a reference gradient mapping map based on the gradient of each pixel in the texture unit, and to generate a reference color mapping map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size;

[0132] An image block processing module, used to determine the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit;

[0133] A type determination module is used to determine the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

[0134] Each module in the above-mentioned cloth defect identification device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0135] It should be noted that, in this embodiment, by determining a texture unit in a preset flawless cloth image, a reference color histogram and a reference HOG histogram corresponding to the texture unit are calculated; a reference gradient map is generated based on the gradient of each pixel in the texture unit, and a reference color map corresponding to the texture unit is generated based on the color channel information of each pixel in the flawless cloth image and the texture unit size; a color histogram to be checked, a HOG histogram to be checked, a gradient map to be checked and a color map to be checked corresponding to each image block in the cloth image to be checked are determined; wherein the size of the image block is the same as the texture unit size; based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, the defect type corresponding to the image block is determined. Through the above implementation, the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units in the defect-free cloth image and the image blocks in the cloth image to be inspected are respectively generated by image processing, and then the color histograms, HOG histograms, gradient maps and color maps corresponding to the texture units and the image blocks are compared by difference to determine the difference between the image block and the corresponding texture unit, thereby determining whether the image block has defects, and processing the defective image blocks through a preset type judgment network to determine the specific defect type; in this way, the participation of manual visual inspection is eliminated, which is not only convenient for improving the defect detection speed and detection accuracy of cloth, but also convenient for reducing the false detection rate and missed detection rate of cloth defect detection.

[0136] In an optional embodiment, in terms of generating a reference gradient map based on the gradient of each pixel in the texture unit, the map generation module is specifically used to:

[0137] Determine a gradient of each pixel in the texture unit, wherein the gradient includes a gradient intensity and a gradient direction;

[0138] Determine a preset intensity interval corresponding to the gradient intensity, and also determine a preset direction interval corresponding to the gradient direction;

[0139] Pixel sets corresponding to interval combinations formed by different preset intensity intervals and preset direction intervals are counted to obtain a reference gradient map.

[0140] In an optional embodiment, in terms of generating a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size, the map generation module is specifically used to:

[0141] Determine a reference pixel in the texture unit, and determine a corresponding pixel of the reference pixel in the flawless cloth image based on the reference pixel and the texture unit size;

[0142] Generate a single-pixel multidimensional vector based on the reference color channel information of the reference pixel and the corresponding color channel information of the corresponding pixel;

[0143] A reference color map is constructed based on the single-pixel multidimensional vector corresponding to each of the reference pixels.

[0144] In an optional embodiment, in determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, the type determination module is specifically used to:

[0145] Calculate the difference between the reference color histogram and the color histogram to be tested to obtain a first difference map, calculate the difference between the reference HOG histogram and the HOG histogram to be tested to obtain a second difference map, calculate the difference between the reference gradient map and the gradient map to be tested to obtain a third difference map, and calculate the reference color map and the color map to be tested to obtain a fourth difference map;

[0146] Determining whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map;

[0147] If so, the defect type corresponding to the image block is determined based on the first difference map, the second difference map, the third difference map, the fourth difference map and a preset type judgment network.

[0148] In an optional embodiment, in determining whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map, the type determination module is specifically configured to:

[0149] Based on a preset threshold group, binarization processing is performed on the first difference map, the second difference map, the third difference map, and the fourth difference map respectively to obtain processing results;

[0150] Based on the processing result, it is determined whether the image block contains defects.

[0151] In an optional embodiment, in determining the defect type corresponding to the image block based on the first difference map, the second difference map, the third difference map, the fourth difference map and a preset type judgment network, the type determination module is specifically used to:

[0152] Merging the first difference map, the second difference map, the third difference map, and the fourth difference map to obtain a multi-channel difference map;

[0153] The multi-channel difference map is processed based on a preset type judgment network to obtain the defect type corresponding to the image block.

[0154] Embodiment 8

[0155] In this embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for identifying cloth defects is implemented.

[0156] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0157] Embodiment 9

[0158] In this embodiment, a computer readable storage medium is provided. Figure 8 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0159] Embodiment 10

[0160] In this embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0161] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0162] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited thereto. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited thereto.

[0163] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0164] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.

Claims

1. A method for identifying cloth defects, characterized in that: include: Determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit; Generate a reference gradient map based on the gradient of each pixel in the texture unit, and generate a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the size of the texture unit; Determine the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit; Based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network, the defect type corresponding to the image block is determined.

2. The method according to claim 1, characterized in that: The generating a reference gradient map based on the gradient of each pixel in the texture unit comprises: Determine a gradient of each pixel in the texture unit, wherein the gradient includes a gradient intensity and a gradient direction; Determine a preset intensity interval corresponding to the gradient intensity, and also determine a preset direction interval corresponding to the gradient direction; Pixel sets corresponding to interval combinations formed by different preset intensity intervals and preset direction intervals are counted to obtain a reference gradient map.

3. The method according to claim 1, characterized in that The step of generating a reference color map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size comprises: Determine a reference pixel in the texture unit, and determine a corresponding pixel of the reference pixel in the flawless cloth image based on the reference pixel and the texture unit size; Generate a single-pixel multidimensional vector based on the reference color channel information of the reference pixel and the corresponding color channel information of the corresponding pixel; A reference color map is constructed based on the single-pixel multidimensional vector corresponding to each of the reference pixels.

4. The method according to claim 1, characterized in that: The method of determining the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network includes: Calculate the difference between the reference color histogram and the color histogram to be tested to obtain a first difference map, calculate the difference between the reference HOG histogram and the HOG histogram to be tested to obtain a second difference map, calculate the difference between the reference gradient map and the gradient map to be tested to obtain a third difference map, and calculate the reference color map and the color map to be tested to obtain a fourth difference map; Determining whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map; If so, the defect type corresponding to the image block is determined based on the first difference map, the second difference map, the third difference map, the fourth difference map and a preset type judgment network.

5. The method according to claim 4, characterized in that The determining whether the image block contains defects based on the first difference map, the second difference map, the third difference map, and the fourth difference map includes: Based on a preset threshold group, binarization processing is performed on the first difference map, the second difference map, the third difference map, and the fourth difference map respectively to obtain processing results; Based on the processing result, it is determined whether the image block contains defects.

6. The method according to claim 4, characterized in that The determining the defect type corresponding to the image block based on the first difference map, the second difference map, the third difference map, the fourth difference map and a preset type judgment network includes: Merging the first difference map, the second difference map, the third difference map, and the fourth difference map to obtain a multi-channel difference map; The multi-channel difference map is processed based on a preset type judgment network to obtain the defect type corresponding to the image block.

7. A cloth defect identification device, characterized in that: The device comprises: A histogram calculation module, used to determine a texture unit in a preset flawless cloth image, and calculate a reference color histogram and a reference HOG histogram corresponding to the texture unit; A mapping generation module, used to generate a reference gradient mapping map based on the gradient of each pixel in the texture unit, and to generate a reference color mapping map corresponding to the texture unit based on the color channel information of each pixel in the flawless cloth image and the texture unit size; An image block processing module, used to determine the color histogram to be inspected, the HOG histogram to be inspected, the gradient map to be inspected and the color map to be inspected corresponding to each image block in the cloth image to be inspected; wherein the size of the image block is the same as the size of the texture unit; A type determination module is used to determine the defect type corresponding to the image block based on the reference color histogram, the reference HOG histogram, the reference gradient map, the reference color map, the color histogram to be checked, the HOG histogram to be checked, the gradient map to be checked, the color map to be checked and a preset type judgment network.

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

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.