Defective cotton foreign fiber detection method and system, terminal and storage medium

The YOLOv8-MMW algorithm enhances foreign fiber detection in defective cotton by using data augmentation and adaptive lighting, addressing inefficiencies and improving detection accuracy and speed.

CN119205615APending Publication Date: 2024-12-27SHIHEZI UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411080694.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Existing methods for detecting foreign fibers in defective cotton are inefficient, labor-intensive, and struggle with high cotton drop rates and poor detection of small targets, particularly under varying environmental conditions.

Method used

A method utilizing a YOLOv8-MMW algorithm enhanced with data augmentation techniques and a lightweight MobileNetV3 backbone, combined with a WIoU loss function and adaptive lighting, to accurately identify and locate foreign fibers in cotton images.

Benefits of technology

The method achieves over 95% accuracy in detecting various foreign fibers, reduces model weight by 56.7%, increases frame rate by 16.1%, and ensures real-time detection of small targets with improved robustness and generalization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119205615A_ABST
    Figure CN119205615A_ABST
Patent Text Reader

Abstract

The invention discloses a defective cotton foreign fiber detection method and system, a terminal and a storage medium, and the method comprises the steps: in an image collection system, employing a CCD industrial camera to carry out image collection on a defective cotton detection area irradiated by an LED light source, and obtaining a defective cotton image; forming sample data by the collected defective cotton images, performing data enhancement operation on the sample data to obtain an enhanced data set, and dividing the enhanced data set into a test set, a verification set and a training set; selecting YOLOv8 as a baseline model, and improving the baseline model to obtain a YOLOv8-MMW algorithm; and inputting the training set into the YOLOv8-MMW algorithm for training to obtain a training model, and carrying out identification and classification on the test set based on the training model to obtain the type and position of the foreign fiber. According to the invention, defective cotton and foreign fibers can be rapidly and accurately detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of foreign fiber detection, and in particular to a method, system, terminal and storage medium for detecting foreign fibers in defective cotton. Background Art

[0002] Cotton is often used as raw material for the textile industry, but some impurities are inevitably mixed in the cotton collection process, such as white paper, feathers, hair, polypropylene yarn, polypropylene sheets, etc. As an important link in the two major production fields of cotton planting industry and manufacturing industry, the quality of its output will directly affect the product quality of downstream industries. Although cotton mills use foreign fiber machines for the initial sorting of raw cotton, the cotton drop rate in the process of foreign fiber removal (that is, the ratio of the weight of the cotton dropped removed from the impurity removal mechanism to the weight of the raw cotton fed) is still as high as 5% to 10%, resulting in a large amount of defective cotton. In view of the need for secondary use of these defective cottons in cotton mills, foreign fibers in defective cotton need to be sorted for the second time. At present, the sorting of defective cotton foreign fibers mainly relies on manual labor. Problems such as high labor input and low detection efficiency have become key factors restricting the development of the textile industry. Therefore, it is of great significance to realize the automatic detection technology of defective cotton foreign fibers.

[0003] In view of the drawbacks of manual detection of defective cotton, researchers have proposed a method for identifying defective cotton and foreign fibers based on machine vision, which is mainly divided into traditional machine learning methods and deep learning methods. Common traditional machine learning methods include decision trees, support vector machines, and artificial neural networks. These methods rely on manual extraction of features such as texture and color, and then classify them according to the extracted features to achieve the purpose of identifying different foreign fibers. Although these traditional methods are simple and efficient, the feature extraction process is easily affected by environmental factors such as lighting and angle, and features need to be manually designed for different types of foreign fibers, so the generalization performance is poor. Compared with traditional methods, common deep learning methods include Faster R-CNN, YOLO series, and SSD. These methods complete the task of foreign fiber detection by autonomously learning the features of foreign fiber samples through multiple training of data sets. Although the use of deep learning for foreign fiber target detection is successful, there are still problems such as redundant detection model structure and small target foreign fibers are easily missed. Therefore, it is very necessary and important to find a method to quickly and accurately detect defective cotton and foreign fibers. Summary of the invention

[0004] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a method, system, terminal and storage medium for detecting foreign fibers in defective cotton are provided, aiming to solve the technical problem that the prior art is difficult to detect small target foreign fibers in defective cotton and has poor real-time performance.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0006] In a first aspect, the present invention provides a method for detecting foreign fibers in defective cotton, wherein the method comprises:

[0007] In the image acquisition system, a CCD industrial camera is used to acquire images of the defective cotton detection area illuminated by the LED light source to obtain defective cotton images;

