Woolen sweater defect detection method

Through deep learning technology and YOLO algorithm, automatic positioning and classification of wool sweater defect detection is achieved, solving the problems of high detection cost, time-consuming and low accuracy in the existing technology, and significantly improving the detection efficiency and accuracy.

CN119477791APending Publication Date: 2025-02-18TONGXIANG KAILONG TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411318396.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The existing cardigan defect detection technology has the problems of high detection cost, time-consuming and low accuracy.

Method used

A cardigan defect detection method based on deep learning is adopted, and through steps such as data preprocessing, model construction, model training and defect detection, and using technologies such as YOLO algorithm and attention mechanism to achieve automatic positioning and classification of defect areas.

Benefits of technology

It significantly improves the efficiency, accuracy and automation level of wool sweater defect detection, reduces detection costs, reduces manual intervention, and improves product quality and customer satisfaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure SMS_1
    Figure SMS_1
  • Figure SMS_2
    Figure SMS_2
  • Figure SMS_3
    Figure SMS_3
Patent Text Reader

Abstract

The invention relates to a woolen sweater defect detection method. The method is characterized by comprising the following four main steps: a data preprocessing step, a model construction step, a model training step and a defect detection step. Wherein in the model construction step, strategies such as an attention mechanism and a network structure optimization are introduced, so that the identification capability of the model on woolen sweater defects is improved; in the detection process, automatic positioning and classification of defect areas are realized through a series of key functions. The method is high in detection efficiency, low in comprehensive detection cost and high in detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a wool sweater defect detection method, which is used for quality inspection of finished wool sweaters and is mainly used in the textile industry. Background Art

[0002] The current wool sweater defect detection technology mainly includes physical detection methods. The existing physical detection methods have the following limitations: the overall cost of detection is high, the detection process is time-consuming, and the detection accuracy is not high. For example, the fluorescent lamp projection method, although the cost of the equipment used is low and the operation is relatively simple, the detection process is time-consuming and the technical requirements of the detection personnel are high, which increases the overall cost of detection. In addition, because the detection process is greatly affected by the human factors of the detection personnel, the accuracy of the detection results is affected. Summary of the invention

[0003] The purpose of the present invention is to overcome the above-mentioned deficiencies in the prior art and to provide a method for detecting defects in a wool sweater with high detection efficiency, low comprehensive detection cost and high detection accuracy.

[0004] The technical solution adopted by the present invention to solve the above problem is: the wool sweater defect detection method is characterized in that the steps are as follows: it includes four main steps: data preprocessing step, model construction step, model training step, and defect detection step; wherein, the model construction step improves the model's recognition ability of wool sweater defects by introducing attention mechanism, optimizing network structure and other strategies; in the detection process, automatic positioning and classification of defect areas are realized through a series of key functions; The key functions and their uses are as follows: (1) Data preprocessing function In the data preprocessing step, the sweater images are cropped, scaled, rotated, and other data enhancement processes are performed to increase the diversity and scale of the data set and improve the generalization ability of the model. At the same time, the images are normalized to ensure the consistency of the input data. (2) Model building function In the model building step, a deep learning model is built based on the basic framework of the YOLO algorithm and the specific needs of sweater defect detection. The model building function is responsible for defining the model's input layer, backbone network (Backbone), feature fusion network (Neck) and output layer (Head), and integrating optimization strategies such as the attention mechanism. (3) Loss calculation function In the model training step, the difference between the predicted result and the true label, i.e. the loss value, is calculated; the loss calculation function usually includes three parts: coordinate loss, confidence loss and category loss. The model parameters are optimized through the back propagation algorithm to reduce the overall loss value and improve the model performance; (4) Non-maximum suppression function (NMS) In the defect detection step, in the model output stage, there may be multiple predicted bounding boxes for the same target. The non-maximum suppression function compares the confidence and overlap of the bounding boxes, retains the bounding boxes with the highest confidence and the lowest overlap, and removes the redundant bounding boxes, thereby improving the accuracy and efficiency of detection. (5) Post-processing function In the defect detection step, the bounding box processed by the non-maximum suppression function is further processed, such as through bounding box adjustment and category label mapping, to generate the final defect detection result; the post-processing function is also responsible for visualizing the detection results for users to intuitively view and analyze.

