Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, the method for detecting a cloth defect of the embodiment of the present invention includes the following steps:
and S1, acquiring a sample data set, wherein the sample data set comprises a plurality of sample product images with cloth defects and a plurality of sample product images without cloth defects.
In one embodiment of the present invention, a large number of sample products can be photographed by a camera, for example, a piece of cloth can be photographed by an industrial camera, and the piece of cloth can be lighted by an artificial or natural light source during photographing, so as to obtain a high-quality sample product image. Whether the sample product has cloth defects or not can be used as a sample label and stored together with the sample product image to form a sample data set.
In an embodiment of the present invention, a line scan camera may be selected to photograph the rolled sample cloth, that is, photograph the sample cloth in a line shape, and then splice the sample cloth into the whole sample cloth image.
In one embodiment of the invention, the ratio of the presence of cloth defects to the absence of cloth defects in the sample product may be at or near 1: 1.
And S2, determining the cloth type corresponding to the sample data set.
Wherein, the cloth type comprises pure color cloth and colored woven cloth. In one embodiment of the invention, the cloth type of the sample product in the sample data set can be automatically determined through image recognition, and the cloth type of the sample product in the sample data set can also be manually input.
And S3, training the neural network in a corresponding training mode through the sample data set according to the cloth type to obtain a corresponding cloth defect detection model.
In one embodiment of the present invention, the neural network is a convolutional neural network, which may be, for example, a VGG network or an inclusion network.
The convolutional neural network includes an input layer, a hidden layer, and an output layer, wherein the hidden layer includes convolutional layers. At the beginning of training, the filter of the convolutional layer is completely random and will not activate, i.e., detect, any features. A blank filter is modified in weight to detect a specific mode, and the whole process is like feedback in engineering. Through such feedback, the convolutional neural network can learn the core features to be judged by itself.
For each sample product image data, the training process may include image input, feature extraction, result prediction, result comparison, and feature memorization. Specifically, the convolutional neural network can match each feature with a corresponding sample label, the correctly matched features are retained by the memory module, the incorrectly matched features are ignored through the loss parameter, and a large number of pictures are continuously iterated through multilayer convolutional deep learning, so that the core features which the convolutional neural network wants to memorize are finally learned, and different core features are classified. The finally trained neural network, namely the cloth defect detection model, can detect a new image according to the characteristics.
In one embodiment of the invention, the images in the sample data set being trained are grayscale images.
When the cloth type is pure-color cloth, firstly, variable-scale fuzzy averaging is used, 4 pixels of an original sample product image are combined into a pixel point with an average value, then specific value taking is carried out on the value point of the whole image, the attention degree of the specific value area is raised, matting operation is carried out on the specific value area, then a classification algorithm is built in a neural network, and the neural network is trained through an image obtained through the matting operation.
When the cloth type is colored woven cloth, the defects on the colored woven cloth can be labeled manually, a target detection algorithm is constructed in the neural network, and the neural network is trained through the image after the defects are labeled. Wherein, the target can be presented through the center point of the target, and then some attributes of the target, such as size, dimension, orientation, and pos, are regressed at the position of the center point. The target detection problem becomes a standard key point estimation problem, only the image is transmitted into a full convolution network to obtain a thermodynamic diagram, the peak point of the thermodynamic diagram is a central point, and the peak point position of each characteristic diagram predicts the width and height information of the target. The model training adopts standard supervised learning, and the inference is a single forward propagation network.
The algorithm optimization aiming at the two different types of cloth is based on the requirement of a target scene on the recognition speed. The fuzzy average can reduce the processing time of the image, and the central point presenting target can also obviously improve the processing speed of the image.
And S4, acquiring the image of the product to be detected, and determining the cloth type in the image of the product to be detected.
In one embodiment of the invention, the defect detection can be carried out on the rolled cloth to be detected, and the image of the product to be detected can be obtained by shooting with a line scanning camera, namely shooting through one line and splicing into the whole image of the cloth to be detected.
The mode of determining the cloth type in the image of the product to be detected is the same as the mode of determining the cloth type of the sample data set sample product.
Further, in the embodiment of the present invention, if the sample product image acquired in step S1 and the product image to be detected acquired in this step include an object other than cloth, for example, an environmental background, it is also possible to acquire a cloth region in the image by a template matching method and intercept the cloth region as an image for training and detection. Specifically, referring to fig. 2, the sample product image may first be decomposed into a matrix form, and the features in the matrix form image may be arranged according to coordinates. After the matrixing process, the features in the image are obvious, for example, as shown in fig. 2, the pixel with the pixel value of 30 can be selected conveniently and quickly. The method can run a function matchTemplate through OpenCV, and match the cloth template image with the regions of the whole image with corresponding sizes one by one, so as to obtain the pixel region and the pixel coordinates of the cloth.
And S5, inputting the image of the product to be detected with the determined cloth type into a corresponding cloth defect detection model to judge whether the cloth defect exists.
In one embodiment of the invention, the image of the product to be inspected for which the inspection is performed is a gray scale image. And inputting the gray-scale cloth image to be detected into the cloth defect detection model to obtain an output result of whether the cloth defect exists or not.
According to the embodiment of the invention, through training and recognition of the gray level image, the cloth defect detection model is sensitive to gray level change, so that the method can be used for realizing cloth hole, stain and warp miss weft detection and filtering the influence of wrinkles, dust and shadows on detection, is not sensitive to color, and can be suitable for cloth with different colors, and is wide in application; through the training of a large amount of sample product images, the cloth defect detection model is sensitive to lines and shapes in specific shapes, so that the cloth defect detection model can be used for realizing the silk drawing and stain detection of cloth, is insensitive to repeated gray patterns, and can screen out the interference of original patterns of the yarn-dyed fabric.
In an embodiment of the invention, the cloth defect detection method can be used for detecting the defects of cloth rolled at 30m/min in a host configured by a 2080ti display card, an i5CPU and a 16G memory.
In addition, when the detection result is obtained, corresponding detection result information can be sent out, for example, alarm information can be sent out when the cloth defect is detected, high and low level signals can be output, or operation indication signals can be sent out.
According to the cloth defect detection method provided by the embodiment of the invention, the neural network training is carried out by adopting the corresponding training mode aiming at different cloth types to obtain the cloth defect detection model, and whether cloth defects exist in the cloth to be detected of the corresponding type is detected through the cloth defect detection model, so that the detection speed is high, the efficiency is high, the labor cost is low, the detection accuracy is high, and the applicability is wide.
Corresponding to the cloth defect detection method of the embodiment, the invention also provides a cloth defect detection device.
As shown in fig. 3, the cloth defect detecting apparatus according to the embodiment of the present invention includes a first obtaining module 10, a first determining module 20, a training module 30, a second obtaining module 40, a second determining module 50, and a detecting module 60. The first obtaining module 10 is configured to obtain a sample data set, where the sample data set includes a plurality of sample product images with cloth defects and a plurality of sample product images without cloth defects; the first determining module 20 is configured to determine a cloth type corresponding to the sample data set; the training module 30 is configured to train the neural network in a corresponding training manner through the sample data set according to the type of the piece goods, so as to obtain a corresponding piece goods defect detection model; the second obtaining module 40 is used for obtaining an image of a product to be detected; the second determining module 50 is used for determining the cloth type in the image of the product to be detected; the detection module 60 is configured to input the image of the to-be-detected product with the determined cloth type into a corresponding cloth defect detection model to determine whether a cloth defect exists.
The detailed implementation of the cloth defect detecting device according to the embodiment of the present invention can refer to the embodiments of the cloth defect detecting method, and will not be described herein again.
According to the cloth defect detection device provided by the embodiment of the invention, the neural network training is carried out by adopting the corresponding training mode aiming at different cloth types to obtain the cloth defect detection model, and whether the cloth to be detected of the corresponding type has defects is detected through the cloth defect detection model, so that the detection speed is high, the efficiency is high, the labor cost is low, the detection accuracy is high, and the applicability is wide.
The invention further provides a computer device corresponding to the embodiment.
The computer device of the embodiment of the invention comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, and when the processor executes the computer program, the cloth defect detection method according to the embodiment of the invention can be realized.
The computer equipment of the embodiment of the invention also comprises a display card, a mainboard and the like, which are connected with the camera through the connecting piece to run a linux or Windows10 system.
According to the computer equipment provided by the embodiment of the invention, when the processor executes the computer program stored on the memory, the neural network training is carried out by adopting the corresponding training mode aiming at different cloth types to obtain the cloth defect detection model, and whether the cloth to be detected of the corresponding type has defects is detected by the cloth defect detection model, so that the detection speed is high, the efficiency is high, the labor cost is low, the detection accuracy is high, and the applicability is wide.
The invention also provides a non-transitory computer readable storage medium corresponding to the above embodiment.
A non-transitory computer-readable storage medium of an embodiment of the present invention has stored thereon a computer program which, when executed by a processor, can implement the cloth defect detection method according to the above-described embodiment of the present invention.
According to the non-transitory computer-readable storage medium of the embodiment of the invention, when the processor executes the computer program stored on the processor, the neural network training is performed by adopting the corresponding training mode according to different cloth types to obtain the cloth defect detection model, and the cloth defect detection model is used for detecting whether the cloth to be detected of the corresponding type has defects or not, so that the detection speed is high, the efficiency is high, the labor cost is low, the detection accuracy is high, and the applicability is wide.
The present invention also provides a computer program product corresponding to the above embodiments.
When the instructions in the computer program product of the embodiment of the present invention are executed by the processor, the cloth defect detecting method according to the above-mentioned embodiment of the present invention can be performed.
According to the computer program product of the embodiment of the invention, when the processor executes the instruction, the neural network training is carried out by adopting the corresponding training mode aiming at different cloth types to obtain the cloth defect detection model, and whether the cloth to be detected of the corresponding type has defects is detected by the cloth defect detection model, so that the detection speed is high, the efficiency is high, the labor cost is low, the detection accuracy is high, and the applicability is wide.
In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The meaning of "plurality" is two or more unless specifically limited otherwise.
In the present invention, unless otherwise expressly stated or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally formed; can be mechanically or electrically connected; either directly or indirectly through intervening media, either internally or in any other relationship. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In the present invention, unless otherwise expressly stated or limited, the first feature "on" or "under" the second feature may be directly contacting the first and second features or indirectly contacting the first and second features through an intermediate. Also, a first feature "on," "over," and "above" a second feature may be directly or diagonally above the second feature, or may simply indicate that the first feature is at a higher level than the second feature. A first feature being "under," "below," and "beneath" a second feature may be directly under or obliquely under the first feature, or may simply mean that the first feature is at a lesser elevation than the second feature.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.