[0008] The collected defective cotton images are formed into sample data, a data enhancement operation is performed on the sample data to obtain an enhanced data set, and the data enhanced data set is divided into a test set, a validation set and a training set;

[0009] Select YOLOv8 as the baseline model, and improve the baseline model to obtain the YOLOv8-MMW algorithm;

[0010] The training set is input into the YOLOv8-MMW algorithm for training to obtain a training model, and the test set is identified and classified based on the training model to obtain the type and location of foreign fibers.

[0011] In one implementation, the data enhancement operation includes at least two of: image mirroring, brightness change, Gaussian blur, pixel translation, size scaling, rotation transformation and / or pixel discarding.

[0012] In one implementation, the improving the baseline model to obtain the YOLOv8-MMW algorithm includes:

[0013] The backbone network of the baseline model is replaced by the lightweight model MobileNetV3;

[0014] Remove the last four layers and add an attention mechanism to the last layer of the baseline model;

[0015] The CIoU loss function in the baseline model is replaced by the WIoU loss function to obtain the YOLOv8-MMW algorithm.

[0016] In one implementation, the input end of the YOLOv8-MMW algorithm processes the pre-classified image through Mosaic data enhancement, wherein the structure of the detection network in the YOLOv8-MMW algorithm includes a feature extraction part, a feature fusion part and a target detection part, wherein the feature extraction part is responsible for capturing basic features from the input defective cotton image to provide rich original information for subsequent processing; the feature fusion part is responsible for enhancing the information exchange between features at different levels and improving the expressiveness of the feature map; the target detection part uses the fused feature map to predict the position and category of the target to complete the final detection task.

[0017] In one implementation, the WIoU loss function is:

[0018]

[0019] Among them, β is an outlier, which is used to describe the quality of the anchor box; δ and α are hyperparameters, both of which can be adjusted according to different models; and are the center positions of the predicted anchor boxes respectively; and is the coordinate of the center point of the annotation box; c w and c h They are the width and height of the minimum enclosing rectangle of the prediction box and annotation box, respectively.

[0020] In one implementation, the image acquisition system includes a conveyor belt, an image acquisition box is provided above the conveyor belt, a CCD industrial camera and an LED light source are installed in the image acquisition box, the illumination area of ​​the LED light source is consistent with the image acquisition area of ​​the CCD industrial camera, and the CCD industrial camera is connected to a data acquisition terminal.

[0021] In one implementation, the LED light source is divided into two groups, one group is an LED white light source, which is used when collecting dark foreign fibers; the other group is an LED ultraviolet light source with a wavelength of 365nm, which is used when collecting fluorescent foreign fibers;

[0022] The LED light source is fixed on the image acquisition box at an angle of 45° in the horizontal direction.

[0023] In a second aspect, an embodiment of the present invention further provides a defective cotton foreign fiber detection system, wherein the system comprises:

[0024] The defective cotton image acquisition module is used to acquire the image of the defective cotton detection area irradiated by the LED light source by using a CCD industrial camera in the image acquisition system to obtain the defective cotton image;

[0025] A data set processing module, used for forming sample data from the collected defective cotton images, performing data enhancement operation on the sample data to obtain an enhanced data set, and dividing the data enhanced data set into a test set, a validation set and a training set;

[0026] An algorithm improvement module, used for selecting YOLOv8 as a baseline model and improving the baseline model to obtain a YOLOv8-MMW algorithm;

[0027] The model training and foreign fiber identification module is used to input the training set into the YOLOv8-MMW algorithm for training to obtain a training model, and identify and classify the test set based on the training model to obtain the type and location of the foreign fiber.

[0028] In a third aspect, an embodiment of the present invention further provides a terminal, wherein the terminal includes a memory, a processor, and a defective cotton foreign fiber detection program stored in the memory and executable on the processor, and when the processor executes the defective cotton foreign fiber detection program, the steps of the defective cotton foreign fiber detection method of any one of the above-mentioned schemes are implemented.

[0029] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein a defective cotton foreign fiber detection program is stored on the computer-readable storage medium, and when the defective cotton foreign fiber detection program is executed by a processor, the steps of the defective cotton foreign fiber detection method described in any one of the above schemes are implemented.