[0005] Preferably, the steps of the present invention are as follows: (1) Collect defect image datasets of wool sweaters and annotate them, including information such as defect category and location. Use high-definition cameras or image scanning equipment to collect image data of wool sweaters, including image data of the front, back, and key details. Ensure that the images are clear and unblurred and can accurately reflect the surface condition of the sweaters. Preprocess the collected images, including cropping, scaling, denoising, and other operations, to ensure the uniformity and consistency of the image data. At the same time, annotate the sweaters in the images, clearly mark the locations and types of defects, and form annotated datasets. (2) Use data preprocessing functions to enhance and normalize the image dataset; divide the preprocessed labeled dataset into training set, validation set, and test set for model training, validation, and testing; (3) Define and initialize the YOLO model through the model building function, including the backbone network, feature fusion network and output layer; use the deep learning framework (PyTorch) to build the improved YOLO model and configure the corresponding training parameters; use the training set to train the improved YOLO model, and optimize the model parameters through continuous iteration to improve the detection accuracy of the model; (4) Use the training set to train the model, use the loss calculation function to evaluate the model performance, and optimize the model parameters through the back propagation algorithm; (5) Use the validation set to evaluate the model, adjust the model structure and parameters, use the validation set to verify the model during training, calculate the model's performance indicators such as detection accuracy, recall rate, F1 score, etc. based on the test results, and evaluate whether the model's detection effect meets actual needs; (6) Apply the trained model to actual sweater images, output defect detection results through non-maximum suppression function and post-processing function, and realize automatic detection function; (7) The trained model is deployed on a self-developed device that can be installed on a sweater production machine to perform real-time inspection of sweaters produced by the sweater production machine, and defective products are discovered and marked in a timely manner.

[0006] Preferably, the structure diagram of the basic framework of the YOLO algorithm of the present invention generally includes the following key parts: (1) Backbone network: ① Focus layer: used to slice the input image and process it through the convolution layer. This step increases the number of channels of the input image from 3 to 64 and reduces the image size by half; ②CSPDarknet53: YOLOv5 uses Darknet53 with CSP (Cross Stage Partial) structure as the backbone network. This structure improves the efficiency of feature reuse, reduces the amount of calculation, and also improves the performance of the model; (2) Neck network: ①SPP (Spatial Pyramid Pooling): Based on the backbone network, multi-scale features are extracted through the SPP module; the SPP module extracts different features through maximum pooling layers of different sizes, so that the model can handle targets of different scales; ②PANet (Path Aggregation Network): used to further fuse features of different scales. PANet enhances the accuracy of target detection through top-down and bottom-up feature fusion; (3) Detection head (Head): YOLO Head: The detection head of YOLOv5 is responsible for target classification and localization. It performs multi-scale prediction through three feature maps of different scales (small, medium, and large), which enables YOLOv5 to detect targets of different sizes. (4) Output layer: The output layer generates prediction boxes of three scales, each of which contains the category, confidence, and location information of the bounding box.

[0007] Preferably, the basic formula of YOLOv5 of the present invention mainly involves the key parts of target detection, including the calculation of loss function, bounding box prediction, and the calculation of confidence and classification probability. The following are some key formulas: (1) Bounding Box Prediction: In the YOLO series of models, each bounding box prediction is represented by the center coordinates (x, y), width w, and height h; The predicted center coordinates and width and height are usually calculated using the following formula: Among them, σ represents the sigmoid function, t x ,t y ,t w ,t h is the output of the network prediction, c x 、c y is the offset of the current grid point, p w and p h are the width and height of the preset anchor box, and e is a natural constant; (2) Calculation of loss function: The loss function of YOLOv5 consists of three parts: classification loss, bounding box regression loss, and object confidence loss. ① Bounding box regression loss: GIoU (Generalized Intersection over Union) is usually used as the loss function: Among them, A and B are the areas of the predicted box and the real box respectively, C is the area of ​​the bounding box (that is, the smallest closed rectangle containing A and B), and IoU represents the intersection-over-union ratio of the predicted box and the real box; ②Classification loss: Binary Cross-Entropy Loss is usually used: Among them, y i is the true category label, is the predicted probability; ③Confidence loss: Confidence loss usually also uses binary cross entropy loss to measure whether there is a target in the prediction box; Among them, y is the label of whether the target exists or not, is the confidence of the prediction; Confidence Score: The confidence score in the YOLOv5 model is defined as: Among them, P(Object) is the probability that the object exists in the predicted box, and IoU is the intersection over union ratio between the predicted box and the true box; ④Non-Maximum Suppression (NMS): In the inference phase, in order to remove redundant overlapping boxes, YOLOv5 uses non-maximum suppression; the basic idea of ​​the non-maximum suppression function is to retain the predicted box with the highest confidence and remove other boxes that overlap with it. If the IoU of two boxes exceeds a set threshold, the box with lower confidence will be removed. IoU is the intersection over union ratio between the predicted box and the true box.

