A method for detecting yarn breakage
By collecting and preprocessing spinning production line images on the robot and building a detection model that improves attention mechanism, the existing yarn break detection methods are solved, and the existing yarn break detection methods are poorly adaptable and insufficient accuracy in complex environments are achieved, and the yarn break detection is achieved, which improves the efficiency and product quality of spinning production.
Patent Information
- Application Number
- CN202411958929.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The existing yarn break detection methods have poor adaptability, insufficient accuracy and poor real-time performance in complex workshop environments, making it difficult to meet the inspection needs of industrial production.
By setting up an image acquisition module on the robot, moving the acquisition image along the spinning production line and pre-processing, a MobileNetV3-Small detection model with improved attention mechanism is built, and the loss functions of combined Focal Loss and Center Loss are trained to achieve yarn break detection.
This method can achieve high-accurate yarn break detection in complex environments, meet real-time requirements, improve spinning efficiency, reduce raw material waste, and improve the quality of yarn products.
Smart Images

Figure CN119379688B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of spinning, and in particular relates to a yarn break detection method. Background Art
[0002] In the ring spinning process, yarn breakage is one of the key factors affecting production efficiency and product quality. Yarn breakage not only reduces the overall efficiency of the production line, but also has an adverse effect on the quality and consistency of textiles. The traditional method of detecting yarn breakage using manual inspection or photoelectric sensors has problems such as low efficiency and susceptibility to environmental interference.
[0003] In recent years, machine vision technology has gradually become an ideal choice for diversified tasks in complex scenes due to its advantages of low cost, strong adaptability and non-contact detection. In particular, it has shown wide application potential in the field of yarn break detection, but there are still defects. Research on yarn break detection mainly focuses on methods based on traditional image processing and deep learning. Traditional image processing methods usually extract yarn features to determine yarn breakage, but their adaptability in complex workshop environments is poor. Deep learning-based yarn break detection has stronger feature learning capabilities and can significantly improve the real-time and accuracy of detection. Although deep learning has made progress in yarn break detection, there are still shortcomings. First, there is a lack of data sets with strong versatility and wide coverage, and the generalization ability of the model is limited in complex environments (such as lighting changes and background interference). Secondly, some methods perform poorly in real-time and are difficult to meet the detection needs of industrial production. Therefore, there is an urgent need for a yarn break detection method that has both high accuracy and meets real-time requirements. Summary of the invention
[0004] The purpose of the present invention is to provide a yarn break detection method which can adapt to complex workshop environments, has high detection accuracy, and can meet real-time requirements.
[0005] The present invention is achieved through the following technical solutions:
[0006] A yarn break detection method comprises the following steps:
[0007] Step S1, an image acquisition module is set on the robot, so that the robot moves along the spinning production line and collects images of the yarn at fixed points, and the collected images are preprocessed to enhance the characteristic representation of the yarn fibers under a complex background, and the preprocessed images constitute a data set;
[0008] Step S2, constructing a detection model, the detection model is a MobileNetV3-Small model with an improved attention mechanism module, the improved attention mechanism module includes an input layer, a horizontal average pooling layer and a vertical average pooling layer respectively connected to the input layer, a splicing convolution layer respectively connected to the horizontal average pooling layer and the vertical average pooling layer, a horizontal convolution layer and a vertical convolution layer respectively connected to the splicing convolution layer, a recalibration layer respectively connected to the horizontal convolution layer, the vertical convolution layer and the input layer, a global average pooling layer connected to the recalibration layer, a convolution layer connected to the global average pooling layer to generate a channel attention weight, and an output layer, the convolution layer output is multiplied by the recalibration layer output as the output layer output;
[0009] Step S3: Input the data set into the detection model for detection. The loss function of the detection model is: ,in, Represents the loss term of Focal Loss, Represents the loss term of Center Loss, represents the weight hyperparameter used to balance the two losses.
[0010] Furthermore, in step S1, the robot includes a height-adjustable bracket, an LED light source arranged on the bracket to realize front lighting of the image acquisition module, an industrial computer arranged on the bracket, and a roller arranged at the lower end of the bracket, and the image acquisition module includes an industrial camera fixed on the bracket and located within the coverage range of the LED light source.
[0011] Furthermore, in step S1, preprocessing the acquired image specifically includes:
[0012] Step S11, using the Prewitt operator to perform edge detection on the image to obtain edge images edges;
[0013] Step S12: According to the formula Adjust the brightness and contrast of the edge image according to the formula The brightness and contrast adjusted image is linearly transformed so that all pixel values are restricted to the interval [0, 255], where a Represents the brightness adjustment coefficient, b represents the contrast adjustment coefficient;
[0014] Step S13: Using formula Gamma correction is performed on the image obtained in step S12 to obtain a preprocessed image. images .
[0015] Furthermore, in step S3, the step of inputting the data set into the detection model for detection specifically includes the following steps:
[0016] Step S31: All pre-processed images form a data set X , dataset X Enter the detection model from the input layer and use the formula in the horizontal average pooling layer Get a one-dimensional feature map in the horizontal direction , in the vertical average pooling layer, by formula Get a one-dimensional feature map in the vertical direction ;
[0017] Step S32: In the concatenated convolutional layer, the formula For one-dimensional feature map And one-dimensional feature map Splice along the width direction and pass the formula Perform channel number reduction;
[0018] Step S33: Perform BatchNorm activation and Swish activation on the reduced-dimensional tensor obtained in step S32, and use the formula Generate horizontal attention weights , in the vertical convolution layer by formula Generate vertical attention weights ,in, is the Sigmoid activation function;
[0019] Step S34: In the recalibration layer, the formula Get the recalibrated output feature map ;
[0020] Step S35: In the global pooling layer, the formula Perform global average pooling on the output feature map, and use the formula in the convolution layer Generate channel attention weights , according to the formula Get the output layer output .
[0021] Furthermore, in the step S1, the image captured by the image acquisition module contains three fibers, and the yarn breakage conditions of the images in the data set are classified according to whether each fiber is broken or not.
[0022] Furthermore, in step S3, the loss term of the Focal Loss Expressed as ,in, is the class weight used to balance the imbalance in the number of positive and negative samples, To test the model's prediction probability for the correct category, is a regulation factor used to reduce the loss value of easy-to-classify samples.
[0023] Furthermore, in step S3, the loss term of Center Loss is expressed as ,in, m represents the total number of samples in the dataset, x i Indicates i The characteristics of the samples, Indicates i The center point of the broken yarn category is calculated in the initialization stage of the detection model training. , and remain unchanged in the subsequent process.
[0024] Furthermore, in the step S1, the distance between the image acquisition module and the spinning machine in the spinning production line is 20-25 cm, and the height of the image acquisition module from the ground is 100-110 cm.
[0025] Furthermore, in step S1, the image acquisition module uses an MV-CA050-20GC industrial camera, and the exposure time of the industrial camera is set to 300-600 μs, the automatic gain is set to 10, and the gamma value is set to 0.6.
[0026] The present invention has the following beneficial effects:
[0027] The present invention first sets an image acquisition module on a robot, so that the robot moves along the spinning production line and collects images of yarn at fixed points, and preprocesses the collected images to enhance the characteristic representation of the yarn fibers under complex backgrounds. The preprocessed images constitute a data set, and then the data set is input into the constructed detection model to obtain the broken yarn detection result. The whole process does not require human participation, and the detection results are avoided from being affected by human factors. The image acquisition is suitable for the workshop environment, and the image preprocessing constructs a high-quality data set, so that the present invention is suitable for complex environments. The designed detection model can enhance the model's focusing ability on yarn features and the ability to capture spatial position information. The designed loss function can alleviate the problem of category imbalance, improve the consistency of features within a class and the distinguishability of features between classes. In summary, the present invention can realize real-time detection of broken yarn in the spinning process, and effectively improve the detection accuracy, thereby improving spinning efficiency, reducing raw material waste, and improving the quality of yarn products. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The present invention is further described in detail below with reference to the accompanying drawings.
[0029] Figure 1 It is a flow chart of the present invention.
[0030] Figure 2It is a structural schematic diagram of the detection model of the present invention.
[0031] Figure 3 It is a schematic diagram of the structure of the robot and the image acquisition module of the present invention.
[0032] Figure 4 This is a state diagram of the image acquisition device of the present invention.
[0033] Figure 5 are image instances of different categories in the dataset of the present invention.
[0034] Figure 6 This is the image before preprocessing in the present invention.
[0035] Figure 7 This is the image after preprocessing in the present invention. DETAILED DESCRIPTION
[0036] like Figure 1 and Figure 2 As shown, the yarn break detection method includes the following steps:
[0037] Step S1, an image acquisition module is set on the robot, so that the robot moves along the spinning production line and collects images of the yarn at fixed points, and the collected images are preprocessed to enhance the characteristic representation of the yarn fibers under a complex background, and the preprocessed images constitute a data set;
[0038] like Figure 3 As shown, the robot includes a height-adjustable bracket, an LED light source arranged on the bracket to realize front lighting of the image acquisition module, an industrial computer arranged on the bracket, and a roller arranged at the lower end of the bracket. The image acquisition module includes an industrial camera fixed on the bracket and located within the coverage range of the LED light source. The industrial camera model is MV-CA050-20GC. The exposure time of the industrial camera is set to 300-600μs, the automatic gain is set to 10, and the gamma value is set to 0.6 to adapt to the image clarity under different lighting conditions. In order to reduce the reflective interference on the surface of the equipment, the mono8 single-channel grayscale mode is adopted to improve the image contrast and stability and ensure the clear presentation of the fiber features. Among them, the specific structure of the bracket, the installation structure of the LED light source, and the control of the robot by the industrial computer are all existing technologies.
[0039] like Figure 4 As shown, the robot is controlled to collect data at fixed points along the spinning production line and acquire images periodically. The working distance between the industrial camera and the spinning machine is 22 cm to ensure sufficient space to avoid mechanical interference and maintain image clarity. The camera height is set to 105 cm to ensure that the field of view covers the broken yarn area and avoids perspective distortion.
[0040] The yarn breakage phenomenon is classified according to the breakage of each fiber. Theoretically, each image contains three fibers. According to whether each fiber is broken or not, the yarn breakage of the images in the dataset is classified. Specifically, each fiber is broken or not, and there are 2 3 = 8 possible combinations, thus divided into 8 categories. However, in actual data collection, the situation where the yarn is broken on both sides but not in the middle is relatively rare, and images of this category cannot be successfully acquired. Therefore, this embodiment performs classification analysis of broken yarn images based on the remaining seven categories. Figure 5 Examples of different categories of images in the dataset are shown, each of which is distinguished based on the breakage of three spindles of yarn. Figure 5 The image corresponding to 110g indicates that the third spindle yarn is broken, the image corresponding to 101g indicates that the second spindle yarn is broken, the image corresponding to 100g indicates that the second and third spindle yarns are broken, the image corresponding to 001g indicates that the first and second spindle yarns are broken, the image corresponding to 000g indicates that the first, second and third spindle yarns are broken, the image corresponding to 111g indicates that there is no break, and the image corresponding to 011 indicates that the first spindle yarn is broken. These images are collected by industrial cameras in actual production, ensuring the diversity and authenticity of the data set, providing high-quality samples for the training and verification of the detection model. Each image clearly shows the breakage site and its environment, helping the model learn and identify different yarn breakage phenomena.
[0041] In order to further optimize the image quality, the acquired images are preprocessed, specifically including the following steps:
[0042] Step S11: Use the Prewitt operator to detect the edge of the image to obtain the edge image edges. Specifically, the image edge is detected by the horizontal convolution kernel and the vertical convolution kernel respectively. The formula is: and , and merged with a weight of 0.5 to generate a complete edge image ;
[0043] Step S12: According to the formula Adjust the brightness and contrast of the edge image according to the formula After adjusting the brightness and contrast, the image is linearly transformed so that all pixel values y is limited to the interval [0, 255] and according to the formula The pixel value y Rounded to unsigned 8-bit integer format to ensure pixel values y The effective range is, a Represents the brightness adjustment coefficient, b represents the contrast adjustment coefficient;
[0044] Step S13: Using formula Gamma correction is performed on the image obtained in step S12 to obtain a preprocessed image. images , to improve the dynamic range of the image, enhance dark details, and effectively avoid local over-brightness problems caused by reflections.
[0045] By comparison Figure 6 and Figure 7 It can be seen that the image after the above enhancement processing has obvious improvements in brightness and detail performance, especially in the dark area, the fiber details are clearer, that is, the characteristic representation of the fiber in a complex background is enhanced, and at the same time, higher quality input data is provided for the subsequent detection algorithm.
[0046] Step S2, constructing a detection model, the detection model is a MobileNetV3-Small model with an improved attention mechanism module, the improved attention mechanism module includes an input layer, a horizontal average pooling layer and a vertical average pooling layer respectively connected to the input layer, a spliced convolution layer respectively connected to the horizontal average pooling layer and the vertical average pooling layer, an activation layer connected to the spliced convolution layer for BatchNorm and Swish activation, a horizontal convolution layer and a vertical convolution layer respectively connected to the activation layer, two Sigmoid activation layers respectively connected to the horizontal convolution layer and the vertical convolution layer, a recalibration layer respectively connected to the two Sigmoid activation layers and the input layer, a global average pooling layer connected to the recalibration layer, a convolution layer connected to the global average pooling layer to generate a channel attention weight, and an output layer, the convolution layer output is multiplied by the recalibration layer output as the output layer output;
[0047] Specifically, the MobileNetV3-Small model is selected as the base model, which consists of a series of depthwise separable convolutional layers, including two steps: depthwise convolution and pointwise convolution. The attention mechanism module of the existing MobileNetV3-Small model is improved to obtain the above-mentioned improved attention mechanism module, so as to more accurately capture the spatial and channel information in the feature map, so as to improve the feature enhancement effect.
[0048] Step S3: Input the data set into the detection model for detection. The loss function of the detection model is: ,in, Represents the loss term of Focal Loss, Represents the loss term of Center Loss, represents the weight hyperparameter used to balance the two losses;
[0049] The data set is input into the detection model for detection, which specifically includes the following steps:
[0050] Step S31: All pre-processed images form a data set X , datasetX Enter the detection model from the input layer, the data set X The size of the image is , the image is pooled in the horizontal average pooling layer by the formula Get a one-dimensional feature map in the horizontal direction , in the vertical average pooling layer, by formula Get a one-dimensional feature map in the vertical direction ,in, C is the number of channels, H is the height, W is the width;
[0051] Step S32: In the concatenated convolutional layer, the formula For one-dimensional feature map And one-dimensional feature map Splice along the width direction to get a size of Tensor Y , and by the formula Perform channel dimensionality reduction to reduce the number of channels To reduce the computational complexity, r is the scaling factor. represents the concatenation function, express convolution;
[0052] Step S33: BatchNorm activation and Swish activation are performed on the tensor after dimension reduction obtained in step S32, and the horizontal convolution layer and the Sigmoid activation layer connected thereto are activated by the formula Generate horizontal attention weights , in the vertical convolution layer and the Sigmoid activation layer connected to it, the formula is Generate vertical attention weights ,in, is the Sigmoid activation function;
[0053] Step S34: In the recalibration layer, the formula Get the recalibrated output feature map ;
[0054] Step S35: In the global pooling layer, the formula Perform global average pooling on the output feature map, and use the formula in the convolution layer Generate channel attention weights , according to the formula Get the output layer output , the output layer is output As the input features of the classification task of the MobileNetV3-Small model to obtain the final classification results, where Represents dot product.
[0055] In this way, the spatial and channel information in the feature map can be captured more accurately to improve the feature enhancement effect. At the same time, the computational complexity is significantly reduced through scaling factors and lightweight convolution operations. It is suitable for resource-constrained embedded systems and scenarios with high real-time requirements.
[0056] To solve the problem of class imbalance, a loss function that combines the loss term of Focal Loss and the loss term of Center Loss is designed to dynamically adjust the sample weights, increase the attention paid to minority classes and difficult-to-classify samples, and improve the performance of the model on minority classes.
[0057] Specifically, the loss term of Focal Loss Expressed as ,in, is the class weight used to balance the imbalance in the number of positive and negative samples, To test the model's prediction probability for the correct category, is a regulatory factor used to reduce the loss value of easy-to-classify samples, which can improve the model's learning ability for difficult-to-classify samples. , Focal Loss degenerates into standard cross entropy loss, when When , Focal Loss will suppress the loss contribution of high-confidence samples and enhance the weight of low-confidence samples, thereby focusing more on the learning of minority classes and difficult-to-classify samples. The loss term of CenterLoss is expressed as ,in, m represents the total number of samples in the dataset, x i Indicates i The characteristics of the samples, Indicates i The center point of the yarn-breaking category is calculated using the formula in the initialization stage of the detection model training. Calculate the characteristic mean of the sample , and remain unchanged in the subsequent process, which can reduce the computational complexity and maintain the effectiveness of the model. x k Indicates that it belongs to i Characteristics of samples in the category of yarn breakage, n Indicates the number of yarn breakage categories.
[0058] The above description is only a preferred embodiment of the present invention, and therefore cannot be used to limit the scope of implementation of the present invention. That is, equivalent changes and modifications made according to the scope of the patent application of the present invention and the contents of the specification should still fall within the scope covered by the patent of the present invention.
Claims
1. A yarn break detection method, characterized in that: The steps include: Step S1, an image acquisition module is set on the robot, so that the robot moves along the spinning production line and collects images of the yarn at fixed points, and the collected images are preprocessed to enhance the characteristic representation of the yarn fibers under a complex background, and the preprocessed images constitute a data set; Step S2, constructing a detection model, the detection model is a MobileNetV3-Small model with an improved attention mechanism module, the improved attention mechanism module includes an input layer, a horizontal average pooling layer and a vertical average pooling layer respectively connected to the input layer, a splicing convolution layer respectively connected to the horizontal average pooling layer and the vertical average pooling layer, a horizontal convolution layer and a vertical convolution layer respectively connected to the splicing convolution layer, a recalibration layer respectively connected to the horizontal convolution layer, the vertical convolution layer and the input layer, a global average pooling layer connected to the recalibration layer, a convolution layer connected to the global average pooling layer to generate a channel attention weight, and an output layer, the convolution layer output is multiplied by the recalibration layer output as the output layer output; Step S3: Input the data set into the detection model for detection. The loss function of the detection model is: ,in, Represents the loss term of Focal Loss, represents the loss term of Center Loss, represents the weight hyperparameter used to balance the two losses; In step S1, preprocessing the collected image specifically includes: Step S11, using the Prewitt operator to perform edge detection on the image to obtain edge images edges; Step S12: According to the formula Adjust the brightness and contrast of the edge image according to the formula Perform a linear transformation on the image after brightness and contrast adjustment so that all pixel values are restricted to the interval [0, 255], where y represents the pixel value of the edge image, a Represents the brightness adjustment coefficient, b represents the contrast adjustment coefficient; Step S13: Using formula Gamma correction is performed on the image obtained in step S12 to obtain a preprocessed image. images ; In step S3, the step of inputting the data set into the detection model for detection specifically includes the following steps: Step S31: All pre-processed images form a data set X , dataset X Enter the detection model from the input layer and use the formula in the horizontal average pooling layer Get a one-dimensional feature map in the horizontal direction , in the vertical average pooling layer, by formula Get a one-dimensional feature map in the vertical direction , where AvgPool() represents the average pooling operation; In step S3, the step of inputting the data set into the detection model for detection specifically includes the following steps: Step S31: All pre-processed images form a data set X , dataset X Enter the detection model from the input layer and use the formula in the horizontal average pooling layer Get a one-dimensional feature map in the horizontal direction , in the vertical average pooling layer, by formula Get a one-dimensional feature map in the vertical direction , where AvgPool() represents the average pooling operation; Step S32: In the concatenated convolution layer, the formula For one-dimensional feature map And one-dimensional feature map Splice along the width direction and pass the formula Perform channel dimensionality reduction, where Y represents the tensor obtained by concatenating the horizontal one-dimensional feature map and the vertical one-dimensional feature map, Concat() represents the concatenation operation, Conv1x1 represents the 1x1 convolution operation, and Z represents the concatenation operation. reduced It represents the feature map obtained after Y is reduced in dimension by 1x1 convolution operation; Step S33: Perform BatchNorm activation and Swish activation on the reduced-dimensional tensor obtained in step S32, and use the formula Generate horizontal attention weights , in the vertical convolution layer by formula Generate vertical attention weights ,in, is the Sigmoid activation function; Step S34: In the recalibration layer, the formula Get the recalibrated output feature map , where ⊙ represents the element-by-element multiplication operation; Step S35: In the global pooling layer, the formula Perform global average pooling on the output feature map, and use the formula in the convolution layer Generate channel attention weights , according to the formula Get the output layer output , where GAP() represents the global average pooling operation.
2. A yarn break detection method according to claim 1, characterized in that: In step S1, the robot includes a height-adjustable bracket, an LED light source arranged on the bracket to realize front lighting of an image acquisition module, an industrial computer arranged on the bracket, and a roller arranged at the lower end of the bracket. The image acquisition module includes an industrial camera fixed on the bracket and located within the coverage range of the LED light source.
3. A yarn break detection method according to claim 2, characterized in that: In the step S1, the image captured by the image acquisition module contains three spindles of fibers, and the yarn breakage conditions of the images in the data set are classified according to whether each spindle of fiber is broken or not.
4. A yarn breakage detection method according to claim 3, characterized in that: In step S3, the loss term of the Focal Loss Expressed as ,in, is the class weight used to balance the imbalance in the number of positive and negative samples, To test the model's prediction probability for the correct category, is a regulation factor used to reduce the loss value of easy-to-classify samples.
5. A yarn breakage detection method according to claim 4, characterized in that: In step S3, the loss term of Center Loss is expressed as ,in, m represents the total number of samples in the dataset, x i Indicates i The characteristics of the samples, Indicates i The center point of the yarn breakage category, Indicates i The features of the samples and their corresponding center points The square of the L2 norm between , in the initialization stage of the detection model training, the feature mean of the sample is calculated , and remain unchanged in subsequent processes.
6. A yarn breakage detection method according to any one of claims 1 to 5, characterized in that: In the step S1, the distance between the image acquisition module and the spinning machine in the spinning production line is 20-25 cm, and the height of the image acquisition module from the ground is 100-110 cm.
7. A yarn breakage detection method according to any one of claims 1 to 5, characterized in that: In step S1, the image acquisition module uses an MV-CA050-20GC industrial camera, and the exposure time of the industrial camera is set to 300-600 μs, the automatic gain is set to 10, and the gamma value is set to 0.6.
Citation Information
Patent Citations
Yarn breakage detection method and device, electronic equipment, storage medium and shutdown system
CN111724377A
Target detection method based on attention mechanism
CN114882205A