[0030] Beneficial effects: Compared with the prior art, the present invention provides a method for detecting foreign fibers in defective cotton. The image acquisition system of the present invention realizes the integration of optics, mechanics, electronics and computers, and can detect various foreign fibers, such as mulch films, cotton stalks, paper pieces, polypropylene yarns, polypropylene sheets, etc., with ultra-high accuracy, and its detection accuracy can reach more than 95%. The LED ultraviolet light source in the image acquisition system of the present invention obliquely illuminates the foreign fibers containing fluorescent substances in cotton at a 45° angle. The image collected by the CCD industrial camera can show obvious characteristics, and the fluorescent effect foreign fiber target detection algorithm can realize the real-time detection requirements of white transparent foreign fibers such as mulch films; the use of CCD industrial cameras can retain rich image information to the maximum extent, and at the same time, it can also obtain high-definition images when capturing fast-moving defective cotton, so that better detection effects can be achieved using fewer convolution kernels. In view of this feature, the present invention improves the original YOLOv8 algorithm, reducing the number of floating-point calculations of its network structure by 69.1%. The improved YOLOv8 algorithm has been tested to reduce the weight of the trained model by 56.7%, increase the frame rate by 16.1%, and achieve the fastest detection time of 2.7ms / image for a single image. The data enhancement algorithm for small sample data in the present invention increases the amount of training data, improves the generalization ability of the training model, better adapts to the environment and working conditions, and improves the robustness of the training model. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A flowchart of a specific implementation of a method for detecting foreign fibers in defective cotton provided in an embodiment of the present invention.

[0032] Figure 2 A schematic structural diagram of an image acquisition system in a method for detecting foreign fibers in defective cotton provided by an embodiment of the present invention.

[0033] Figure 3 A structural diagram of the YOLOv8-MMW network based on the improved YOLOv8 model in the defective cotton foreign fiber detection method provided in an embodiment of the present invention.

[0034] Figure 4A structural diagram of the attention mechanism in the defective cotton foreign fiber detection method provided in an embodiment of the present invention.

[0035] Figure 5 This is a principle block diagram of a defective cotton foreign fiber detection system provided in an embodiment of the present invention.

[0036] Figure 6 A functional block diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0038] As construction projects increase in complexity, manually managing and analyzing these drawings becomes increasingly time-consuming and laborious, especially when specific data needs to be extracted from a large number of drawings or error checking is required. Traditional methods rely on visual inspection and manual input by professionals, which is not only inefficient but also prone to errors. In addition, as construction projects grow in size and revisions are frequent, maintaining the accuracy and up-to-dateness of drawings becomes a challenge.

[0039] The defective cotton foreign fiber detection method provided in this embodiment can be used in a terminal, and the terminal can be an intelligent product terminal such as a computer. Figure 1 As shown in , the following steps are included:

[0040] Step S100: In the image acquisition system, a CCD industrial camera is used to acquire an image of the defective cotton detection area illuminated by the LED light source to obtain a defective cotton image;

[0041] Step S200, the collected defective cotton images are formed into sample data, data enhancement operation is performed on the sample data to obtain an enhanced data set, and the data enhanced data set is divided into a test set, a validation set and a training set;

[0042] Step S300, selecting YOLOv8 as a baseline model, and improving the baseline model to obtain a YOLOv8-MMW algorithm;

[0043] Step S400: input the training set into the YOLOv8-MMW algorithm for training to obtain a training model, and identify and classify the test set based on the training model to obtain the type and location of foreign fibers.

[0044] Combination Figure 2As shown, the image acquisition system of this embodiment includes a conveyor belt 1, the speed of the conveyor belt is 0-30m / min, and the motor power is 50w. The photoelectric sensor 2 is located on both sides of the operating table above the conveyor belt 1. The conveyor belt 1 is connected to the servo motor 8, and the servo motor 8 is connected to the controller. The controller controls the rotation of the servo motor 8 by issuing a command through the control button to control the speed of the conveyor belt. The conveyor belt is about 70cm directly below the CCD industrial camera 5. An image acquisition box 3 is provided above the conveyor belt 1, and a CCD industrial camera 5, a front LED light source 4 and a rear LED light source 6 are installed on the image acquisition box 3. The light emission area of ​​the front LED light source 4 and the rear LED light source 6 is consistent with the image acquisition area of ​​the CCD industrial camera 5, and the CCD industrial camera 5 and the LED light source are connected to the data acquisition terminal 9. The data acquisition terminal 9 acquires and stores the image collected by the CCD industrial camera 5 through an online detection method. It includes a 365nm LED light source, a CCD industrial camera 5, a conveyor belt 2, a servo motor 8, and a data acquisition terminal 9; the CCD industrial camera 5 and the LED light source are fixed on a light-shielding box 3, and the conveyor belt is located directly below the CCD industrial camera 5. The resolution of the CCD industrial camera 5 is 1294px×964px, and the frame rate is 30fps. The image captured by the CCD industrial camera 5 has a high signal-to-noise ratio, the noise generated during the image acquisition process is low, and the captured image is more stable. The front LED light source 4 and the rear LED light source 6 are 365nm ultraviolet light sources with a power of 200W and a divergence angle of 90°. Irradiation with a 365nm ultraviolet light source can cause a fluorescent effect on certain foreign fibers containing whitening agents. The front LED light source 4 and the rear LED light source 6 are 45° in the horizontal direction, and the angle is fixed on the image acquisition box 3. The image captured by the 45° oblique projection has better contrast characteristics. The horizontal distance between the CCD industrial camera and the 365nm ultraviolet light source is about 25cm, and the vertical distance is about 35cm.