[0008] Preferably, the present invention combines the sweater defect detection task, and each formula and calculation step in YOLOv5 has a specific function, aiming to achieve accurate detection and classification of sweater defects; the following is how to combine these formulas with the defect detection task, and the role of each formula: Bounding Box Prediction,In the sweater defect detection task, these formulas are used to predict the bounding box of the defect; specifically, b x and b y represents the center point of the detected defect area, b w and b h They represent the width and height of the defective area respectively. Through these parameters, YOLOv5 can locate and select the defective area on the sweater in the image.

[0009] The bounding box regression loss (GIoU Loss) in the loss function is used to measure the overlap between the predicted bounding box and the actual defect area when detecting defects in sweaters. If the predicted box is highly consistent with the actual defect area, the GIoU value is close to 1 and the loss value is small; if the predicted box deviates greatly from the actual box, the loss value will increase. GIoU Loss helps improve the accuracy of the detection box.

[0010] Classification loss in the loss function. In defect detection, classification loss is used to determine whether there is a specific type of defect (for example, fabric holes, color difference, etc.) in each detection box. By minimizing the classification loss, the model can more accurately determine which type of defect the detected area belongs to.

[0011] The confidence loss in the loss function is used to measure the model's confidence in whether there are defects in the detection area. For the sweater defect detection task, if the model believes that there is a defect in a certain area, the confidence score will be higher; on the contrary, if there is no defect, the confidence score will be lower; confidence loss helps the model distinguish between real defects and normal areas.

[0012] Confidence Score: In defect detection, the confidence score indicates the model's overall confidence in whether there is a defect in a detection box. This score combines the IoU of the detection box (the degree of overlap between the predicted box and the true box) and the probability of whether there is a defect in the prediction box. A detection box with high confidence is more likely to be a real defect area.

[0013] Non-Maximum Suppression (NMS) in the loss function is used to remove redundant overlapping boxes and retain only the boxes with the highest confidence. For the sweater defect detection task, when multiple overlapping defect boxes are detected, NMS ensures that only the boxes that are most likely to represent the real defect are retained, thereby avoiding repeated or redundant detection.

[0014] Bounding box prediction is responsible for locating potential defective areas on the sweater; the loss function is used to train the model so that the model can more accurately select and classify defects; the confidence score evaluates the possibility of defects in each detection area; non-maximum suppression (NMS) is used to optimize the final detection results and avoid repeated detection.

[0015] Compared with the prior art, the present invention has the following advantages and effects: significantly improving the efficiency, accuracy and automation level of wool sweater defect detection, and effectively solving the problems faced by the quality inspection link in the current wool sweater production process.

[0016] Improve inspection efficiency: By introducing advanced automated inspection technology and optimization algorithms, we can quickly identify and classify sweater defects, significantly shorten the inspection cycle, and improve production line efficiency. This helps reduce manual intervention, lower labor costs, and speed up product launch.

[0017] Enhanced detection accuracy: Using high-definition image acquisition equipment and advanced image processing technology, combined with deep learning and other machine learning algorithms, we can accurately identify subtle surface defects of products generated by sweater production equipment. This includes but is not limited to holes, missed stitches, broken edges, hit stitches, flower pieces and other types of defects, ensuring that every product can meet strict quality standards.

