Abstract
In textile factories, the most typical warp-knitted fabric defects include point defects, holes, and color differences. Traditional manual inspection methods are inefficient for detecting these defects. Existing intelligent inspection systems often have a single function. Factories require a real-time inspection system that can detect common defects and color difference. The YOLO (you only look once) neural network is faster than the two-stage neural network and has lower hardware requirements. The system’s color difference detection algorithm compares the color difference between the standard image and the image to be measured and records where the color difference value is exceeded. Finally, the comparison of the factory application proves that the designed system has good real-time performance and accuracy and can meet the fabric inspection requirements of warp-knitted fabric factories.
Warp-knitted fabric defects, which mainly include point defects, holes, and color difference, not only compromise fabric quality but also severely downgrade the benefits of operating a textile factory.1,2 The traditional manual inspection method has low detection efficiency and high labor intensity. In contrast, intelligent detection methods can improve inspection speed. Some these systems include the I-TEX2000 visual automatic inspection system of Israel EVS, the Fabriscan automatic visual inspection system of Uster Technologies in Switzerland, and the intelligent visual inspection system of the UK’s Shelton Vision. These visual inspection systems accelerate fabric inspection and improve cloth quality. 3 However, these systems are suitable for specific fabrics and cannot be used in the warp-knitted fabric detection process, and the color difference of warp-knitted fabrics is difficult to detect with these systems.
Some experts have investigated other cloth defect detection systems. For example, Jun et al. 4 analyzed the reason why the automatic fabric inspection machine is not widely used, concluding that the algorithm lacks adaptability to various defects. The fabric defect online detection system they proposed is suitable for the detection of plain-weave fabric defects. The neural network algorithm designed by them can only detect three types of defects: no-direction defects, warp-direction defects, and weft-direction defects. For specific defects, the model needs to be retrained, and the algorithm cannot detect the color difference of the cloth. Li and Zhang 5 developed an embedded machine vision system using Gabor filters and pulse-coupled neural networks (PCNN) to identify defects in warp-knitted fabrics automatically. First, Gabor filters are employed to enhance the contrast of images captured by a CMOS sensor. Second, defect areas are segmented by the PCNN with adaptive parameter settings. Soyaslan and Karataş 6 developed a fabric defect detection device based on an artificial vision system, which mainly detects loop drops, fly defects, grease spots, cross-striped defects, hole defects, and pilling defects in knitted pile fabric. Hanbay et al. 7 designed another fabric defect detection system. The algorithm is based on Fourier transform to extract the texture features of fabric images to detect fabric surface defects. They tested the system on a circular knitting machine to realize the automatic detection of fabric defects under industrial conditions. Bai et al. 8 designed an automatic detection system for fabric defects based on machine vision. The system uses digital image processing technology to realize the functions of fabric defect detection and information storage. It adopts a two-step detection method from rough inspection to simplification, which reduces hardware costs, simplifies operation, and enhances the practicability of the fabric inspection system. Raheja et al. 9 designed a real-time fabric defect detection system on the STM320DM642 platform. The platform algorithm uses the gray-level co-occurrence matrix to extract the texture characteristics of the fabric image and applies the sliding window technology to the algorithm to calculate the texture energy in the window to determine the window threshold. The algorithm depends on the texture characteristics of the fabric and is greatly affected by the threshold. Different thresholds need to be set for different fabrics, and the application of the system has certain limitations. Han and Yu 10 designed a fabric defect detection system using a convolution-denoising autoencoder. Li et al. 11 investigated a color difference detection system for the continuous printing and dyeing of fabrics. The algorithms used in these systems, such as faster recurrent convolutional network (R-CNN), 12 cascade R-CNN, 13 and other neural network cloth defect detection algorithms, have unsatisfactory real-time performance when deployed in factories. Moreover, a warp-knitted fabric defect detection system needs to have faster intelligent algorithms and mature software interfaces to adapt to real-time production.
In this research, an intelligent inspection system was designed for the warp-knitted fabric factory, which integrates defect and color difference detection algorithms. A hardware platform for warp-knitted fabric inspection was designed, and the software interface of the defect inspection system was written using C#wiform. The system can detect five types of warp-knitted fabric defects and color difference. After factory testing, the system can meet the cloth detection speed of 0.7–0.85 m/s, and the detection accuracy rate is >90%.
Defect detection system
The defect detection system consists of hardware and software systems. The hardware system mainly includes image acquisition modules (i.e., cameras, encoders, and image acquisition cards), D65 standard light source modules, and mechanical transmission modules. The hardware system mainly maintains a collection of warp-knitted fabric images. Figure 1 shows a schematic of the warp-knitted fabric defect detection system platform.