[0045] In the specific implementation, the loosened and flattened cotton moves to the detection area along the conveyor belt; then, the light emitted by the front LED light source 4 and the rear LED light source 6 is projected obliquely on the cotton in the detection area; the cotton in the detection area illuminated by the front LED light source 4 and the rear LED light source 6 is collected in real time by the CCD industrial camera 5, and the collected defective cotton image is transmitted to the data collection terminal 9 in real time to obtain sample data composed of the collected defective cotton image. Foreign fibers are generally dense structures, and when the LED light source 4 and the rear LED light source 6 are vertically hit, the reflected light is too strong, which produces a similar "glare", making the contrast between foreign fibers and defective cotton weak; after changing the light source projection angle many times, it is found that when the angle is about 45°, the contrast is enhanced, and the collected defective cotton image has better contrast characteristics.

[0046] Since there are few labeled foreign fiber sample data in defective cotton images, and the foreign fiber samples collected and produced by ourselves are limited, this embodiment performs data enhancement on the small sample data of foreign fibers. The data enhancement method includes at least two of the following: image mirroring, brightness change, Gaussian blur, pixel translation, size scaling, rotation transformation and / or pixel discarding.

[0047] Before training the sample data, seven target detection enhancement strategies, including mirroring, brightness change, Gaussian blur, pixel translation, size scaling, rotation transformation, and pixel discarding, are used to enhance the generalization and robustness of the model. Among them, the image is swapped left and right along the vertical center axis of the image; mirroring is the easiest image expansion to implement, which enhances the model's understanding of left-right symmetry. The brightness change is to multiply each pixel grayscale value by a random coefficient between 0.5 and 1.5, simulating lighting conditions from dim to bright, and improving the model's adaptability to lighting changes. The standard deviation of the Gaussian transform of the Gaussian blur is 0 to 3.0. The random value matrix sampled from the Gaussian distribution is added to the RGB pixels of the image. Adding noise to the image can help CNN (convolutional neural network) learn more powerful functions. A Gaussian kernel with a standard deviation of 0 to 3.0 is applied for blurring. By introducing noise, the model's generalization ability to image details is enhanced. Pixel translation randomly translates pixels in the range of -20% to +20%, effectively avoiding the model's dependence on the fixed position of the target object and enhancing position invariance. Size scaling randomly scales the image size to 80% to 120% of the original size to train the model to recognize target objects of different sizes, thereby enhancing scale invariance. Rotation transformation randomly rotates the image to between -270° and +270°, simulating the various orientations that the target object may appear in the image, thereby improving the model's generalization to directional changes. Pixel discarding randomly removes 1% to 10% of the pixels and sets the grayscale values ​​of these pixels to zero. This enhancement improves the robustness of the model in the case of partial occlusion of the image and enables the network to understand the image content more comprehensively.

[0048] This embodiment performs three image enhancement methods, namely, mirroring, brightness, and Gaussian, on each sample data collected, and the number of expansions of each enhancement algorithm is the same as the original sample. For example, if 2049 foreign fiber samples are collected, after seven enhancements, the total data set obtained is 2049+2049×3=8196. After obtaining the defective cotton images after data enhancement, this embodiment divides the defective cotton images after data enhancement into a training set, a test set, and a verification set, wherein the number of defective cotton images in the training set, the test set, and the verification set is 7:2:1, that is, among the 8196 defective cotton images, there are 5737 defective cotton images in the training set, 1640 defective cotton images in the test set, and 819 defective cotton images in the verification set.