[0018] Reduce missed detection and false detection rates: By continuously optimizing the algorithm model and increasing the diversity of data samples, the robustness and generalization ability of the detection system can be improved, effectively reducing missed detection and false detection. This helps improve product quality and customer satisfaction, while reducing returns and complaints caused by quality issues.

[0019] Achieve comprehensive detection capabilities: Build a comprehensive sweater defect detection system that can detect multiple types of defects at the same time and have the ability to evaluate the overall quality characteristics of sweaters. This includes but is not limited to material analysis, size measurement, elasticity testing, etc., to provide more comprehensive and accurate detection results.

[0020] Promote standardization and regularization: By formulating and implementing unified testing standards and specifications, we can ensure that the quality test results of sweaters from different batches and production lines are comparable and consistent. This will help improve the quality control level of the entire industry and enhance consumers' trust in sweater products.

[0021] Improve user experience and brand value: Through efficient and accurate defect detection, we ensure that every product meets high quality standards, thereby improving consumers' wearing experience and satisfaction. At the same time, this also helps to enhance the brand's market competitiveness and brand value, bringing more sustainable development momentum to the company.

[0022] In summary, the present invention solves the pain points in the current wool sweater defect detection through technological innovation and optimization, improves the detection efficiency, accuracy and automation level, and provides wool sweater manufacturers with a more efficient and reliable quality inspection solution. DETAILED DESCRIPTION

[0023] The present invention will be further described in detail below by way of examples. The following examples are provided to explain the present invention but the present invention is not limited to the following examples.

[0024] Example

[0025] The steps of the sweater defect detection method in this embodiment include four main steps: data preprocessing step, model building step, model training step, and defect detection step; wherein, the model building step improves the model's recognition ability of sweater defects by introducing attention mechanism, optimizing network structure and other strategies; in the detection process, automatic positioning and classification of defect areas are realized through a series of key functions; The key functions and their uses are as follows: (1) Data preprocessing function In the data preprocessing step, the sweater images are cropped, scaled, rotated, and other data enhancement processes are performed to increase the diversity and scale of the data set and improve the generalization ability of the model. At the same time, the images are normalized to ensure the consistency of the input data. (2) Model building function In the model building step, a deep learning model is built based on the basic framework of the YOLO algorithm and the specific needs of sweater defect detection. The model building function is responsible for defining the model's input layer, backbone network (Backbone), feature fusion network (Neck) and output layer (Head), and integrating optimization strategies such as the attention mechanism. (3) Loss calculation function In the model training step, the difference between the predicted result and the true label, i.e. the loss value, is calculated; the loss calculation function usually includes three parts: coordinate loss, confidence loss and category loss. The model parameters are optimized through the back propagation algorithm to reduce the overall loss value and improve the model performance; (4) Non-maximum suppression function (NMS) In the defect detection step, in the model output stage, there may be multiple predicted bounding boxes for the same target. The non-maximum suppression function compares the confidence and overlap of the bounding boxes, retains the bounding boxes with the highest confidence and the lowest overlap, and removes the redundant bounding boxes, thereby improving the accuracy and efficiency of detection. (5) Post-processing function In the defect detection step, the bounding box processed by the non-maximum suppression function is further processed, such as through bounding box adjustment and category label mapping, to generate the final defect detection result; the post-processing function is also responsible for visualizing the detection results for users to intuitively view and analyze.