Schematic of fabric defect detection hardware system.
The computer used in the hardware system is an industrial computer. The computer’s experimental environment is a 64-bit Windows 10 operating system, Intel® Xeon® CPU E3-1220 V3 3.10 GHz processor, NVIDIA GeForce GTX 2080TI GPU, and 64 GB memory. In addition, the camera uses DALSA Linea 4 K CL, and the image acquisition card is an Xtium-CL MX4.
The warp-knitted fabric defect detection system uses two cameras to capture fabric images. The resolution of each image is 1024 × 4096 pixels, which corresponds to a 0.25 mm warp-knitted fabric. The cloth drives the friction wheel of the encoder through friction, allowing the encoder to send a pulse signal to the image acquisition card to control the camera fragment.
The software system is composed of three modules: camera setting, defect detection, and history query. It mainly implements image processing and displays fabric detection results. The defect detection interface is primarily composed of a cloth defect map album, defect count bar graph, defect map module, and standard color sample selection module. Figure 2 shows the system interface design of the cloth defect detection software. The software system also interacts with the database, as shown in Figure 3, which illustrates the system’s connection to the database.

Fabric defect detection software system interface.

Schematic diagram of the connection between the system and database.
The setting module is utilized to set the initial state of the camera. With this module, the configuration file is imported, and the system state parameters are recorded. The detection module is the system’s common module; the interface diagram of this module is shown in Figure 2. The album area displays the detected fabric defects. The “New” button is activated by an operator. Before operating the cloth detection system, the cloth selected for testing is numbered, and certain physical parameters are recorded (including the fabric width and ID of the cloth inspector). The system initiates the detection process only when the “Start” button is clicked. The “Pause” button may be used if the inspector has certain doubts regarding the inspected fabric; clicking this button halts detection until it is clicked again. The “Upload” button uploads the detected data to the server. The “Grab” and “Select” buttons at the bottom of the interface are employed to select the standard fabric image for color difference detection and fabric image comparison. The query history module is applied to seek information regarding fabric defect and color difference.
At the start of detection, the system needs to be trained to obtain a stable defect detection model. During detection, the collected cloth image is inputted into the system, and the defect detection model inspects for cloth defects. The color difference detection mainly uses image processing technology to compare the standard cloth image color with the color of the tested cloth image. The system test results are outputted and then stored in the database. Figure 4 shows the flow chart of the defect detection algorithm.

Flow chart of defect detection algorithm.
The detection algorithm includes two stages: training and detection. In the training stage, the existing warp-knitted fabric defect images are used to train the YOLO (you only look once) 14 neural network model. The defect image must be labelled by labelme and then inputted into the model. If the collated defect images are insufficient, additional images may be generated using an anti-learning network and other generation algorithms. In this study, the model requires 12,000 defect images, each 300 × 300 pixels in size.
In the detection stage, the image size of the warp-knitted fabric to be tested is 1024 × 4096 pixels, corresponding to an actual fabric size of 0.25 m×1 m. Image processing mainly eliminates the edge non-cloth image area from each collected warp-knitted fabric image, down-samples the image to transform it into 600 × 2400 pixels, and finally divides it into 16 images, each measuring 300 × 300 pixels. The detection software uses a multi-thread processing method to separate the images captured by the two cameras and only merge the detection results. The images collected by two cameras need to be stitched and processed by an image processing algorithm. Scale-invariant feature transform 15 is used to match the key points at the junction of two images.
Fabric defect detection algorithm
The core of the warp-knitted fabric defect detection system is the detection algorithm. With the development of artificial intelligence, the use of deep learning algorithms to detect fabric defects has become a research focus. At present, the deep learning methods typically used for fabric defect detection are faster R-CNN, 16 single shot multi-box detector (SSD), 17 and YOLO algorithms.
The principle of the faster R-CNN algorithm is illustrated in Figure 5. The key to this algorithm is to provide numerous anchor candidate boxes for cloth defects through the region proposal network (RPN) operation. This principle is shown in Figure 6.

Faster recurrent convolutional network (R-CNN) algorithm schematic.

Region proposal network operation principle.
The size of each fabric defect image is 300 × 300 pixels. Consider how the faster R-CNN algorithm processes the image as an example. First, the input image of the fabric is scaled. Then, neural network convolution and pooling operations are applied. The size of the defect feature map of the fabric is 62 × 37 pixels. In this instance, the number of anchor boxes in the fabric defect feature map is 20,000 (62 × 37×9), which contains all the defects in the cloth image. Although the detection accuracy is high, the detection speed is slow and cannot satisfy real-time requirements.
Two-stage neural networks, such as the faster R-CNN algorithm, are highly accurate in object detection. Compared to two-stage neural networks, the SSD and YOLO are typical lightweight one-stage neural networks. Compared to the faster R-CNN and other algorithms, the detection speeds of these two lightweight algorithms have been considerably improved. The model diagram of the SSD algorithm without an RPN process is illustrated in Figure 7.