[0049] The YOLOv8-MMW algorithm of this embodiment is used to identify foreign fibers with obvious classification color characteristics in the image and foreign fibers that produce a fluorescent effect under the irradiation of an LED ultraviolet light source with a wavelength of 365nm. Figure 3 As shown in the figure, the YOLOv8-MMW model includes feature extraction, feature fusion and target detection. The feature extraction part is responsible for capturing basic features from the input defective cotton image and providing rich original information for subsequent processing; the feature fusion part is responsible for enhancing the information exchange between features at different levels and improving the expressiveness of feature maps; the target detection part uses the fused feature map to predict the location and category of the target and complete the final detection task.

[0050] The feature extraction part includes a MobileNetV3 network, 1 SPPF layer and an attention mechanism MCA, which are used to extract deep features of the image. Referring to Table 1, the MobileNetV3 network structure specifically includes: 1 convolution layer (Conv) and 11 bneck layers, wherein the convolution kernel size of the convolution layer is 3×3 and the number is 16. The SPPF layer includes 2 convolution layers (Conv) with a convolution kernel size of 1×1, 3 maximum pooling layers (MaxPool) with a pooling kernel size of 5×5, and 1 feature concatenation layer (Concat), wherein the number of convolution kernels in each 1×1 convolution layer is equal to the number of channels of the input feature map, and the stride of the pooling layer is 5. Finally, the outputs of these layers are combined in the feature concatenation layer. Figure 4 As shown in , where C represents the number of channels of the feature map, H represents the height of the feature map, and W represents the width of the feature map, the MCA attention mechanism includes 3 layers of 1×1 convolutional layers (Conv), 3 layers of global average pooling layers (AvgPool), 3 layers of global standard deviation pooling layers (StdPool), 3 adaptive combination mechanisms, 3 layers of 3×3 convolutional layers, 3 gating mechanisms, 3 activation function layers, 3 feature recalibration operations, and 1 feature integration operation. The input feature map is sent to the three branches respectively. In each branch, it first passes through the 1×1 convolutional layer, then the global average pooling layer and the global standard deviation pooling layer, and then the feature is merged through the adaptive combination mechanism. After that, the local feature interaction is performed through the 3×3 convolutional layer, and then the attention weights are generated through the gating mechanism and activation function. These weights are applied to the feature recalibration operation. Finally, the outputs of all branches are summarized through the feature integration operation to generate the final output feature map.

[0051] Furthermore, the MobileNetV3 network specifically includes two versions: MobileNetV3-Large and MobileNetV3-Small. This embodiment selects MobileNetV3-Small and removes the last four layers.

[0052] Furthermore, the bneck layer specifically includes three necessary layers: a 1×1 convolution layer, which is converted from an input channel to an expansion channel, a 3×3 or 5×5 depthwise separable convolution layer, which is an expansion channel with a stride of 1 or 2, and finally a 1×1 convolution layer, which is converted from an expansion channel to an input channel. In addition, two optional layers are included, namely, an SE layer and a Residual layer, and the activation functions include two types, namely, ReLU and h-swish. The network structure of MobileNetV3 in this embodiment is shown in Table 1.

[0053] Table 1

[0054] Input scale Related operations Output Channel SE Activation Function stride <![CDATA[224 2 ×3]]> conv2d, 3×3 16 - HS 2 <![CDATA[112 2 ×16]]> bneck, 3×3 16 √ RE 2 <![CDATA[56 2 ×16]]> bneck, 3×3 24 - RE 2 <![CDATA[28 2 ×24]]> bneck, 3×3 24 - RE 1 <![CDATA[28 2 ×24]]> bneck, 5×5 40 √ HS 2 <![CDATA[14 2 ×40]]> bneck, 5×5 40 √ HS 1 <![CDATA[14 2 ×40]]> bneck, 5×5 40 √ HS 1 <![CDATA[14 2 ×40]]> bneck, 5×5 48 √ HS 1 <![CDATA[14 2 ×48]]> bneck, 5×5 48 √ HS 1 <![CDATA[14 2 ×48]]> bneck, 5×5 96 √ HS 2 <![CDATA[7 2 ×96]]> bneck, 5×5 96 √ HS 1 <![CDATA[7 2 ×96]]> bneck, 5×5 96 √ HS 1