[0026] The steps of the sweater defect detection method in this embodiment are as follows: (1) Collect defect image datasets of wool sweaters and annotate them, including information such as defect category and location. Use high-definition cameras or image scanning equipment to collect image data of wool sweaters, including image data of the front, back, and key details. Ensure that the images are clear and unblurred and can accurately reflect the surface condition of the sweaters. Preprocess the collected images, including cropping, scaling, denoising, and other operations, to ensure the uniformity and consistency of the image data. At the same time, annotate the sweaters in the images, clearly mark the locations and types of defects, and form annotated datasets. (2) Use data preprocessing functions to enhance and normalize the image dataset; divide the preprocessed labeled dataset into training set, validation set, and test set for model training, validation, and testing; (3) Define and initialize the YOLO model through the model building function, including the backbone network, feature fusion network and output layer; use the deep learning framework (PyTorch) to build the improved YOLO model and configure the corresponding training parameters; use the training set to train the improved YOLO model, and optimize the model parameters through continuous iteration to improve the detection accuracy of the model; (4) Use the training set to train the model, use the loss calculation function to evaluate the model performance, and optimize the model parameters through the back propagation algorithm; (5) Use the validation set to evaluate the model, adjust the model structure and parameters, use the validation set to verify the model during training, calculate the model's performance indicators such as detection accuracy, recall rate, F1 score, etc. based on the test results, and evaluate whether the model's detection effect meets actual needs; (6) Apply the trained model to actual sweater images, output defect detection results through non-maximum suppression function and post-processing function, and realize automatic detection function; (7) The trained model is deployed on a self-developed device that can be installed on a sweater production machine to perform real-time inspection of sweaters produced by the sweater production machine, and defective products are discovered and marked in a timely manner.

[0027] The structure diagram of the basic framework of the YOLO algorithm usually includes the following key parts: (1) Backbone network: ① Focus layer: used to slice the input image and process it through the convolution layer. This step increases the number of channels of the input image from 3 to 64 and reduces the image size by half; ②CSPDarknet53: YOLOv5 uses Darknet53 with CSP (Cross Stage Partial) structure as the backbone network. This structure improves the efficiency of feature reuse, reduces the amount of calculation, and also improves the performance of the model; (2) Neck network: ①SPP (Spatial Pyramid Pooling): Based on the backbone network, multi-scale features are extracted through the SPP module; the SPP module extracts different features through maximum pooling layers of different sizes, so that the model can handle targets of different scales; ②PANet (Path Aggregation Network): used to further fuse features of different scales. PANet enhances the accuracy of target detection through top-down and bottom-up feature fusion; (3) Detection head (Head): YOLO Head: The detection head of YOLOv5 is responsible for target classification and localization. It performs multi-scale prediction through three feature maps of different scales (small, medium, and large), which enables YOLOv5 to detect targets of different sizes. (4) Output layer: The output layer generates prediction boxes of three scales, each of which contains the category, confidence, and location information of the bounding box.

[0028] The basic formulas of YOLOv5 mainly involve the key parts of target detection, including the calculation of loss function, bounding box prediction, and the calculation of confidence and classification probability. The following are some key formulas: (1) Bounding Box Prediction: In the YOLO series of models, each bounding box prediction is represented by the center coordinates (x, y), width w, and height h; The predicted center coordinates and width and height are usually calculated using the following formula: Among them, σ represents the sigmoid function, t x ,t y ,t w ,t h is the output of the network prediction, c x 、c y is the offset of the current grid point, p w and p h are the width and height of the preset anchor box, and e is a natural constant; (2) Calculation of loss function: The loss function of YOLOv5 consists of three parts: classification loss, bounding box regression loss, and object confidence loss. ① Bounding box regression loss: GIoU (Generalized Intersection over Union) is usually used as the loss function: Among them, A and B are the areas of the predicted box and the real box respectively, C is the area of ​​the bounding box (that is, the smallest closed rectangle containing A and B), and IoU represents the intersection-over-union ratio of the predicted box and the real box; ②Classification loss: Binary Cross-Entropy Loss is usually used: Among them, y i is the true category label, is the predicted probability; ③Confidence loss: Confidence loss usually also uses binary cross entropy loss to measure whether there is a target in the prediction box; Among them, y is the label of whether the target exists or not, is the confidence of the prediction; Confidence Score: The confidence score in the YOLOv5 model is defined as: Among them, P(Object) is the probability that the object exists in the predicted box, and IoU is the intersection over union ratio between the predicted box and the true box; ④Non-Maximum Suppression (NMS): In the inference phase, in order to remove redundant overlapping boxes, YOLOv5 uses non-maximum suppression; the basic idea of ​​the non-maximum suppression function is to retain the predicted box with the highest confidence and remove other boxes that overlap with it. If the IoU of two boxes exceeds a set threshold (e.g. 0.5), the box with lower confidence will be removed. IoU is the intersection over union ratio between the predicted box and the true box.

