Cloth count detection system based on machine learning and detection method thereof
By adopting a fabric spend detection system based on machine learning in the textile industry, using the YOLOv5 algorithm and multi-task processing model, the fabric spend detection and fabric defect recognition functions are integrated, which solves the problems of high cost and low efficiency of the existing system and achieves efficient and low-cost detection effects.
Patent Information
- Application Number
- CN202510209042.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-05-30
AI Technical Summary
The existing deep learning-based fabric detection system has high requirements for graphics card and computer configuration, which increases the cost of the system. The fabric count detection and fabric defect recognition are usually processed separately, reducing the detection efficiency.
A cloth spend detection system based on machine learning is adopted, including an image acquisition module, an image preprocessing module, a feature extraction module and an identification module. The feature vectors of image data are extracted using the YOLOv5 algorithm, and the spend detection and defect recognition are performed through a multi-tasking machine learning model.
It realizes deep integration of fabric count detection and fabric defect identification, improves detection efficiency, reduces equipment complexity and cost, and achieves efficient operation on ordinary configuration computers.
Smart Images

Figure CN120070397A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a textile industry detection technology, and particularly to a fabric count detection system based on machine learning and its detection method. Background Art
[0002] In the traditional textile industry, the detection of fabric count and the identification of fabric defects mainly rely on manual visual inspection. This method is inefficient and vulnerable to subjective factors. With the development of computer vision and deep learning technologies, detection methods based on image analysis have gradually emerged. However, existing deep learning-based fabric detection systems often have high requirements for graphics cards and computer configurations, increasing the cost of the system. In addition, although existing systems can use deep learning algorithms for fabric defect identification, they often process fabric count detection separately, thereby reducing the detection efficiency. Summary of the Invention
[0003] The present invention overcomes the deficiencies of the prior art and provides a fabric count detection system based on machine learning and its detection method.
[0004] To achieve the above object, the technical solution adopted by the present invention is: a fabric count detection system based on machine learning and its detection method, including: an image acquisition module, an image preprocessing module, a feature extraction module, and an identification module;
[0005] The image acquisition module uses a camera or a scanner to obtain image data of the fabric;
[0006] The image preprocessing module preprocesses the acquired image data, including image scaling, cropping, angle transformation, brightness, and contrast adjustment;
[0007] The feature extraction module uses the YOLOv5 algorithm to extract feature vectors that can characterize the fabric count and fabric defects from the preprocessed image data;
[0008] The identification module performs fabric count detection and defect identification on the fabric according to the feature vectors, and displays the identification results in a visual manner.
[0009] In a preferred embodiment of the present invention, the YOLOv5 algorithm uses CSPDarknet53 as the backbone network, and gradually extracts low-level features and high-level features of the image through convolutional operations; after the backbone network, the YOLOv5 algorithm uses an aggregation network structure of a feature pyramid network and a path aggregation network to fuse the low-level features and high-level features to obtain the feature vectors.
[0010] In a preferred embodiment of the present invention, the characterization information of the feature vector includes: the texture density of the fabric, the thickness of the lines, the shape, size, and color of the defects; the low-level features refer to the basic information directly extracted from the original data of the image, including: edge features, corner features, texture features, and color features; the high-level features refer to the abstract information extracted from the low-level features, including: shape features, category features, and semantic features.
[0011] In a preferred embodiment of the present invention, the recognition module is built-in with a machine learning model for multi-task processing. The implementation process of the machine learning model includes:
[0012] S1. Collect fabric image data containing different counts and defect types, label the count information for each image, and at the same time label the defect positions, types, and sizes in the image;
[0013] S2. Preprocess the image data and divide the image data into a training set, a validation set, and a test set for model training, validation, and evaluation;
[0014] S3. Use CSPDarknet53 as the backbone network to extract the low-level features and high-level features of the image data in the training set. After the backbone network, design two branches: one for count prediction and the other for defect detection;
[0015] S4. Use a multi-task loss function to balance the learning of count prediction and defect detection, and perform weighted combination on the count prediction loss and the defect detection loss to form a total loss function;
[0016] S5. Input the image data in the validation set into the model, calculate the total loss value; use the optimizer to update the weights of the machine learning model to obtain the minimized loss function, and calculate the minimum loss value; repeat the process until the machine learning model converges or reaches the predetermined number of training epochs;
[0017] S6. Use the image data in the test set to evaluate the performance of the machine learning model, including the accuracy of count prediction and the recall rate and precision rate of defect detection.
[0018] In a preferred embodiment of the present invention, the calculation expression formula of the total loss function is: L = αL 支数检测 + βL 缺陷检测 ; where α and β are weighting coefficients; L 支数检测 and L 缺陷检测 are the count prediction loss and the defect detection loss respectively.
[0019] In a preferred embodiment of the present invention, the precision rate of the count prediction is evaluated using the root mean square error, and its calculation expression formula is:
[0020]
[0021] In the formula, Y i represents the actual count; represents the predicted count; n represents the total number of samples; i represents the index or number of the sample.
[0022] In a preferred embodiment of the present invention, the relationship between the positive and negative classes predicted by the machine learning model and the actual positive and negative classes is shown through a confusion matrix, the true positives and false positives are calculated, and then through ratio calculation, the accuracy rate of the defect detection is obtained; its calculation expression is:
[0023]
[0024] In the formula, TP represents true positives; FP represents false positives.
[0025] In a preferred embodiment of the present invention, a method for detecting the count of fabric based on machine learning is proposed, which is applied to the above-mentioned detection system, and includes the following steps:
[0026] A1. Use a camera or scanner to obtain the image data of the fabric, and preprocess the collected image data;
[0027] A2. Use the YOLOv5 algorithm to extract features from the preprocessed image data to obtain feature vectors, and based on the feature vectors, use a classifier to detect the count of the fabric and identify defects;
[0028] A3. The classifier will output the count information of the fabric and the location, type and size of the defects, and then display the recognition results in a visual manner.
[0029] The present invention solves the defects existing in the background technology, and the present invention has the following beneficial effects:
[0030] (1) The present invention deeply integrates the functions of fabric count detection and fabric defect identification in one system, and through optimizing the model structure and algorithm design, realizes multi-task parallel processing. This integrated design not only improves the detection efficiency, but also reduces the complexity and cost of the equipment.
[0031] (2) By adopting a lightweight network structure, the present invention successfully reduces the number of model parameters to one tenth of the original model, thus realizing efficient operation on a computer with ordinary configuration.
[0032] (3) The recognition module of the present invention adopts an efficient classification algorithm, which can accurately identify the count of the fabric and the type of defects. The detection results are displayed in a visual manner, including information such as the value of the fabric count, the location and type of the defects, etc. Users can conveniently view and analyze the detection results through an intuitive interface.
[0033] (4) The present invention uses the YOLOv5 algorithm to perform multi-level feature extraction on the preprocessed image data. Specifically, through its powerful feature extraction network, the YOLOv5 algorithm can extract rich image features, including key information such as the thickness and density of fabric yarns and fabric defects. By optimizing the structure and parameter settings of the feature extraction network, the present invention further improves the representation ability and robustness of the feature vector, ensuring that the feature vector can accurately reflect the characteristics of fabric count and fabric defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings;
[0035] Figure 1 is the system flowchart of the preferred embodiment of the present invention;
[0036] Figure 2 is the graph of the training results of the machine learning model of the preferred embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0037] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0038] In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited by the specific embodiments disclosed below.
[0039] As Figure 1 shown, a fabric count detection system and its detection method based on machine learning include: an image acquisition module, an image preprocessing module, a feature extraction module, and an identification module;
[0040] The image acquisition module uses a camera or a scanner to obtain image data of the fabric;
[0041] The image preprocessing module preprocesses the acquired image data, including image scaling, cropping, angle transformation, brightness and contrast adjustment;
[0042] The feature extraction module uses the YOLOv5 algorithm to extract the feature vectors that can characterize the fabric count and fabric defects from the preprocessed image data;
[0043] Furthermore, the YOLOv5 algorithm uses CSPDarknet53 as the backbone network, and gradually extracts the low-level features and high-level features of the image through convolutional operations; after the backbone network, the YOLOv5 algorithm uses the aggregation network structure of the Feature Pyramid Network and the Path Aggregation Network to fuse the low-level features and high-level features to obtain the feature vectors.
[0044] The characterization information of the feature vectors includes: the texture density of the fabric, the thickness of the lines, the shape, size, and color of the defects; the low-level features refer to the basic information directly extracted from the original data of the image, including: edge features, corner features, texture features, color features; the high-level features refer to the abstract information extracted from the low-level features, including: shape features, category features, semantic features.
[0045] Specifically: convert the original image into a format acceptable to the model and perform preprocessing operations such as normalization. For fabric images, specific preprocessing may also be required, such as denoising and enhancing contrast, etc., to improve the effect of feature extraction.
[0046] YOLOv5 uses CSPDarknet53 as the backbone network, which has 53 convolutional layers and can effectively extract the features of the image.
[0047] The backbone network gradually extracts the low-level features (such as edges, textures, etc.) and high-level features (such as the shape and structure of objects) of the image through convolutional operations.
[0048] During the feature extraction process, YOLOv5 also introduces techniques such as the Bottleneck structure to reduce the computational amount and speed up the calculation speed.
[0049] YOLOv5 uses the structure of the Feature Pyramid Network (FPN) and the Path Aggregation Network (PANet) after the backbone network for feature fusion.
[0050] FPN fuses the high-level features with the low-level features through the top-down path and lateral connections, and obtains multi-scale feature maps through upsampling.
[0051] PANet further enhances the representation ability of the feature maps through bottom-up path aggregation.
[0052] This multi-scale feature fusion method enables YOLOv5 to better handle the detection tasks of targets at different scales, including the detection of fine targets such as fabric count and fabric defects.
[0053] After being processed by the feature extraction module, the YOLOv5 algorithm generates a series of feature vectors. These feature vectors can represent the feature information of target objects such as fabric count and fabric defects.
[0054] Generation of feature vectors: In the prediction head (Head) of YOLOv5, each grid predicts the classes and positions of multiple anchor boxes. These anchor boxes are adjusted according to the target objects in the image and finally generate a series of feature vectors. Each feature vector contains the class information, position information, confidence, etc. of the target object.
[0055] Characterization of feature vectors: For fabric count, the feature vector may contain feature information such as fabric texture density and line thickness that can represent the count.
[0056] For fabric defects, the feature vector may contain feature information such as the shape, size, and color of the defects that can represent the defects.
[0057] Based on the feature vectors, the recognition module uses a classifier to detect the fabric count and identify defects of the fabric, and displays the recognition results in a visual way.
[0058] Applying the YOLOv5 algorithm to the feature extraction of fabric count and fabric defects has significant advantages:
[0059] Real-time performance: The YOLOv5 algorithm has a fast detection speed and can achieve real-time object detection.
[0060] Accuracy: Through multi-scale feature fusion and powerful feature extraction capabilities, the YOLOv5 algorithm can accurately extract the feature information of fabric count and fabric defects.
[0061] Robustness: The YOLOv5 algorithm has strong robustness to complex scenes and occlusion situations and can achieve good results in practical applications.
[0062] Furthermore, the recognition module has a machine learning model with multi-task processing built in. The implementation process of the machine learning model includes:
[0063] S1. Collect fabric image data containing different counts and defect types, label the count information for each image, and at the same time label the defect positions, types, and sizes in the image;
[0064] S2. Preprocess the image data and divide the image data into a training set, a validation set, and a test set for model training, validation, and evaluation;
[0065] S3. Use CSPDarknet53 as the backbone network to extract low-level and high-level features of the image data in the training set. After the backbone network, design two branches: one for count prediction and the other for defect detection;
[0066] S4. Use a multi-task loss function to balance the learning of count prediction and defect detection, and perform weighted combination of the count prediction loss and the defect detection loss to form the total loss function;
[0067] S5. Input the image data in the validation set into the model, calculate the total loss value; use the optimizer to update the weights of the machine learning model, obtain the minimized loss function, and calculate the minimum loss value; repeat the process until the machine learning model converges or reaches the predetermined number of training epochs;
[0068] S6. Use the image data in the test set to evaluate the performance of the machine learning model, including the accuracy of count prediction and the recall rate and precision rate of defect detection.
[0069] Specifically: The feature vectors are extracted by the YOLOv5 algorithm through the aggregation network structure of the CSPDarknet53 backbone network, the Feature Pyramid Network (FPN), and the Path Aggregation Network (PANet).
[0070] These feature vectors contain key information such as the texture density of the fabric, the line thickness (for count detection), and the shape, size, and color of the defects (for defect identification).
[0071] The significance of the feature vectors: The texture density and line thickness reflect the fabric's organizational structure and are important bases for count detection.
[0072] The shape, size, and color of the defects are directly related to the fabric quality issues and are key features for defect identification.
[0073] The selection of the classifier: The recognition module uses a classifier to classify the feature vectors. The classifier can be a machine learning-based model such as a Support Vector Machine (SVM), a Random Forest (RF), or a deep learning model (such as a fully connected neural network).
[0074] The selection of the classifier depends on the specific application scenario, data volume, and computing resources.
[0075] The training of the classifier: In the training stage, use a large number of labeled fabric image data to train the classifier. The training data includes fabric images of different counts and fabric images with defects.
[0076] By adjusting the parameters and loss function of the classifier, enable it to accurately classify the feature vectors and distinguish different fabric counts and defect types.
[0077] Application of the classifier: In the recognition stage, the feature vector is input into the trained classifier. Based on the values of the feature vector, the classifier outputs the corresponding fabric count and defect type.
[0078] Visualization method: The recognition module presents the recognition results in a visual way for easy understanding and use by the user. The visualization method can be image annotation, chart display, text report, etc.
[0079] Image annotation: Mark the recognized count and defect positions on the original fabric image. Different colors or marks are used to distinguish different counts and defect types.
[0080] Chart display: Organize the recognition results into chart forms such as bar charts, pie charts, etc. The charts can display information such as the count distribution of the fabric and the proportion of defect types.
[0081] The calculation expression formula of the total loss function is: L = αL 支数检测 + βL 缺陷检测 ; where α and β are weighting coefficients; L 支数检测 and L 缺陷检测 are the count prediction loss and defect detection loss respectively.
[0082] The precision rate of count prediction is evaluated using the root mean square error, and its calculation expression formula is:
[0083]
[0084] In the formula, Y i represents the true count; represents the predicted count; n represents the total number of samples; i represents the index or number of the sample.
[0085] The relationship between the predicted positive and negative classes and the actual positive and negative classes of the machine learning model is shown through a confusion matrix. The true positive and false positive are calculated, and then through ratio calculation, the accuracy rate of defect detection is obtained; its calculation expression is:
[0086]
[0087] In the formula, TP represents the true positive; FP represents the false positive.
[0088] Furthermore, a method for detecting fabric count based on machine learning is proposed and applied to the above detection system, including the following steps:
[0089] A1. Use a camera or scanner to obtain the image data of the fabric and preprocess the collected image data;
[0090] A2. Use the YOLOv5 algorithm to extract features from the preprocessed image data to obtain feature vectors, and then use a classifier to detect the count of the fabric and identify defects based on the feature vectors.
[0091] A3. The classifier will output the count information of the fabric, as well as the location, type, and size of the defects, and then display the recognition results in a visual way.
[0092] When the present invention is used, image data of the fabric is acquired using a high-resolution camera or scanner. The image acquisition module supports multiple image formats and resolution settings to adapt to the detection requirements of different fabrics.
[0093] Preprocess the acquired image data, including operations such as image scaling, cropping, angle transformation, brightness and contrast adjustment, etc. The preprocessing module adopts an adaptive algorithm and can automatically adjust the preprocessing parameters according to the characteristics of the fabric.
[0094] Use the lightweight YOLOv5 algorithm (or its improved version) to extract features from the preprocessed image data. Through its unique feature extraction network structure, such as CSPDarknet53, the YOLOv5 algorithm can automatically learn and extract the key features in the fabric image. These features include, but are not limited to, the thickness and density distribution of the fabric yarns, texture patterns, and potential fabric defects (such as holes, stains, color differences, etc.). By optimizing the structural parameters of the convolutional layer, pooling layer, etc. in the feature extraction network, the present invention ensures that the extracted feature vectors can accurately and comprehensively reflect the feature information of the fabric count and fabric defects.
[0095] Based on the feature vectors, use an efficient classification algorithm to detect the count of the fabric and identify defects. The recognition module supports the recognition of multiple defect types and can output accurate detection results.
[0096] Display the detection results in a visual way, including information such as the value of the fabric count, the location and type of the defects, etc. Users can conveniently view and analyze the detection results through the interface. At the same time, the detection results can be output to a specified file or database for subsequent analysis and processing.
[0097] The relevant software used in the present invention is the K210 (a lightweight embedded AI chip) and the YOLOv5 (or its improved version) algorithm.
[0098] (1) In terms of hardware, the present invention can be implemented and run on a computer with ordinary configuration, without the need for a high-performance graphics card and expensive computing devices. The low-power and high-performance characteristics of the K210 chip make this system very suitable for real-time detection applications in edge computing scenarios.
[0099] (2) Software implementation
[0100] Image acquisition and preprocessing
[0101] Use an open-source image processing library (such as OpenCV) to perform preprocessing operations on the collected fabric images. The preprocessing algorithm adopts an adaptive strategy, which can automatically adjust parameters according to the characteristics of the fabric to obtain the best results.
[0102] Model training and optimization
[0103] Build a lightweight YOLOv5 model using a deep learning framework (such as PyTorch or TensorFlow), and train it using the labeled fabric image data. During the training process, data augmentation techniques (such as image rotation, flipping, translation, etc.) are adopted to increase the diversity of the dataset and improve the robustness of the model.
[0104] Perform pruning, quantization and other optimization operations on the trained model to reduce the number of model parameters and improve the computing efficiency. The optimized model can be deployed on the K210 chip to achieve real-time detection.
[0105] Interface design and interaction
[0106] Design a user-friendly interface to facilitate users to operate and view the detection results. The interface supports multiple operation methods (such as mouse clicks, keyboard inputs, etc.), and provides rich interaction functions (such as image selection, saving detection results, parameter settings, etc.).
[0107] System integration and testing
[0108] Integrate each module into a complete system and conduct comprehensive tests to ensure the stability and reliability of the system. The test content includes functional tests, performance tests, compatibility tests, etc., to ensure that the system meets the actual application requirements.
[0109] Example 1
[0110] (1) Preparation stage
[0111] a) Data collection:
[0112] In this data collection, we implemented code to directly collect data using the K210 to ensure good photo quality. In addition, during the data collection process, we took photos from the perspective of being able to display stable data as much as possible, and ensured that the number of samples was sufficient (there were at least more than one hundred samples in each label, and the total number of training images was 419).
[0113] b) Data annotation:
[0114] Use the annotation tool to annotate the objects in the picture, define labels and select the target area, so as to realize the annotation of the photo. Generally, we define three types of labels: 40 counts, 50 counts, and 60 counts.
[0115] (2) Model training stage on the platform
[0116] a) Create a project:
[0117] Log in to the developer community with the registered account.
[0118] In the model training section, select "Create Project", fill in the project name and description, select the project type (such as image detection or image classification). The type selected this time is image detection, which can specifically detect the category of the shooting content and enclose it with a rectangle.
[0119] b) Create and upload the dataset:
[0120] Compress the prepared dataset (the photos collected in the preparation stage) into a file package.
[0121] In the project, select "Upload Dataset" and upload the file package. According to the platform prompt, bind the dataset to the current project.
[0122] c) Configure training parameters and start training: Configure training parameters:
[0123] Run chip: k210;
[0124] Number of iterations: 400 times Batch size: 32;
[0125] Maximum learning rate: 0.001;
[0126] Annotation box limit: 5;
[0127] d) Start training:
[0128] Click "Start Training" to start the training process.
[0129] During the training process, view the training log, loss curve and other information in real time to monitor the training progress and effect.
[0130] (3) Model evaluation and deployment
[0131] a) Evaluate the machine learning model:
[0132] After the training is completed, use the test set to evaluate the machine learning model and view indicators such as recognition rate and accuracy.
[0133] The training results are as Figure 2 shown.
[0134] Based on the inspiration of the ideal embodiments of the present invention, through the above description, relevant personnel can completely make various changes and modifications without departing from the technical idea of this invention. The technical scope of this invention is not limited to the content in the specification, and the technical scope must be determined according to the scope of the claims.
Claims
1. A cloth count detection system based on machine learning, comprising: Image acquisition module, image preprocessing module, feature extraction module and recognition module; characterized in that: The image acquisition module uses a camera or a scanner to acquire image data of the fabric; The image preprocessing module preprocesses the collected image data, including image scaling, cropping, angle transformation, brightness and contrast adjustment; The feature extraction module uses the YOLOv5 algorithm to extract feature vectors of the preprocessed image data that can characterize the count of fabric and fabric defects; The recognition module uses a classifier to detect the count and identify defects of the fabric according to the feature vector, and displays the recognition results in a visual manner.
2. The cloth count detection system based on machine learning according to claim 1, characterized in that: The YOLOv5 algorithm uses CSPDarknet53 as the backbone network, and gradually extracts low-level features and high-level features of the image through convolution operations; the YOLOv5 algorithm uses an aggregation network structure of a feature pyramid network and a path aggregation network after the backbone network to fuse the low-level features and high-level features to obtain the feature vector.
3. The cloth count detection system based on machine learning according to claim 2, characterized in that: The representation information of the feature vector includes: texture density of the cloth, line thickness, shape, size and color of defects; the low-level features refer to basic information directly extracted from the original data of the image, including: edge features, corner features, texture features, and color features; the high-level features refer to abstract information extracted from low-level features, including: shape features, category features, and semantic features.
4. The cloth count detection system based on machine learning according to claim 1, characterized in that: The recognition module has a built-in multi-task processing machine learning model, and the implementation process of the machine learning model includes: S1. Collect fabric image data with different counts and defect types, annotate the count information for each image, and annotate the defect position, type and size in the image; S2. Preprocess the image data and divide the image data into training set, validation set and test set for model training, validation and evaluation; S3, using CSPDarknet53 as the backbone network to extract low-level and high-level features of the image data in the training set. After the backbone network, two branches are designed: one for branch count prediction and the other for defect detection; S4. Use a multi-task loss function to balance the learning of count prediction and defect detection, and perform a weighted combination of the count prediction loss and the defect detection loss to form a total loss function; S5. Input the image data in the validation set into the model and calculate the total loss value; use the optimizer to update the weights of the machine learning model, obtain the minimized loss function, and calculate the minimum loss value; repeat the process until the machine learning model converges or reaches the predetermined number of training rounds; S6. Use the image data in the test set to evaluate the performance of the machine learning model, including the accuracy of count prediction and the recall and precision of defect detection.
5. The cloth count detection system based on machine learning according to claim 4, characterized in that: The calculation formula of the total loss function is: L = αL 支数检测 +βL 缺陷检测 ; In the formula, α, β are weighting coefficients; L 支数检测 and L 缺陷检测 They are count prediction loss and defect detection loss respectively.
6. The cloth count detection system based on machine learning according to claim 4, characterized in that: The root mean square error is used to evaluate the accuracy of the branch count prediction, and its calculation formula is: Where Y i Indicates the actual number of branches; represents the number of predictions; n represents the total number of samples; i represents the index or number of the sample.
7. The cloth count detection system based on machine learning according to claim 4, characterized in that: The confusion matrix is used to show the relationship between the positive and negative classes predicted by the machine learning model and the actual positive and negative classes, and the true positive examples and false positive examples are calculated. Then, the accuracy of the defect detection is obtained by ratio calculation; the calculation expression is: In the formula, TP represents true positive examples and FP represents false positive examples.
8. A method for detecting fabric count based on machine learning, applied to a detection system according to any one of claims 1 to 7, characterized in that: The following steps are involved: A1. Use a camera or scanner to obtain image data of the fabric and pre-process the collected image data; A2. Use the YOLOv5 algorithm to extract features from the preprocessed image data to obtain feature vectors. Based on the feature vectors, use the classifier to detect the count and identify defects of the fabric. A3. The classifier will output the count information of the fabric as well as the location, type and size of the defects, and then display the recognition results in a visual way.