[0055] The feature fusion part of this embodiment adopts the PANet structure, and the expressive ability of the feature map is enhanced through top-down and bottom-up paths. The PANet structure includes 2 upsampling layers (Upsample), 4 feature concatenation layers (Concat), 4 C2f layers and 2 3×3 convolution layers (Conv). The feature map is first expanded in size through the upsampling layer, and the nearest neighbor method is used to ensure that the resolution matches the subsequent layer. Then, the upsampled feature map is spliced ​​with the feature map of the corresponding level in the feature extraction part in the channel dimension to achieve preliminary fusion of features. Next, the fused feature map enters the C2f layer, and the features are further extracted and refined through 1×1 and 3×3 convolution operations, where the residual connection enhances the learning ability of the network. In addition, the feature map adjusts the number of channels through the 3×3 convolution layer to prepare for multi-scale feature fusion. In the PANet structure, the feature map is iterated through the top-down and bottom-up paths, and its expressive ability is gradually enhanced after upsampling, feature concatenation and convolution processing. In addition, the integrated attention mechanism enhances the significance of important information in the feature map. After this series of coherent processing, the feature map is enriched with multi-scale and multi-level feature information, providing high-quality input for the target detection part and achieving accurate target recognition and positioning.

[0056] The target detection part of this embodiment combines the outputs of the three C2f layers of the feature fusion part to predict the bounding box coordinates, category probability and confidence through the convolution layer. Target detection combines a special bounding box loss function with NMS non-maximum suppression to optimize the accuracy of the prediction while ensuring the efficiency of the detection process. The YOLOv8-MMW algorithm adjusts the size and performance of the model by setting specific depth coefficients (depth_multiple=0.33) and width coefficients (width_multiple=0.25) to meet different application requirements. Finally, the target detection part outputs a prediction result that integrates the bounding box coordinates, category probability and confidence, achieving efficient and high-precision target detection.

[0057] After the training model is trained, the defective cotton images of the divided test set are input for final detection. The test set is passed to the trained training model for detection, and the final detection results are output. Through the YOLOv8-MMW algorithm detection of the training model, the type and location of foreign fibers are output.

[0058] The input of the YOLOv8-MMW algorithm processes the pre-classified images through Mosaic data enhancement. Mosaic data enhancement randomly crops four images and then splices them into one image as training data, enriching the background of the image.

[0059] YOLOv8-MMW uses an adaptive image scaling method to process images. Scaling is a preprocessing process built into the YOLOv8 algorithm. Different images have different lengths and widths. The original images, i.e., the original images captured by the camera, are uniformly scaled to a standard size and then fed into the detection model. An adaptive image scaling method is used to process image inputs of different sizes, and adaptive anchor box calculation is used to assist in the prediction of the bounding box, that is, by calculating the difference between the predicted box and the true box, the loss function is used to back-propagate the error, thereby iteratively updating the network parameters.

[0060] The output end of the target detection part of this embodiment includes a bounding box loss function and NMS non-maximum suppression.

[0061] The bounding box loss function adopts the WIoU loss function as follows:

[0062] L WIoU =rR WIoU L IoU (1)

[0063] Among them, L WIoU is the dynamic loss function, r is the non-monotonic focus factor, R WIoU It is a weight coefficient penalty term, and LIoU is the intersection-over-union ratio of the overlapping area of ​​the prediction box and the annotation box;

[0064]

[0065]

[0066] Among them, β is an outlier, which is used to describe the quality of the anchor box; δ and α are hyperparameters, both of which can be adjusted according to different models; is the monotonic focus coefficient; It is the intersection-and-union ratio of the overlapping area of ​​the prediction box and the annotation box; and are the center positions of the predicted anchor boxes respectively; and is the coordinate of the center point of the annotation box; cw and c h They are the width and height of the minimum enclosing rectangle of the prediction box and annotation box, respectively.

[0067] The final WIoU loss function is:

[0068]

[0069] The WIoU loss function not only avoids the calculation of inverse trigonometric functions when using CIoU as the loss function, but also solves the problem of balancing samples with different recognition difficulties. By introducing a dynamic focusing mechanism, WIoU can calculate the most appropriate gradient gain allocation strategy according to the current situation. This strategy judges the quality of the anchor box by outliers and allocates smaller gradient gains to high-quality and low-quality anchor boxes. This not only reduces the additional computational burden that may be caused by processing low-quality samples, but also avoids the waste of computational resources caused by excessive attention to high-quality samples. The model therefore pays more attention to anchor boxes of ordinary quality, thereby improving the overall detection performance of the model without sacrificing performance and reducing the overall computational power consumption. In addition, WIoU's dynamic non-monotonic focusing mechanism helps to reduce the gradient vanishing problem, further improves the efficiency of model training, and reduces the consumption of computing resources.