[0029] In conjunction with the sweater defect detection task, each formula and calculation step in YOLOv5 has a specific role, aiming to achieve accurate detection and classification of sweater defects; here is how to combine these formulas with the defect detection task and the role of each formula: (1) Bounding Box Prediction: In the sweater defect detection task, these formulas are used to predict the bounding box of the defect; specifically, b x and b y represents the center point of the detected defect area, b w and b h They represent the width and height of the defective area respectively. Through these parameters, YOLOv5 can locate and select the defective area on the sweater in the image.

[0030] (2) Bounding box regression loss (GIoU Loss) in the loss function. When detecting defects in wool sweaters, GIoU Loss is used to measure the overlap between the predicted bounding box and the actual defect area. If the predicted box is highly consistent with the actual defect area, the GIoU value is close to 1 and the loss value is small. If the predicted box deviates greatly from the actual box, the loss value will increase. GIoU Loss helps improve the accuracy of the detection box.

[0031] Classification loss in the loss function. In defect detection, classification loss is used to determine whether there is a specific type of defect (for example, fabric holes, color difference, etc.) in each detection box. By minimizing the classification loss, the model can more accurately determine which type of defect the detected area belongs to.

[0032] The confidence loss in the loss function is used to measure the model's confidence in whether there are defects in the detection area. For the sweater defect detection task, if the model believes that there is a defect in a certain area, the confidence score will be higher; on the contrary, if there is no defect, the confidence score will be lower; confidence loss helps the model distinguish between real defects and normal areas.

[0033] (3) Confidence Score: In defect detection, the confidence score indicates the model’s overall confidence in whether a defect exists in a detection box. This score combines the IoU (the degree of overlap between the predicted box and the true box) of the detection box and the probability of whether there is a defect in the predicted box. A detection box with high confidence is more likely to be a true defect area.

[0034] (4) Non-Maximum Suppression (NMS): NMS is used to remove redundant overlapping boxes and retain only the boxes with the highest confidence. For the sweater defect detection task, when multiple overlapping defect boxes are detected, NMS ensures that only the box that is most likely to represent the real defect is retained, thereby avoiding repeated or redundant detection.

[0035] As can be seen, bounding box prediction is responsible for locating potential defective areas on the sweater. The loss function is used to train the model so that the model can more accurately select and classify defects. The confidence score evaluates the possibility of defects in each detection area. Non-maximum suppression (NMS) is used to optimize the final detection results and avoid repeated detection.

[0036] Through these formulas, YOLOv5 can efficiently detect and classify various defects on sweaters, helping to improve inspection efficiency and quality control on the production line.

[0037] In addition, when the detection method described in the present invention is applied to equipment, it can be divided into the following two situations: 1. The system is arranged to be detected in an independent machine: a camera and an integrated circuit that can run the system are installed on the machine to be detected and combined with the machine alarm device and the start-stop device, and the camera is used to monitor the finished cloth, and the data is transmitted to the system built into the machine. When damage is detected, the machine can be directly instructed, and the real-time data is sent to the cloud, so that the mobile phone can directly receive the data information of the workshop. 2. The system is arranged to be detected in a remote server (including a cloud server): a wireless camera and an integrated circuit that can control the machine alarm device and the start-stop device are installed on the machine to be detected, and the camera is used to monitor the finished cloth, and the data is transmitted to the remote server for detection, and the remote server's instructions are sent to the installed integrated circuit, and the alarm and machine pause actions are realized on the machine. The remote server will also send the machine data to the mobile phone in real time; the advantage of this method is that batch machine data can be processed on the server, and the data will be analyzed and instructions will be sent after processing.