Single shot multi-box detector (SSD) algorithm model diagram. 17
The detection speed of SSD is three times faster than that of the faster R-CNN algorithm. This speed can reach 16 fps, and 16 images of 300 × 300-pixel warp-knitted fabrics can be detected per second. The actual fabric inspection speed is only 0.2 m/s, which cannot satisfy the required factory inspection speed. In contrast, the YOLO algorithm is a faster one-stage object detection neural network capable of fabric inspection at a speed exceeding 0.5 m/s.
Compared to the faster R-CNN algorithm, YOLO uses a convolutional neural network for simultaneous detection and positioning. The YOLO model principle is shown in Figure 8. As the figure indicates, because the RPN step is omitted, the target detection time is significantly shortened. Nevertheless, detecting the category and positioning of fabric defects is accomplished using the same process. The specific location information of fabric defects is obtained through border regression, and the category information and confidence of these defects are checked through the classification score.

YOLO (you only look once) algorithm.
Each grid prediction determines whether defects are present in the cloth grid and then calculates the confidence value of the two anchor boxes under the grid. Using this value, the classification and positioning performance of the fabric defect prediction in the model reinspection process can be obtained.
The 300 × 300-pixel fabric defect image is inputted into the YOLO v1 model. Then, the image is scaled up to 448 × 448 pixels and divided into 7 × 7 grids. The total number of predicted anchor boxes is 98 (7 × 7 × 2); this is considerably less than the 20,000 anchor candidate boxes predicted by the faster R-CNN model RPN. Thus, although the fabric defect detection speed has been improved, the detection accuracy has considerably deteriorated.
To ensure that the defect detection algorithm satisfies the factory requirements, this study designs an improved deep learning algorithm for the online detection of cloth defects based on the YOLO neural network model. Using VGG-16 as the basic network, the modules of the depth-wise separable convolution (DSC) 18 and atrous spatial pyramid pooling (ASPP) 19 are designed. To balance the accuracy and speed of the fabric defect detection algorithm, the loss and optimization functions are improved. Furthermore, the evaluation standard for the fabric defect detection model is established.
In 2014, VGG-Nets 20 was introduced. The size of the convolution kernel used by the network is either 3 × 3 or 1 × 1, which can effectively reduce network parameters. This type of network uses a layer-by-layer training method to increase the number of network layers continuously. From the 11 layers of the A model to the 19 layers of the E model, 16 layers (represented by VGG-16) exhibit the best performance. By increasing the convolution kernel, the detection accuracy of the defect model can be improved to a certain extent. However, this can substantially increase the number of parameters, increasing the defect detection calculation and retarding the algorithm. To resolve this, an ASPP module satisfying the defect characteristics was designed, as shown in Figure 9.

Atrous spatial pyramid pooling (ASPP) module.
The feature map uses atrous convolution at different sampling rates. After the ASPP operation, the neural network can obtain more scale features from the cloth image information.
The defect feature map of the warp-knitted fabric in the convolution process is 10 × 10×512 pixels, where 10 × 10 is the size of the defect feature, and 512 represents the number of features. When the convolution core is 3 × 3, the number of convolutions is 1024 and the step is 2; the filling is in the same form. After the convolution operation, the feature map obtained is 5 × 5×1024, and the total calculation quantity of floating point operations (FLOPs) is 3 × 3×2 × 5×5 ×512×1024. Figure 9 shows the traditional convolution process. DSC can reduce the number of network parameters. First, convolution is performed on the defect feature channel of the cloth to obtain a 5 × 5×512 defect feature map. Then, 1024 convolutions are used for the defect feature fusion operation. Finally, the feature output is 5 × 5×1024; this is the same as that of traditional convolution. Figure 10 shows a deep separable convolution process. The total FLOPs calculation is 26,444 800, which is approximately 11.2% of traditional convolution.

Depth-wise separable convolution (DSC) process.
The final overall framework of the fabric defect detection model consisting of the designed VGG-16 basic network combined with the ASPP and DSC modules is summarized in Table 1.
Fabric defect detection model
DSC: depth-wise separable convolution; ASPP: atrous spatial pyramid pooling.
The fabric defect detection deep learning network model adopts the focal loss function
21
:
The optimization function of the model uses the AdaBound algorithm,
22
which is expressed as:
As an optimization function of the model, AdaBound can accelerate the convergence speed, reduce the development cost, and derive a better solution.
Figure 11 shows the result of the detected warp-knitted fabric defect using the improved YOLO neural network. The designed YOLO network can detect five types of the most common warp-knitted fabric defects observed in factories: holes, creases, dirties, point defects, and broken yarns. In the figure, the text and value represent the type of defect and confidence level, respectively.