[0070] The depth coefficient of the YOLOv8-MMW algorithm of this embodiment is depth_multiple=0.33, and the width coefficient is width_multiple=0.25. The model weight is reduced by 56.7% and the frame rate is increased by 16.1%. There are 5 versions of the YOLOv8 target detection network in the YOLOv8 model suitable for the image acquisition system, namely YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8xl. The YOLOv8n network is the network with the smallest network depth and width in the YOLOv8 series. The following 4 types are continuously deepened and widened on this basis. The five structures control the depth and width of the network through the two parameters of depth_multiple and width_multiple. Among them, depth_multiple controls the depth of the network, and width_multiple controls the width of the network. The deeper the depth of the network, the stronger the feature extraction ability of the network. The wider the width of the network, the stronger the learning ability of the network to extract features. The lightweight design of the YOLOv8n model not only speeds up the training process, but also generates a more compact model, which is very suitable for industrial application scenarios with high real-time requirements. YOLOv8n's multi-scale feature fusion and feature extraction capabilities ensure that the detection performance will not be significantly reduced even when computing resources are reduced, thereby improving operational efficiency while ensuring the reliability of the detection task. YOLOv8n's depth_multiple=0.33, width_multiple=0.25. The present invention has undergone multiple experiments based on the YOLOv8n network. When depth_multiple is set to 0.33 and width_multiple is set to 0.25, the model weight is reduced by 56.7% and the frame rate is increased by 16.1%, which meets the online detection requirements of our detection system.

[0071] In the final detection part of this embodiment, the image detected by the YOLOv8-MMW algorithm is the defective cotton image collected by the CCD industrial camera. The divided training set and verification set are input into the YOLOv8-MMW algorithm for training, and a trained training model is obtained. The actual detection data source is the test set divided in step S2, and the test set is input into the trained training model for detection.

[0072] The defective cotton after opening is transmitted to the detection area composed of CCD industrial camera 5 and LED light source through a conveyor belt, and the image collected in the detection area is transmitted to the data acquisition terminal 9 for storage, and input into the YOLOv8-MMW algorithm for training and testing, and finally the prediction results of bounding box coordinates, category probability and confidence are obtained. The present invention designs a YOLOv8-MMW algorithm for small target foreign fibers and good real-time performance, and finally realizes the recognition, classification and positioning of foreign fibers.

[0073] Based on the above embodiments, the present invention also provides a defective cotton foreign fiber detection system, such as Figure 5 As shown in , the system includes: a defective cotton image acquisition module 10, a data set processing module 20, an algorithm improvement module, and a model training and foreign fiber identification module 40. Specifically, the defective cotton image acquisition module 10 is used to use a CCD industrial camera in the image acquisition system to acquire images of the defective cotton detection area illuminated by the LED light source to obtain defective cotton images. The data set processing module 20 is used to form sample data from the acquired defective cotton images, perform data enhancement operations on the sample data to obtain an enhanced data set, and divide the enhanced data set into a test set, a validation set, and a training set. The algorithm improvement module 30 is used to select YOLOv8 as a baseline model, and improve the baseline model to obtain a YOLOv8-MMW algorithm. The model training and foreign fiber identification module 40 is used to input the training set into the YOLOv8-MMW algorithm for training to obtain a training model, and identify and classify the test set based on the training model to obtain the type and location of foreign fibers.

[0074] The working principles of each module in the defective cotton foreign fiber detection system of this embodiment are the same as the principles of each step in the above method embodiment, and will not be repeated here.

[0075] Based on the above embodiment, the present invention further provides a terminal, the principle block diagram of the terminal can be as follows: Figure 6 The terminal may include one or more processors 100 ( Figure 6 Only one is shown in the figure), a memory 101 and a computer program 102 stored in the memory 101 and executable on one or more processors 100, for example, a defective cotton foreign fiber detection program. When one or more processors 100 execute the computer program 102, each step in the defective cotton foreign fiber detection method embodiment can be implemented. Alternatively, when one or more processors 100 execute the computer program 102, the functions of each module / unit in the defective cotton foreign fiber detection method embodiment can be implemented, which is not limited here.