[0038] Although the present invention has been disclosed as above by way of embodiments, it is not intended to limit the protection scope of the present invention. Any changes and modifications made by any technician familiar with the technology without departing from the concept and scope of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for detecting defects in a wool sweater, characterized in that: The steps are as follows: including data preprocessing, model building, model training, and defect detection. In the model building step, the attention mechanism is introduced and the network structure is optimized to improve the model's ability to identify sweater defects. In the detection process, the key functions are used to realize automatic positioning and classification of defect areas. The key functions are as follows: (1) Data preprocessing function In the data preprocessing step, the sweater images are cropped, scaled, and rotated for data enhancement to increase the diversity and scale of the data set and improve the generalization ability of the model. At the same time, the images are normalized to ensure the consistency of the input data. (2) Model building function In the model building step, a deep learning model is built based on the basic framework of the YOLO algorithm and the specific needs of sweater defect detection. The model building function is responsible for defining the input layer, backbone network, feature fusion network and output layer of the model, and integrating the strategy of the attention mechanism. (3) Loss calculation function In the model training step, the difference between the predicted result and the true label, i.e. the loss value, is calculated; the loss calculation function includes coordinate loss, confidence loss and category loss. The model parameters are optimized through the back propagation algorithm to reduce the overall loss value and improve the model performance; (4) Non-maximum suppression function In the defect detection step, in the model output stage, there is a problem of generating multiple predicted bounding boxes for the same target. The non-maximum suppression function compares the confidence and overlap of the bounding boxes, retains the bounding boxes with the highest confidence and the lowest overlap, and removes the redundant bounding boxes, thereby improving the accuracy and efficiency of detection; (5) Post-processing function In the defect detection step, the bounding box processed by the non-maximum suppression function is further processed, and the final defect detection result is generated through bounding box adjustment and category label mapping; the post-processing function is also responsible for visualizing the detection results for users to intuitively view and analyze.

2. The sweater defect detection method according to claim 1, characterized in that: Here are the steps: (1) Collect defect image datasets of wool sweaters and annotate them, including defect categories and location information; use high-definition cameras or image scanning equipment to collect image data of wool sweaters, including image data of the front, back, and key details; ensure that the images are clear and unblurred, and accurately reflect the surface condition of the sweaters; pre-process the collected images, including cropping, scaling, and denoising operations, to ensure the uniformity and consistency of the image data; at the same time, annotate the wool sweaters in the images, clearly mark the locations and types of defects, and form annotated datasets; (2) Use data preprocessing functions to enhance and normalize the image dataset; divide the preprocessed labeled dataset into training set, validation set, and test set for model training, validation, and testing; (3) Define and initialize the YOLO model through the model building function, including the backbone network, feature fusion network and output layer; use the deep learning framework to build the improved YOLO model and configure the corresponding training parameters; use the training set to train the improved YOLO model, and optimize the model parameters through continuous iteration to improve the detection accuracy of the model; (4) Use the training set to train the model, use the loss calculation function to evaluate the model performance, and optimize the model parameters through the back propagation algorithm; (5) Use the validation set to evaluate the model, adjust the model structure and parameters, use the validation set to verify the model during training, calculate the model's detection accuracy, recall rate, and F1 score performance indicators based on the test results, and evaluate whether the model's detection effect meets actual needs; (6) Apply the trained model to actual sweater images, output defect detection results through non-maximum suppression function and post-processing function, and realize automatic detection function; (7) The trained model is installed on a sweater production machine to perform real-time inspection on the sweaters produced by the sweater production machine, so as to detect and mark defective products in a timely manner.

3. The sweater defect detection method according to claim 1, characterized in that: The basic framework of the YOLO algorithm consists of the following parts: (1) Backbone network: ① It is used to slice the input image and process it through the convolution layer. This step increases the number of channels of the input image from 3 to 64 and reduces the image size by half; ②YOLO uses Darknet53 with CSP structure as the backbone network. This structure improves the efficiency of feature reuse, reduces the amount of calculation, and also improves the performance of the model; (2) Neck network: ① Based on the backbone network, multi-scale features are extracted through the SPP module; the SPP module extracts different features through maximum pooling layers of different sizes, so that the model can handle targets of different scales; ② It is used to further fuse features of different scales, and enhance the accuracy of target detection through top-down and bottom-up feature fusion; (3) Detection head: The detection head is responsible for target classification and localization. It performs multi-scale prediction through feature maps of three different scales, which enables the detection of targets of different sizes. (4) Output layer: The output layer generates prediction boxes of three scales, each of which contains the category, confidence, and location information of the bounding box.

