Cloth flaw detection system based on YOLOV8
By combining a YOLOv8-based deep learning model with a robotic arm module, the low accuracy of traditional fabric defect detection technology on complex patterned fabrics is solved, achieving efficient and accurate defect detection applicable to a variety of fabric patterns.
Patent Information
- Application Number
- CN202511003612.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-18
AI Technical Summary
Existing fabric defect detection technologies have low accuracy when detecting fabrics with complex floral patterns or other non-periodic or irregular patterns, making it difficult to meet the high standards required by the modern textile industry.
The system employs a YOLOv8-based deep learning model combined with a robotic arm module and a conveyor belt module to achieve omnidirectional image acquisition and continuous transport of fabric. A visual recognition module is used for defect detection, and the system UI module provides real-time monitoring and operation.
It significantly improves the detection accuracy and applicability of fabrics with non-periodic or irregular patterns, enhances detection efficiency and intelligence, avoids the dependence of traditional algorithms on texture periodicity, and achieves composite detection of global and local data.
Smart Images

Figure CN120976113A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a detection system, and more specifically to a fabric defect detection system based on YOLOV8. Background Technology
[0002] In recent years, the textile industry has developed rapidly, and the market has increasingly higher requirements for fabric quality, especially in terms of the accuracy, efficiency, and reliability of defect detection. Traditional fabric defect detection methods are unable to meet these high standards, driving the innovation of new fabric defect detection technologies to adapt to the modern textile industry's demand for high-quality testing. Although some existing fabric defect detection technologies have shown good performance in theory or experiments, they still face many challenges in practical industrial applications.
[0003] To address the aforementioned issues, the existing technology includes an invention patent with publication number CN120219721A, entitled "A Method, Apparatus, and Readable Storage Medium for Detecting Fabric Defects," which discloses the detection of fabric defects through image recognition and analysis. However, this method employs traditional image processing algorithms, using methods such as Discrete Cosine Transform (DCT), Perceptual Hash (pHash), and Adaptive Window Search to extract the periodic patterns of the fabric to achieve fabric defect detection. Therefore, the detection range of the aforementioned existing technology is limited, relying primarily on the periodic patterns of the fabric. It is only suitable for fabrics with obvious repeating textures, such as plain weave and striped fabrics, and its detection accuracy drops significantly for non-periodic or irregular patterned fabrics such as jacquard and complex floral patterns. Summary of the Invention
[0004] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a fabric defect detection system based on YOLOV8 that can solve the problems existing in the prior art.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a fabric defect detection system based on YOLOv8, comprising: The visual recognition module includes a camera and a processing module to acquire fabric images through the camera, and after the fabric images are acquired, the processing module detects fabric defects based on the YOLOV8 model. The camera of the vision recognition module is mounted on the robotic arm module and moves under the control of the robotic arm module to move closer to or away from the fabric, or to move horizontally on the fabric. The conveyor belt module is used to transport the fabric to be inspected past the robotic arm module so that the camera of the vision recognition module can capture images. The system UI module has a display interface, which is divided into a functional area and a display area. The display area is used to display the real-time captured images, and the functional area is used to display various function buttons. As a further improvement of the present invention, the specific steps of the processing module for detecting fabric defects based on the YOLOv8 model are as follows: Step 1: Collect image data through a camera. Specifically, take pictures or videos with the camera, then cut the video into frames to increase the amount of data, and finally organize the images as image data. Step 2: Label the image data collected in Step 1. Use the LabelImg tool to label all images, then draw bounding boxes for the target objects in each image and assign a corresponding category to each box. The labeling format adopts the labeling format required by the YOLOv8 model, and generate a corresponding .txt file for each image. Step 3: Divide the image data labeled in Step 2 into a training set, a validation set, and a test set. Step 4: Determine the training parameters; Step 5: Based on the training parameters determined in Step 4, train the YOLOv8 model using the training set data divided in Step 3. Step 6: Use the confusion matrix to analyze the accuracy of the YOLOv8 model trained in Step 5, and select the YOLOv8 model with higher accuracy as the detection model. As a further improvement of the present invention, the control method of the robotic arm module is as follows: First, establish a connection between the system and the robotic arm, then instantiate the ElephantRobot class through Python API to call the function of mycobotpro630, and then drive the robotic arm to perform the required actions according to the function. The functions are as follows: The write_coords(coords,speed) function in the API allows the robotic arm to move according to a given Cartesian coordinate system, and its running speed is controlled by the set speed parameter. After sending the movement command, the function will run elephant_client.command_wait_done() to wait for the robotic arm to send a movement completion signal to the PC. As a further improvement of the present invention, the bottom of the robotic arm module has several I / O ports, one of which is connected to an alarm. When the I / O port outputs a high level, the alarm is triggered. The output level of the I / O port is achieved by calling the set_digital_out(pin_number,pin_signal) function. As a further improvement of the present invention, the system UI module uses OpenCV to connect to the camera to acquire and display image data captured by the camera. The specific steps for acquiring image data are as follows: Step 1: Capture new image frames using the camera's image capture function; Step 2: After capturing a new image in Step 1, first check if the current task list is empty. If it is empty, add the captured new image frame to the queue for processing. If the task list is not empty, wait for the tasks in the task list to complete. As a further improvement of the present invention, the system UI module displays images using QLabel, specifically: the image is identified by results=self.model.predict(source=frame,conf=0.4,augment=True,line_thickness=10,iou=0.3), and the image recognition result is saved to results; The confidence threshold is 0.4, augment=True indicates that data augmentation is initiated, and iou=0.3 indicates the threshold for cross-union ratio. As a further improvement of the present invention, the crossover-union ratio is calculated as follows: IoU = Intersection area of predicted bounding box and ground truth bounding box / Union area of predicted bounding box and ground truth bounding box. As a further improvement of the present invention, the system UI module has a log box in its functional area, which is used to display the camera startup time and robotic arm action information. The beneficial effects of this invention are as follows: Through the collaborative work of the visual recognition module, the robotic arm module, the conveyor belt module, and the system UI module, the robotic arm can adjust the position of the camera to acquire images from all directions, the conveyor belt realizes the continuous transport of fabrics, the processing module based on the YOLOv8 model can accurately detect defects in fabrics with various patterns, and the system UI module facilitates real-time monitoring and operation, significantly improving the detection accuracy and applicability of fabrics with non-periodic or irregular patterns, and improving the efficiency and intelligence level of fabric defect detection. Attached Figure Description
[0006] Figure 1 This is a schematic diagram of a confusion matrix; Figure 2 The curve for F; Figure 3 This is a schematic diagram of the loss function. Detailed Implementation
[0007] The present invention will now be described in further detail with reference to the embodiments shown in the accompanying drawings.
[0008] Reference Figures 1 to 3As shown, the YOLOv8-based fabric defect detection system in this embodiment includes a vision recognition module, a robotic arm module, a conveyor belt module, and a system UI module. The vision recognition module includes a camera and a processing module. After the camera captures images of the fabric, the processing module detects defects based on the YOLOv8 model. The robotic arm module is equipped with a camera and controls it to move closer to / away from the fabric or to translate across the fabric. The conveyor belt module transports the fabric to be inspected past the robotic arm. The system UI module's display interface is divided into a functional area and a display area, showing real-time images and function buttons.
[0009] The visual recognition module overcomes the limitations of traditional algorithms through deep learning models: after the camera captures images or videos, the processing module segments the video into frame images to increase the data volume. Through annotation, dataset partitioning, model training, and accuracy analysis, a detection model suitable for various types of fabrics is constructed. The flexible movement of the robotic arm module expands the acquisition range and can accurately focus on defective areas; the conveyor belt module enables continuous fabric transport, forming an assembly line detection system in conjunction with the robotic arm and visual recognition module; the system UI module displays the detection process in real time, facilitating operator monitoring. Compared to traditional algorithms that rely on the periodic texture of fabrics in the background technology, this system is based on the YOLOv8 model, which does not rely on texture periodicity. It can still maintain high detection accuracy for non-periodic patterned fabrics such as jacquard fabrics and complex floral patterns, significantly expanding the detection range.
[0010] Furthermore, the detection process of the processing module based on the YOLOv8 model is as follows: First, image data is acquired through a camera, including capturing images or videos and segmenting them into frames; then, the images are labeled using the LabelImg tool to draw bounding boxes for target objects and assign categories, generating a YOLOv8 format .txt label file; the labeled data is divided into training, validation, and test sets, and the model is trained using the training set after setting training parameters; finally, the model accuracy is analyzed using a confusion matrix, and the high-precision model is selected as the detection model. This process autonomously learns defect features from images through deep learning, eliminating the need for manual feature extraction rules. It solves the detection limitations of traditional algorithms due to their reliance on texture periodicity, significantly improving the accuracy of defect recognition for complex patterned fabrics. A specific example of analyzing model accuracy using a confusion matrix in this embodiment is as follows: Reference Figure 1As shown, the model performs poorly in recognizing defects such as loose threads and snagging, with 0.5 samples not being detected. Other defects are recognized well, especially thick threads, holes, and hot melt adhesive penetration, achieving a 100% recognition rate. The evaluation metrics in this embodiment are: border precision (BP), recall (R), F1 score (F1), and mean precision (mAP). Border precision reflects the similarity between the model's predicted borders and the ground truth borders; recall reflects the model's ability to detect positive samples; the F1 score reflects the model's overall performance in terms of precision and recall, and its ability to accurately identify most ground truth samples while maintaining a low false positive rate; mAP 0.5 refers to the mean precision when the intersection-over-union (IoU) threshold is 0.5, reflecting the model's basic target detection capability under relatively relaxed conditions.
[0011] The F1 curve, defined as the harmonic mean of precision and recall, is calculated using the following formula: Typically, when the confidence threshold (the probability threshold for a sample to be classified as a certain class) is low, many samples with low confidence will be classified as true, resulting in high recall but low precision. Conversely, when the confidence threshold is high, only samples with high confidence are classified as true, leading to more accurate class detection and higher precision (only samples with very high confidence will be classified as a certain class). Therefore, the F1 scores at both ends of the threshold are relatively low. Figure 2 As shown.
[0012] Based on the above confusion matrix, we can obtain the following: Figure 3 The loss function shown in this embodiment is: The loss function measures the degree to which the model's predictions differ from the actual values, and it largely determines the model's performance.
[0013] Localization loss (box_loss): The error between the predicted bounding box and the calibration box (GIoU). The smaller the value, the more accurate the localization. Confidence loss obj_loss: Calculates the network's confidence level; the lower the value, the more accurate the network's ability to identify the target. Classification loss cls_loss: calculates whether the anchor box is correctly classified with respect to its corresponding label. The smaller the value, the more accurate the classification. Precision: accuracy (number of correctly found positive classes / total number of positive classes found); Recall: The accuracy rate of finding true positives, i.e., how many positive samples were found (how many were recalled).
[0014] Furthermore, the robotic arm module is controlled via the Python API: after establishing a connection between the system and the robotic arm, the `ElephantRobot` class is instantiated, and the `mycobotpro630` function is called. The `write_coords(coords, speed)` function drives the robotic arm to move in a Cartesian coordinate system, with the speed controlled by parameters. After movement, the `elephant_client.command_wait_done()` function waits for a completion signal. This control method allows the robotic arm to flexibly adjust the camera position, enabling both global scanning of the fabric and focused acquisition of detailed images of local defect areas. Combined with continuous conveyor belt transport, this achieves "global + local" composite detection, avoiding the blind spots of traditional fixed cameras and improving the comprehensiveness of the detection.
[0015] Furthermore, an alarm is connected to the I / O port at the bottom of the robotic arm. The I / O port level is controlled by the `set_digital_out(pin_number,pin_signal)` function, and an alarm is triggered when the level is high. When a serious defect is detected, the system automatically triggers an alarm, facilitating timely handling by operators and improving the timeliness and accuracy of defective product screening.
[0016] Furthermore, the system's UI module acquires image data via OpenCV connection to a camera: after capturing a new image frame, it checks if the task list is empty; if empty, it adds the frame to the queue for processing; otherwise, it waits for the task to complete. The image is displayed using a QLabel, and the image is recognized using the `model.predict()` function. The results are saved to `results`, with a recognition confidence threshold of 0.4, data augmentation enabled, and an intersection-over-union (IoU) threshold of 0.3. The IoU is calculated as (IoU = area of intersection between predicted and ground truth bounding boxes / area of union). This design ensures synchronized image display and recognition, and the IoU parameter optimizes the localization accuracy of defective bounding boxes, resulting in more precise detection results.
[0017] The system's UI module includes a log box that displays camera startup time, robotic arm movement information, etc., facilitating traceability of the detection process and improving system maintainability and operational transparency.
[0018] In summary, this solution constructs a fully automated fabric defect detection system through the YOLOv8 deep learning model of the visual recognition module, the flexible data acquisition of the robotic arm module, the continuous conveyor belt module, and the real-time monitoring of the system UI module. Compared to the previous technologies, it eliminates the dependence on the periodicity of fabric texture, is applicable to various patterned fabrics, and significantly expands the detection range; the robotic arm and camera work together to achieve precise focusing and global scanning, avoiding blind spots; the system UI module provides real-time display and log recording, improving ease of operation and traceability. This system effectively solves the problem of low detection accuracy of traditional algorithms for complex patterned fabrics, providing an efficient and accurate technical solution for fabric quality inspection.
[0019] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A fabric defect detection system based on YOLOv8, characterized in that: include: The visual recognition module includes a camera and a processing module to acquire fabric images through the camera, and after the fabric images are acquired, the processing module detects fabric defects based on the YOLOV8 model. The camera of the vision recognition module is mounted on the robotic arm module and moves under the control of the robotic arm module to move closer to or away from the fabric, or to move horizontally on the fabric. The conveyor belt module is used to transport the fabric to be inspected past the robotic arm module so that the camera of the vision recognition module can capture images. The system UI module has a display interface, which is divided into a functional area and a display area. The display area is used to display the real-time captured images, and the functional area is used to display various function buttons.
2. The fabric defect detection system based on YOLOv8 according to claim 1, characterized in that: The specific steps of the processing module in detecting fabric defects based on the YOLOv8 model are as follows: Step 1: Collect image data through a camera. Specifically, take pictures or videos with the camera, then cut the video into frames to increase the amount of data, and finally organize the images as image data. Step 2: Label the image data collected in Step 1. Use the LabelImg tool to label all images, then draw bounding boxes for the target objects in each image and assign a corresponding category to each box. The labeling format adopts the labeling format required by the YOLOv8 model, and generate a corresponding .txt file for each image. Step 3: Divide the image data labeled in Step 2 into a training set, a validation set, and a test set. Step 4: Determine the training parameters; Step 5: Based on the training parameters determined in Step 4, train the YOLOv8 model using the training set data divided in Step 3. Step 6: Use the confusion matrix to analyze the accuracy of the YOLOv8 model trained in Step 5, and select the YOLOv8 model with higher accuracy as the detection model.
3. The fabric defect detection system based on YOLOv8 according to claim 1 or 2, characterized in that: The control method of the robotic arm module is as follows: First, establish a connection between the system and the robotic arm. Then, instantiate the ElephantRobot class through the Python API to call the function of mycobotpro630. After that, drive the robotic arm to perform the required actions according to the function. The functions are as follows: The write_coords(coords,speed) function in the API allows the robotic arm to move according to a given Cartesian coordinate system, and its running speed is controlled by the set speed parameter. After sending the movement command, the function will run elephant_client.command_wait_done() to wait for the robotic arm to send a movement completion signal to the PC.
4. The fabric defect detection system based on YOLOv8 according to claim 3, characterized in that: The bottom of the robotic arm module has several I / O ports, one of which is connected to an alarm. When the I / O port outputs a high level, the alarm is triggered. The output level of the I / O port is achieved by calling the set_digital_out(pin_number,pin_signal) function.
5. The fabric defect detection system based on YOLOv8 according to claim 1 or 2, characterized in that: The system UI module uses OpenCV to connect to the camera, acquire and display image data captured by the camera. The specific steps for acquiring image data are as follows: Step 1: Capture new image frames using the camera's image capture function; Step 2: After capturing a new image in Step 1, first check if the current task list is empty. If it is empty, add the captured new image frame to the queue for processing. If the task list is not empty, wait for the tasks in the task list to complete.
6. The fabric defect detection system based on YOLOv8 according to claim 5, characterized in that: The system UI module displays images using QLabel. Specifically, it identifies images by using `results=self.model.predict(source=frame,conf=0.4,augment=True,line_thickness=10,iou=0.3)` and saves the image recognition results to `results`. The confidence threshold is 0.4, augment=True indicates that data augmentation is initiated, and iou=0.3 indicates the threshold for cross-union ratio.
7. The fabric defect detection system based on YOLOv8 according to claim 6, characterized in that: The crossover-union ratio is calculated as follows: IoU = Intersection area of predicted bounding box and ground truth bounding box / Union area of predicted bounding box and ground truth bounding box.
8. The fabric defect detection system based on YOLOv8 according to claim 7, characterized in that: The system UI module has a log box within its functional area, which displays the camera startup time and robotic arm movement information.
Citation Information
Patent Citations
Cloth flaw detection method and device and readable storage medium
CN120219721A