Five types of warp-knitted fabric defect detection results.
Table 2 gives a comparison of five kinds of warp-knitted fabric defects detected by faster-RCNN, SSD, and the improved YOLO algorithm. During the test, 200 images measuring 300 × 300 pixels were selected for each defect.
Comparison of faster R-CNN, SSD, and improved YOLO detection
R-CNN: recurrent convolutional network; SSD: single shot multi-box detector: YOLO: you only look once.
Based on the list in Table 2, the improved YOLO defect detection algorithm detects 50 images per second on average. Hence, it can inspect two or three actual images each measuring 1024 × 4096 pixels, and the inspection speed can reach 0.5–0.7 m/s.
Color difference detection algorithm
The proposed color difference detection system uses the CIELAB color space. The collected image is in the RGB (red, green, and blue) format, and the RGB model of the color image considerably relies on the hardware device. Consequently, the color difference is not well represented in the RGB color space. In contrast, the CIELAB color model does not depend on the hardware system and can fully reflect the colors that the human eye can perceive. Accordingly, the CIELAB color space was employed in the defect detection system to calculate the color variations in the cloth.
The RGB color space cannot be directly converted to that of CIELAB. Generally, the three channels of the RGB space are first converted into the three intermediate color spaces of XYZ. Then, the three channels of XYZ are converted into the CIELAB space. Finally, the color difference formula calculates the color variation; a phase alternate line system digital camera is used. The conversion formula from the RGB color space to that of XYZ is:
The conversion formula from XYZ space to CIELAB space is:
In the formula, Xn, Yn, and Zn are the calculated X, Y, and Z values, respectively, when each of the value of the three RGB channels are 255. Accordingly, the conversion of RGB color space to CIELAB is achieved.
Chromatic aberration detection compares the standard image to the image to be tested to determine whether chromatic aberration exists in the image. In the textile industry, the CMC (l:c) formula is applied to calculate the color difference, with l:c generally taken as 2:1
19
; CMC (l:c) is expressed as:
Calculating the color difference requires a color standard map and color difference threshold. The standard color map in this study was obtained from a factory standard library. Before testing, the standard map is loaded, and the standard threshold is set according to the standard factory color difference. Finally, they are modified manually.
Factory verification
The online inspection and testing system of fabric defects can achieve an inspection speed of 0.5–0.7 m/s. At this speed, the image can be processed without frame loss, and the software runs smoothly without stuttering. The factory requires a speed of 30 m/min, which is completely satisfied by the detection speed of the proposed system. Hence, the system may be used for intelligent fabric inspection operations to satisfy real-time requirements.
The cloth movement speed is set to 0.7 m/s to detect defects and color difference. First, the detection rate, false detection rate, and detection accuracy of test defects have to be determined. A total of 100 defects were marked on the cloth in advance, and the system successfully detected 93 of these. The detection accuracy of the intelligent detection system for warp-knitted fabric defects is therefore 93%. Table 3 shows part of the test results of purple warp-knitted fabrics detected by intelligent defect detection systems in the factory.
The factory detection test results of intelligent defect detection systems
The proposed detection system results were compared to those of a hand-held color difference detector, as summarized in Table 4. The comparison indicates that the results of the hand-held color difference detector are fundamentally consistent with those of the detection system. However, they differ in the ΔECMC values. The reason for this is that the system cannot fully simulate the detection environment of the hand-held color difference detector. Moreover, their measuring methods differ: the hand-held detector adopts the spectrophotometer method, whereas the system uses a digital camera to capture images and analyze the color variation. Although the hand-held color difference detector is more accurate than the proposed defect detection system, it can only be used for sampling.
Hand-held color detector and detection systems test results
Conclusion
This study designed an intelligent fabric inspection system for warp-knitted fabric factories. The algorithm of the system is capable of detecting defects and color differences in the fabric, and the designed system provides an idea for the development of an intelligent textile inspection system.
The system uses DSC and ASPP to improve the YOLO algorithm, which is intended to have a faster detection speed than the R-CNN and SSD algorithms in order to adapt to online inspection of fine woven fabrics. In addition, the system can detect fabric color differences using the CMC (2:1) color difference calculation formula. The proposed warp-knitted fabric detection system can accomplish cloth image collection, real-time image processing, defect detection, and data storage. The combination of neural network algorithms with machine vision for cloth inspection and deployment in factories is anticipated to be an important research direction for artificial intelligence.
Footnotes
Declaration of conflicting interests
The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The authors disclosed receipt of the following financial support for the research, authorship, and/or publication of the article: This work was supported by the National Key Research and Development Project (grant number: 2018YFB1308800).