4. The sweater defect detection method according to claim 1, characterized in that: The formula includes the calculation of the loss function, bounding box prediction, and the calculation of confidence and classification probability: (1) Bounding box prediction: In the YOLO series of models, each bounding box prediction is represented by the center coordinates (x, y), width w, and height h; The predicted center coordinates and width and height use the following formula: Among them, σ represents the sigmoid function, t x ,t y ,t w ,t h is the output of the network prediction, c x 、c y is the offset of the current grid point, p w and p h are the width and height of the preset anchor box, and e is a natural constant; (2) Calculation of loss function: The loss function consists of three parts: classification loss, bounding box regression loss, and target confidence loss; ① Bounding box regression loss: Use GIoU as the loss function: Among them, A and B are the areas of the predicted box and the real box respectively, C is the area of ​​the bounding box, and IoU represents the intersection-over-union ratio of the predicted box and the real box; ②Classification loss: The binary cross entropy loss is used: Among them, y i is the true category label, is the predicted probability; ③Confidence loss: Confidence loss uses binary cross entropy loss to measure whether there is an object in the prediction box; Among them, y is the label of whether the target exists or not, is the confidence of the prediction; The confidence score is defined as: Among them, P(Object) is the probability that there is an object in the predicted box, and IoU is the intersection over union ratio between the predicted box and the true box; ④Non-maximum suppression: In the inference phase, non-maximum suppression is used to remove redundant overlapping boxes. The basic idea of ​​the non-maximum suppression function is to retain the predicted box with the highest confidence and remove other boxes that overlap with it. If the IoU of two boxes exceeds a set threshold, the box with lower confidence will be removed. IoU is the intersection over union ratio between the predicted box and the true box.

5. The sweater defect detection method according to claim 4, characterized in that: Bounding box prediction, used to predict the bounding box of defects in the sweater defect detection task; b x and b y represents the center point of the detected defect area, b w and b h They represent the width and height of the defect area respectively; Using these parameters, the defective area on the sweater is located and selected in the image.

6. The sweater defect detection method according to claim 4, characterized in that: The bounding box regression loss in the loss function is used to measure the degree of overlap between the predicted bounding box and the actual defect area when detecting defects in sweaters. If the predicted box is highly consistent with the actual defect area, the GIoU value is close to 1 and the loss value is small; if the predicted box deviates greatly from the actual box, the loss value will increase.

7. The sweater defect detection method according to claim 4, characterized in that: Classification loss in the loss function. In defect detection, classification loss is used to determine whether there is a specific type of defect in each detection box. By minimizing the classification loss, the model can more accurately determine which defect type the detected area belongs to.

8. The sweater defect detection method according to claim 4, characterized in that: The confidence loss in the loss function is used to measure the model's confidence in whether there are defects in the detection area. For the sweater defect detection task, if the model believes that there are defects in a certain area, the confidence score will be higher; on the contrary, if there are no defects, the confidence score will be lower; In defect detection, the confidence score indicates the model’s overall confidence in whether a defect exists in a detection box; this score combines the IoU of the detection box and the probability of predicting whether there is a defect in the box.

9. The sweater defect detection method according to claim 4, characterized in that: The non-maximum suppression in the loss function is used to remove redundant overlapping boxes and retain only the boxes with the highest confidence. For the sweater defect detection task, when multiple overlapping defect boxes are detected, it ensures that only the boxes that are most likely to represent the real defect are retained, thereby avoiding repeated or redundant detection.

10. The sweater defect detection method according to claim 4, characterized in that: Bounding box prediction is responsible for locating potential defective areas on the sweater; the loss function is used to train the model so that the model can more accurately select and classify defects; the confidence score evaluates the possibility of defects in each detection area; non-maximum suppression is used to optimize the final detection results and avoid repeated detection.

Citation Information

Cited By

  • Construction engineering steel structure welding quality detection method based on deep neural network

    CN119963556A

  • Cashmere and wool microscopic image component detection method and system

    CN122385595A