[0076] In one embodiment, the processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0077] In one embodiment, the memory 101 may be an internal storage unit of an electronic device, such as a hard disk or memory of the electronic device. The memory 101 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 101 may also include both an internal storage unit of the electronic device and an external storage device. The memory 101 is used to store computer programs and other programs and data required by the terminal. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0078] Those skilled in the art will understand that Figure 6 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal to which the scheme of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0079] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, operating database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double operational data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting foreign fibers in defective cotton, characterized in that: The method comprises: In the image acquisition system, a CCD industrial camera is used to acquire images of the defective cotton detection area illuminated by the LED light source to obtain defective cotton images; The collected defective cotton images are formed into sample data, a data enhancement operation is performed on the sample data to obtain an enhanced data set, and the data enhanced data set is divided into a test set, a validation set and a training set; Select YOLOv8 as the baseline model, and improve the baseline model to obtain the YOLOv8-MMW algorithm; The training set is input into the YOLOv8-MMW algorithm for training to obtain a training model, and the test set is identified and classified based on the training model to obtain the type and location of foreign fibers.

2. The method for detecting foreign fibers in defective cotton according to claim 1, characterized in that: The data enhancement operation includes: at least two of image mirroring, brightness change, Gaussian blur, pixel translation, size scaling, rotation transformation and / or pixel discarding.

3. The method for detecting foreign fibers in defective cotton according to claim 1, characterized in that: The baseline model is improved to obtain the YOLOv8-MMW algorithm, including: The backbone network of the baseline model is replaced by a lightweight model MobileNetV3; Remove the last four layers and add an attention mechanism to the last layer of the baseline model; The CIoU loss function in the baseline model is replaced by the WIoU loss function to obtain the YOLOv8-MMW algorithm.

4. The method for detecting foreign fibers in defective cotton according to claim 3, characterized in that: The input end of the YOLOv8-MMW algorithm processes the pre-classified image through Mosaic data enhancement, wherein the structure of the detection network in the YOLOv8-MMW algorithm includes a feature extraction part, a feature fusion part and a target detection part. The feature extraction part is responsible for capturing basic features from the input defective cotton image to provide rich original information for subsequent processing; the feature fusion part is responsible for enhancing the information exchange between features at different levels and improving the expressiveness of the feature map; the target detection part uses the fused feature map to predict the position and category of the target to complete the final detection task.

5. The method for detecting foreign fibers in defective cotton according to claim 3, characterized in that: The WIoU loss function is: Among them, β is an outlier, which is used to describe the quality of the anchor box; δ and α are hyperparameters, both of which can be adjusted according to different models; and are the center positions of the predicted anchor boxes respectively; and is the coordinate of the center point of the annotation box; c w and c h They are the width and height of the minimum enclosing rectangle of the prediction box and annotation box, respectively.

6. The method for detecting foreign fibers in defective cotton according to claim 1, characterized in that: The image acquisition system includes a conveyor belt, an image acquisition box is arranged above the conveyor belt, a CCD industrial camera and an LED light source are installed in the image acquisition box, the irradiation area of ​​the LED light source is consistent with the image acquisition area of ​​the CCD industrial camera, and the CCD industrial camera is connected to a data acquisition terminal.

7. The method for detecting foreign fibers in defective cotton according to claim 6, characterized in that: The LED light source is divided into two groups, one group is an LED white light source, which is used when collecting dark foreign fibers; the other group is an LED ultraviolet light source with a wavelength of 365nm, which is used when collecting fluorescent foreign fibers; The LED light source is fixed on the image acquisition box at an angle of 45° in the horizontal direction.

8. A defective cotton foreign fiber detection system, characterized in that: The system comprises: The defective cotton image acquisition module is used to acquire the image of the defective cotton detection area irradiated by the LED light source by using a CCD industrial camera in the image acquisition system to obtain the defective cotton image; A data set processing module, used for forming sample data from the collected defective cotton images, performing data enhancement operation on the sample data to obtain an enhanced data set, and dividing the data enhanced data set into a test set, a validation set and a training set; An algorithm improvement module, used for selecting YOLOv8 as a baseline model and improving the baseline model to obtain a YOLOv8-MMW algorithm; The model training and foreign fiber identification module is used to input the training set into the YOLOv8-MMW algorithm for training to obtain a training model, and identify and classify the test set based on the training model to obtain the type and location of the foreign fiber.

9. A terminal, characterized in that: The terminal includes a memory, a processor, and a defective cotton foreign fiber detection program stored in the memory and executable on the processor. When the processor executes the defective cotton foreign fiber detection program, the steps of the defective cotton foreign fiber detection method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a defective cotton foreign fiber detection program, and when the defective cotton foreign fiber detection program is executed by the processor, the steps of the defective cotton foreign fiber detection method according to any one of claims 1 to 7 are implemented.