Improved YOLOv8 coal gangue detection method

By improving YOLOV8's OSM-YOLOV8N model, the problem of high complexity and insufficient feature extraction capabilities in coal tincture detection in coal gangue detection, and achieved lower complexity and higher detection performance.

CN119380193APending Publication Date: 2025-01-28HENAN UNIVERSITY OF TECHNOLOGY

Patent Information

Application Number
CN202411431071.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

In the dim and complex and changeable environment, the existing models are difficult to effectively extract coal gangue characteristics, and the model is too complex, resulting in real-time detection and limited resources.

Method used

It proposes to improve the coal gangue detection method of YOLOV8. By constructing the OSM-YOLov8n model, it will reduce the complexity of the model, reduce training costs, enhance the understanding of the model's understanding of the image, and improve the detection performance. Specific measures include replacing the C2F module as the C2F_OREPA module, add the Segnext_attention module, and use the MPDiou loss function.

Benefits of technology

It reduces the complexity of the model, reduces the training cost, enhances the understanding of the model's understanding and detection performance of the image, and solves the problem of insufficient environmental complexity and lack of characteristics extraction capacity in coal stones.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380193A_ABST
    Figure CN119380193A_ABST
Patent Text Reader

Abstract

The invention proposes an improved YOLOv8 coal gangue detection method, and the method comprises the steps: obtaining a coal gangue image, carrying out the preprocessing of the coal gangue image, and dividing the coal gangue image into a training set and a test set; the method comprises the steps that an OSM-YOLOv8n model is constructed, the OSM-YOLOv8n model comprises a backbone network, a neck network and a head network, the backbone network and the neck network construct a C2fORPA module through a block linearization and block extrusion method, a SegNextAttention module is constructed at the tail of the backbone network, and an MPDIOU loss function is designed in the head network; using the training set to train the constructed OSM-YOLOv8n model, using the test set to evaluate the performance of the trained model and adjust the parameter selection model, and finally obtaining the trained model; and acquiring a coal gangue image needing to be processed, and inputting the coal gangue image into the trained OSM-YOLOv8n model to obtain a classification detection result. The method reduces the complexity of the model, reduces the training cost, enhances the understanding of the model for the image, and improves the detection performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to a coal gangue detection method based on an improved YOLOv8. Background Art

[0002] With the rapid development of industrial technology, my country's energy production and consumption capacity has gradually increased. As one of my country's main energy sources, the mining and utilization efficiency of coal is of great significance to the country's economic development. In the process of coal mining, a large amount of coal gangue is often mixed in. As a common by-product, coal gangue not only affects the economic benefits of coal, but also the sulfides produced by it will cause serious pollution to the surrounding environment. Therefore, the sorting of coal gangue is of great significance to the improvement of economic benefits and environmental protection in the process of coal mining, and accurate detection of coal gangue is the basis for coal gangue sorting and also a key link.

[0003] At present, there are many methods for detecting gangue, such as manual sorting, X-ray method, wet selection method and image-based intelligent detection method. Manual sorting method is inefficient and consumes a lot of manpower. X-ray method requires special protective measures to avoid radiation, which increases equipment costs. Wet selection method will cause a lot of waste of resources. Traditional gangue detection methods are not practical and should not be promoted. Therefore, the use of intelligent gangue detection method has become a hot research direction in this field.

[0004] The invention patent with the publication number CN118334306A discloses a method for sorting coal gangue based on target detection, which includes: obtaining an image to be identified, wherein the image to be identified includes a target identification object, and the target identification object includes coal gangue; extracting a feature fusion map of the target identification object in the image to be identified; determining multiple candidate frames from the feature fusion map; determining a target candidate frame from the multiple candidate frames based on the overlapping area and center point distance of the candidate frames; wherein the target candidate frame is used to indicate the position of the target identification object in the image to be detected. This method can improve the recognition effect of the target identification object and reduce the misjudgment rate, but the original model has high complexity and the ability to extract surface features of coal gangue is reduced. Summary of the invention

[0005] Aiming at the technical problems that the existing model has great difficulty in extracting features of coal gangue in a dim and complex environment and a large amount of coal gangue is accumulated, and the model itself is too complex, the present invention proposes a coal gangue detection method by improving YOLOv8, and proposes an OSM-YOLOv8n (OREPA SegNext MPDIoU-YOLOv8n) model, which reduces the complexity of the model, reduces the training cost, enhances the model's understanding of the image, and improves the detection performance.

[0006] In order to achieve the above object, the technical solution of the present invention is achieved as follows:

[0007] A method for detecting coal gangue by improving YOLOv8 comprises the following steps:

[0008] S1: obtaining a coal gangue image, preprocessing the coal gangue image, and dividing the preprocessed coal gangue image into a training set and a test set;

[0009] S2: Construct an OSM-YOLOv8n model; the OSM-YOLOv8n model includes a backbone network, a neck network and a head network, the backbone network and the neck network both construct a C2f_OREPA module by block linearization and block extrusion, a SegNext_Attention module is constructed at the tail of the backbone network, and an MPDIoU loss function is designed in the head network;

[0010] S3: Use the training set to train the constructed OSM-YOLOv8n model, use the test set to evaluate the performance of the OSM-YOLOv8n model and adjust the parameters to select the model, and finally obtain the trained OSM-YOLOv8n model;

[0011] S4: Obtain the gangue image to be processed and input it into the trained OSM-YOLOv8n model to obtain the classification detection result.

[0012] The preprocessing method described in step S1 is: image preprocessing is performed by adding Gaussian noise, blurring, rotating and adjusting the brightness of the acquired coal gangue image.

[0013] Step S2: The backbone network includes a first Conv module, a second Conv module, a first C2f_OREPA module, a third Conv module, a second C2f_OREPA module, a fourth Conv module, a third C2f_OREPA module, a fifth Conv module, a fourth C2f_OREPA module, an SPPF module, and a SegNext_Attention module connected in sequence;

[0014] The neck network includes a first Upsample module, a first concat module, a second Upsample module, a fifth C2f_OREPA module, a second concat module and a sixth C2f_OREPA module connected in sequence; the first Upsample module is connected to the SegNext_Attention module, the first concat module is connected to the third C2f_OREPA module, and the second concat module is connected to the second C2f_OREPA module; and also includes a sixth Conv module, a third concat module, a seventh C2f_OREPA module, a seventh Conv module, a fourth concat module and an eighth C2f_OREPA module connected in sequence; the sixth Conv module is connected to the sixth C2f_OREPA module, and the fourth concat module is connected to the SegNext_Attention module;

[0015] The head network includes a first Detect module, a second Detect module and a third Detect module; the first Detect module is connected to the sixth C2f_OREPA module, the second Detect module is connected to the seventh C2f_OREPA module, and the third Detect module is connected to the eighth C2f_OREPA module.

[0016] The SPPF module includes a Conv module a, a first MaxPool2d module, a second MaxPool2d module, a third MaxPool2d module, a concat module a and a Conv module b connected in sequence, and the inputs of the first MaxPool2d module, the second MaxPool2d module and the third MaxPool2d module are all connected to the concat module a;

[0017] The Conv module includes a Conv2d layer, a BatchNorm2d layer and a SiLU layer connected in sequence.

[0018] The block linearization method described in step S2 is: remove the nonlinear layer in all branches in the original module, then introduce a linear scaling layer to replace the original nonlinear layer, obtain the branch after block linearization replacement, and finally add a BN layer after feature fusion of all branches after block linearization replacement.

[0019] The block squeezing method described in step S2 is: simplify the sequential structure in each branch after the linearization substitution of the block, considering multiple convolutional layers, the formula is as follows: Y = W N (...(W j ...(W2(W1*X))))=W e *X Among them, represents the input tensor, represents the output tensor, represents the weight of the jth layer, C i represents the input channel, C0 represents the output channel, W e represents the end-to-end mapping matrix;

[0020] Simplify the parallel structure between branches after multiple block linearization substitutions by:

[0021]

[0022] Among them, W m represents the mth branch, represents uniform weight.

[0023] The original module is the Bottleneck module in the C2f module.

[0024] The calculation process of the SegNext_Attention module is as follows: the input feature map first aggregates local information through deep convolution, and then captures the overall feature maps of different scales through multi-branch deep strip convolution. The multi-branch deep strip convolution output feature map is jump-connected with the local information aggregated by the deep convolution. Finally, 1*1 convolution is used to model different channels to obtain the attention map. The attention map is used as the input feature of the SegNext_Attention module to re-weight the attention weight. The formula is:

[0025]

[0026] Among them, F represents input features, Att represents attention map, Out represents output, and DW-Conv represents deep convolution. Represents element-by-element matrix multiplication operation, Scale i represents the i-th branch of a multi-branch depthwise strip convolution, Scale0 represents a skip connection, and each branch has two depthwise stripe convolutions.

[0027] The training process in step S3 is as follows: inputting the training set into the constructed OSM-YOLOv8n model, using the backbone network to extract features of the input coal gangue image, using the neck network to enhance and fuse the features extracted by the backbone network, and using the head network to output the prediction box according to the features enhanced and fused by the neck network; using the MPDIoU loss function to calculate the loss according to the predicted box and the real box in the data set, using the stochastic gradient descent algorithm to update the model parameters, using the test set to evaluate the performance of the OSM-YOLOv8n model after each round of training and adjust the parameter selection model until the predetermined training rounds or model convergence are reached, and the final trained OSM-YOLOv8n model is obtained;

[0028] The performance evaluation uses precision, recall, and average precision to verify the performance of the improved model, uses the number of frames transmitted per second to verify the detection speed of the improved model, and uses the floating-point operation amount to verify the complexity of the model calculation.

[0029] The MPDIoU loss function in step S2 is:

[0030]

[0031] in, Indicates the coordinates of the upper left corner of the prediction box, Indicates the coordinates of the lower right corner of the prediction box, Indicates the coordinates of the upper left corner of the real box, represents the coordinates of the lower right corner of the true box, d1 represents the straight-line distance between the predicted box and the upper left corner of the true box, d2 represents the straight-line distance between the predicted box and the lower right corner of the true box, IoU represents the ratio of the intersection and union of the true box and the predicted box, and h and w represent the height and width of the gangue image.

[0032] The beneficial effects of the present invention are:

[0033] In order to solve the problem that the model is too complex to be used in real-time detection or when resources and equipment are limited during coal gangue detection, the C2f module is replaced by the C2f_OREPA module, and the convolution module is re-parameterized to reduce the complexity of the model and the training cost.

[0034] In view of the complex and changeable environment in mines and the reduced ability to extract surface features of coal gangue, the SegNext_Attention module is added to enhance the model's understanding of images and improve detection performance.

[0035] In order to solve the problem that the CIoU loss function cannot accurately express the relationship between the predicted box and the real box due to the large accumulation of coal gangue, the CIoU loss function is replaced by the MPDIoU loss function to enhance the model's ability to recognize and locate coal gangue, simplify the model's calculation process, obtain faster convergence speed and more accurate results, and improve the model detection performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 This is a flow chart of coal gangue detection of an improved YOLOv8 proposed by the present invention.

[0038] Figure 2 This is the improved OSM-YOLOv8n network model structure diagram in the present invention.

[0039] Figure 3 It is a block linearization structure transformation diagram of the C2f_OREPA convolution module in the present invention.

[0040] Figure 4 It is a block extrusion structure transformation diagram of the C2f_OREPA convolution module in the present invention.

[0041] Figure 5 It is a diagram of the improvement process of the C2f_OREPA convolution module in the present invention.

[0042] Figure 6 It is a structural diagram of the MSCA module in the present invention.

[0043] Figure 7 It is the CIoU loss function diagram before improvement in the present invention.

[0044] Figure 8 It is the improved MPDIoU loss function diagram in the present invention.

[0045] Fig. 9 It is the mAP curve diagram of the C2f_OREPA module in different network positions in the present invention.

[0046] Fig.10 It is the mAP curve diagram of different attention mechanisms in the present invention.

[0047] Fig.11 It is the mAP curve diagram of the ablation experiment in the present invention.

[0048] Fig.12 It is a comparison diagram of the visualization detection results of coal gangue in the present invention. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] An improved YOLOv8 coal gangue detection method, such as Figure 1 As shown, the steps include:

[0051] S1: Acquire coal gangue images, preprocess the coal gangue images, and divide the preprocessed coal gangue images into a training set and a test set.

[0052] By simulating the real situation, the gangue was placed on the conveyor belt for shooting, and the real working scene in the mine was simulated. The acquired gangue images were preprocessed by adding Gaussian noise, blurring, rotation and brightness adjustment. A total of 2688 gangue images were obtained. The preprocessing can increase the diversity of images and improve the generalization and robustness of the model.

[0053] After acquiring the images, they were divided into two categories: coal and gangue. The images were annotated using annotation software, and the data set was divided into training set and test set in a ratio of 8 to 2.

[0054] S2: Construct an OSM-YOLOv8n model; the OSM-YOLOv8n model includes a backbone network, a neck network and a head network, the backbone network and the neck network both construct a C2f_OREPA module by block linearization and block extrusion, a SegNext_Attention module is constructed at the end of the backbone network, and an MPDIoU loss function is designed in the head network; Figure 2 As shown in the figure, the YOLOv8n model used is the model designed by YOLOv8 for target detection tasks.

[0055] The backbone network includes a first Conv module, a second Conv module, a first C2f_OREPA module, a third Conv module, a second C2f_OREPA module, a fourth Conv module, a third C2f_OREPA module, a fifth Conv module, a fourth C2f_OREPA module, an SPPF module and a SegNext_Attention module connected in sequence;

[0056] The neck network includes a first Upsample module, a first concat module, a second Upsample module, a fifth C2f_OREPA module, a second concat module and a sixth C2f_OREPA module connected in sequence;

[0057] The first Upsample module is connected to the SegNext_Attention module, the first concat module is connected to the third C2f_OREPA module, and the second concat module is connected to the second C2f_OREPA module;

[0058] Also includes a sixth Conv module, a third concat module, a seventh C2f_OREPA module, a seventh Conv module, a fourth concat module and an eighth C2f_OREPA module connected in sequence;

[0059] The sixth Conv module is connected to the sixth C2f_OREPA module, and the fourth concat module is connected to the SegNext_Attention module;

[0060] The head network includes a first Detect module, a second Detect module and a third Detect module; the first Detect module is connected to the sixth C2f_OREPA module, the second Detect module is connected to the seventh C2f_OREPA module, and the third Detect module is connected to the eighth C2f_OREPA module;

[0061] The SPPF module includes a Conv module a, a first MaxPool2d module, a second MaxPool2d module, a third MaxPool2d module, a concat module a and a Conv module b connected in sequence, and the inputs of the first MaxPool2d module, the second MaxPool2d module and the third MaxPool2d module are all connected to the concat module a;

[0062] The Conv module includes a Conv2d layer, a BatchNorm2d layer, and a SiLU layer connected in sequence;

[0063] The OREPA module is a reparameterized convolution module that reduces the cost and complexity of model training by reparameterizing the convolution online. This method mainly consists of two stages: block linearization and block squeezing. Block linearization optimizes the performance of online blocks through a special linear scaling layer.

[0064] Block Linearization Method:

[0065] like Figure 3 As shown in the figure. In this stage, all nonlinear layers in the original module are removed, and then a linear scaling layer is introduced to obtain branches replaced by block linearization. Finally, after all branches replaced by block linearization are feature fused, a BN layer is added. Through the block linearization stage, the OREPA module can effectively simplify the complexity of the model during the training stage, greatly optimize the training efficiency, and provide a way to build a high-performance module.

[0066] Block extrusion method:

[0067] Block squeezing reduces the training cost by compressing complex training modules into a single convolution. During training, it can not only effectively reduce the memory cost during training, but also increase the training speed. The process is as follows: Figure 4 shown.

[0068] During the block squeezing process, a size K can be defined H ×K WThe two-dimensional convolution process is as follows:

[0069] Y=W*X

[0070] Y=W*X

[0071] Simplifying the sequential structure in the branch after each block linearization replacement and considering multiple convolutional layers, it is shown as follows:

[0072] Y=W N (...(W j ...(W2(W1*X))))

[0073] in, represents the input tensor, represents the output tensor, represents the weight of the jth layer, C i represents the input channel, and C0 represents the output channel.

[0074] According to the associative law, the convolution kernel can be compressed into one layer by the following formula:

[0075] Y=W N (...(W j ...(W2(W1*X))))=W e *X

[0076] Among them, W e Represents the end-to-end mapping matrix.

[0077] The parallel structure is simplified between the branches after multiple block linearization substitutions. According to the linearity of convolution, multiple branches can be combined into one by the following formula:

[0078]

[0079] Among them, W m represents the mth branch, represents uniform weight.

[0080] The replacement process of this embodiment is as follows: Figure 5As shown, in this embodiment, at the stage of block linearization, the nonlinear layer BN layer in the Bottleneck module of C2f is first deleted, and then the linear scaling layer Scaling layer is introduced to replace the original BN layer, and a BN layer is added after the feature fusion. At the stage of block extrusion, the above structure is compressed into a single convolution, namely the OREPA convolution module. The optimized Bottleneck module (i.e., the Bottleneck-OREPA convolution module) is replaced with the original Bottleneck module in the C2f module. After this series of operations, the required C2f_OREPA module is obtained. This series of operations re-parameterizes the original complex structure, not only maintaining the original performance, but also greatly reducing the complexity of the model and reducing the training cost.

[0081] Adding the SegNext_Attention module at the end of the model backbone network can adaptively perform weighted fusion on feature maps of different scales to enhance the model's understanding of the image. The structure is as follows: Figure 6 shown.

[0082] The SegNext_Attention module consists of three parts: deep convolution for aggregating local information, multi-branch deep strip convolution for capturing multi-scale context, and 1*1 convolution for modeling different channel relationships. The input features are first subjected to deep convolution to aggregate local information and process some small targets that are difficult to capture. Then, multi-branch deep strip convolution captures the overall feature maps of different scales to help the model learn features of different scales. The output features of multi-branch deep strip convolution are jump-connected with the local information aggregated by deep convolution. Finally, 1*1 convolution is used to model different channels, and its output is directly used as attention weight to reweight the input of the SegNext_Attention module:

[0083] The calculation formula of the SegNext_Attention module is:

[0084]

[0085] Among them, F represents input features, Att represents attention map, Out represents output, and DW-Conv represents deep convolution. Represents element-by-element matrix multiplication operation, Scale i Denotes the i-th branch of the multi-branch deep strip convolution, i∈{0,1,2,3}, Scale0 indicates a skip connection, and each branch has two deep strip convolutions. The advantage of using deep strip convolution is that it is a lightweight convolution, and only 1*7 and 7*1 are needed to simulate a 7*7 2D standard convolution, and strip convolution can effectively increase the model's ability to recognize coal gangue of different shapes.

[0086] The head network is responsible for further processing the features output by the neck network to generate the final prediction box for comparison with the real box in the data set, so as to adjust the model parameters. The main function of the head network is to convert the feature map obtained by the neck network into the specific information required for target detection, including category, position and confidence. The three types of Detect are used to detect objects of different sizes, and the internal parts are composed of convolutional layers and activation functions, prediction layers and non-maximum suppression. The convolutional layer is used to further process the feature map output by the neck network to obtain more features, and the activation function is used to introduce nonlinearity to improve the feature expression ability. The prediction layer is responsible for generating the final result, including three main outputs: bounding box regression (predicting the position and size of the target), confidence score (predicting whether each bounding box contains the target and the confidence of the target) and category probability (predicting the probability of each category of the target). Non-maximum suppression is used to process the final detection results to remove duplicate detection boxes, retain the bounding box with the highest confidence (final prediction box), and remove other bounding boxes with the highest overlap with it to ensure that each target is detected only once.

[0087] In deep learning object detection tasks, the loss function measures the difference between the predicted box and the true box, and optimizes the parameters through the algorithm. IoU (Intersection over Union) represents the overlap between the predicted box and the true box, which is an important indicator for measuring object detection tasks. YOLOv8n uses the CIoU loss function, such as Figure 7 As shown in the figure, the CIoU loss function takes into account the shape information and diagonal distance of the target box (i.e., the predicted box), and also comprehensively considers multiple factors such as position, shape, and direction. This makes it easier for the model to capture the accurate shape of the target and improve the accuracy of locating the target. However, when the model is trained, if the center point of the predicted box overlaps with the center point of the real box, and the aspect ratio of the predicted box and the real box is the same, the CIoU loss function cannot accurately express the actual relationship between the predicted box and the real box.

[0088] The mathematical formula of CIoU loss function is as follows:

[0089]

[0090] Among them, w g Indicates the width of the real box, h g Indicates the height of the real box, w p Indicates the width of the prediction box, h p represents the height of the prediction box, π represents the circumference, IoU represents the ratio of the intersection and union of the real box and the prediction box, v represents the correction factor, which is used to further adjust the loss function, and c g represents the center point of the real box, cp Represents the center point of the predicted box, c represents the straight-line distance between the real box and the center point of the predicted box, d represents the diagonal distance of the minimum circumscribed rectangle, and α represents the weight coefficient.

[0091] It can be seen from the above formula that when w g =w p ,h g =h p When v = 0, the loss function cannot be optimized. In complex environments, especially in actual coal mine production, coal gangue is piled up in large quantities and is prone to mutual occlusion, which will cause this situation to occur frequently, resulting in reduced target detection performance.

[0092] In order to solve this problem, the MPDIoU bounding box regression loss function is used to replace the original CIoU loss function, such as Figure 8 As shown in Figure 2. MPDIoU includes relevant factors considered by most loss functions, such as mutual occlusion, center point position, and height and width deviations, while also simplifying the calculation process. Using the MPDIoU loss function as a new metric to compare the similarity between the predicted box and the true box in the bounding box regression process can solve the shortcomings of the CIoU loss function, obtain faster convergence speed and more accurate results, and improve the performance of model detection.

[0093] The mathematical formula of the MPDIoU loss function is as follows:

[0094]

[0095] in, Indicates the coordinates of the upper left corner of the prediction box, Indicates the coordinates of the lower right corner of the prediction box, Indicates the coordinates of the upper left corner of the real box, represents the coordinates of the lower right corner of the true box, d1 represents the straight-line distance between the predicted box and the upper left corner of the true box, d2 represents the straight-line distance between the predicted box and the lower right corner of the true box, IoU represents the ratio of the intersection and union of the true box and the predicted box, and h and w represent the height and width of the entire image of coal gangue.

[0096] S3: Use the training set to train the constructed OSM-YOLOv8n model, use the test set to evaluate the performance of the OSM-YOLOv8n model and adjust the parameters to select the model, and finally obtain the trained OSM-YOLOv8n model.

[0097] The training process is as follows: inputting the training set into the constructed OSM-YOLOv8n model, using the backbone network to extract features of the input gangue image, using the neck network to enhance and fuse the features extracted by the backbone network, and using the head network to output the prediction frame according to the features enhanced and fused by the neck network; using the MPDIoU loss function to calculate the loss according to the predicted frame and the real frame in the data set, using the stochastic gradient descent algorithm to update the model parameters, using the test set to evaluate the performance of the OSM-YOLOv8n model after each round of training and adjust the parameter selection model until a predetermined training round is reached or the model converges, thereby obtaining a finally trained OSM-YOLOv8n model.

[0098] The experimental operating system used in the present invention is Windows 10, the experimental platform CPU is 13th Gen Intel (R) Core (TM) i5-13600KF, the GPU is NVIDIA GeForce RTX 4060, the internal size is 16G, the programming language is Python 3.8.19, the CUDA version is 11.8, and the PyTorch version is 2.2.1. The model sets the input size of the gangue image to 640*640, the training batch is 250 times, the batch size is 32, the optimizer uses the stochastic gradient descent method, and the initial learning rate is 0.01.

[0099] The present invention uses precision P (Precision), recall R (Recall), mean average precision (mAP), floating point operations (FLOPs) and frames per second (FPS) as evaluation indicators for verifying model improvement. P, R, and mAP are used to verify the performance of model improvement, FPS is used to verify the detection speed of model improvement, and FLOPs is used to verify the complexity of model calculation. The calculation formulas of P, R and mAP are as follows:

[0100]

[0101] Among them, TP (True Positive) indicates the number of positive samples correctly classified as positive, FP (False Positive) indicates the number of negative samples incorrectly classified as positive, FN (False Negative) indicates the number of positive samples incorrectly classified as negative, AP indicates the average precision, and N indicates the number of detection categories, which is set to 2 in this paper.

[0102] S4: Obtain the gangue image to be processed and input it into the trained OSM-YOLOv8n model to obtain the classification detection result.

[0103] Comparison model. Based on the coal gangue detection model based on the improved YOLOv8n algorithm obtained after training, the effectiveness of the network model is comprehensively compared from multiple aspects such as the model's precision, recall rate, average precision mean, and model complexity.

[0104] In the process of replacing the C2f_OREPA convolutional module, the C2f module is replaced in three different ways: the model backbone network, the neck network, and the backbone network and the neck network. The experimental results are shown in Table 1.

[0105] Table 1 The impact of C2f_OREPA module on the model in different network positions

[0106]

[0107] The experimental results clearly show that replacing the convolution in the Backbone+Neck network can achieve the best results, with FLOPs reduced by 29.2% and mAP increased by 0.4%, which is better than replacing the convolution in the Neck network in terms of target feature extraction. After optimization, the complexity of the YOLOv8n model is not only greatly reduced, but also the feature extraction capability of the target is improved. Therefore, this paper replaces the C2f convolution with the C2f_OREPA convolution module in the Backbone+Neck network. The mAP curves of C2f_OREPA added to different positions are shown in the figure below. Fig. 9 shown.

[0108] In order to verify the impact of different attention mechanisms on the model, four different attention mechanisms are introduced on the basis of replacing C2f convolution with C2f_OREPA convolution, namely SimAM, TripletAttention, CPCA and SegNext_Attention. The experimental results are shown in Table 2.

[0109] Table 2 Comparative experiments of different attention mechanisms

[0110]

[0111] By introducing the attention mechanism, the overall detection performance of the model has been improved, and it also has a certain impact on the detection speed. After the CPCA attention mechanism module was introduced, the detection speed decreased by 4.8%, and the mAP only increased by 0.2%. After the SimAM attention mechanism module was introduced, the detection speed was slightly improved, but the mAP only increased by 0.1%. The SegNext_Attention module used in this model did not significantly reduce the detection speed, but the mAP increased by 0.5%. Compared with the TripletAttention module, it has a stronger feature extraction capability for the target and better overall performance. The mAP curves of the four different attention mechanisms and the O-YOLOv8n model are shown below. Fig.10 shown.

[0112] In order to verify the improved performance of the YOLOv8n model, the present invention designs an ablation experiment to observe the experimental results more intuitively. The parameter settings of each group of experiments are the same, and only the module structure is improved. Models A, B, and C respectively introduce the C2f_OREPA convolution module, SegNext_Attention module, and MPDIoU loss function on the original YOLOv8n model. Models D and E respectively introduce the SegNext_Attention module and MPDIoU loss function on the basis of model A, and model F introduces the MPDIoU loss function on the basis of model B. The ablation experiment results are shown in Table 3.

[0113] Table 3 Ablation experiments of different modules of YOLOv8n model improvement

[0114]

[0115]

[0116] The improvements of the three modules have verified the effectiveness of improving model performance. The combination of the three can effectively improve the model detection accuracy and reduce the complexity of the model. The mAP of the OSM-YOLOv8n model can reach 95.1%, and FLOPs decreases by 29.2%. The mAP curve of the ablation experiment is shown in the figure below. Fig.11 In order to intuitively reflect the effect of the improved model, the OSM-YOLOv8n and YOLOv8n models were used to perform visual detection on coal gangue. The results are shown in Fig.12 The experimental results show that the OSM-YOLOv8n model has a significant improvement over the original model. It can still accurately identify gangue in the case of gangue accumulation, while also avoiding overlap, false detection, and missed detection. As an algorithm related to gangue detection, it can more efficiently complete the related work of gangue sorting in industrial production and reduce industrial production costs.

[0117] In order to more intuitively observe the recognition accuracy of the improved YOLOv8n model for coal gangue, this paper compares the OSM-YOLOv8n model with SSD, Faster-RCNN, and YOLOv5n, YOLOv5s, YOLOv7-tiny, YOLOv7, and YOLOv8n models in the YOLO series without changing the dataset and parameter settings used in training. The P, R, mAP, and FLOPs of different models are shown in Table 4.

[0118] Table 4 Comparative experiments of different models

[0119]

[0120] By comparing different models, it can be seen that OSM-YOLOv8n has the best overall performance. P, R and mAP are the highest among different models, which are 88%, 90.2% and 95.1% respectively. At the same time, FLOPs is only higher than Faster-RCNN and YOLOv5n models, but the mAP values ​​of Faster-RCNN and YOLOv5n are only 90.6% and 92.5%, respectively. OSM-YOLOv8n has higher detection accuracy, which shows that this model not only has the best detection accuracy under low complexity. Compared with the current mainstream target detection models, this model has better detection accuracy and low model complexity, and can be used in hardware facilities with limited resources.

[0121] The experimental results show that the mAP of the OSM-YOLOv8n algorithm model can reach 95.1%, while the model complexity is greatly reduced, and the FLOPs reduction can reach 29.2%. Compared with other models, this model has the best comprehensive performance, indicating that the lightweight and detection accuracy of the OSM-YOLOv8n algorithm model meet the requirements of the detection task, which can provide certain help for the subsequent research of coal gangue sorting and related contents in actual production.

[0122] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A coal gangue detection method based on improved YOLOv8, characterized in that: The following steps are involved: S1: obtaining a coal gangue image, preprocessing the coal gangue image, and dividing the preprocessed coal gangue image into a training set and a test set; S2: Construct an OSM-YOLOv8n model; the OSM-YOLOv8n model includes a backbone network, a neck network and a head network, the backbone network and the neck network both construct a C2f_OREPA module by block linearization and block extrusion, a SegNext_Attention module is constructed at the tail of the backbone network, and an MPDIoU loss function is designed in the head network; S3: Use the training set to train the constructed OSM-YOLOv8n model, use the test set to evaluate the performance of the OSM-YOLOv8n model and adjust the parameters to select the model, and finally obtain the trained OSM-YOLOv8n model; S4: Obtain the gangue image to be processed and input it into the trained OSM-YOLOv8n model to obtain the classification detection result.

2. The improved YOLOv8 coal gangue detection method according to claim 1, characterized in that: The preprocessing method described in step S1 is: image preprocessing is performed by adding Gaussian noise, blurring, rotating and adjusting the brightness of the acquired coal gangue image.

3. The improved YOLOv8 coal gangue detection method according to claim 2, characterized in that: Step S2: The backbone network includes a first Conv module, a second Conv module, a first C2f_OREPA module, a third Conv module, a second C2f_OREPA module, a fourth Conv module, a third C2f_OREPA module, a fifth Conv module, a fourth C2f_OREPA module, an SPPF module, and a SegNext_Attention module connected in sequence; The neck network includes a first Upsample module, a first concat module, a second Upsample module, a fifth C2f_OREPA module, a second concat module and a sixth C2f_OREPA module connected in sequence; the first Upsample module is connected to the SegNext_Attention module, the first concat module is connected to the third C2f_OREPA module, and the second concat module is connected to the second C2f_OREPA module; and also includes a sixth Conv module, a third concat module, a seventh C2f_OREPA module, a seventh Conv module, a fourth concat module and an eighth C2f_OREPA module connected in sequence; the sixth Conv module is connected to the sixth C2f_OREPA module, and the fourth concat module is connected to the SegNext_Attention module; The head network includes a first Detect module, a second Detect module and a third Detect module; the first Detect module is connected to the sixth C2f_OREPA module, the second Detect module is connected to the seventh C2f_OREPA module, and the third Detect module is connected to the eighth C2f_OREPA module.

4. The improved YOLOv8 coal gangue detection method according to claim 3, characterized in that: The SPPF module includes a Conv module a, a first MaxPool2d module, a second MaxPool2d module, a third MaxPool2d module, a concat module a and a Conv module b connected in sequence, and the inputs of the first MaxPool2d module, the second MaxPool2d module and the third MaxPool2d module are all connected to the concat module a; The Conv module includes a Conv2d layer, a BatchNorm2d layer and a SiLU layer connected in sequence.

5. The improved YOLOv8 coal gangue detection method according to any one of claims 1 to 4, characterized in that: The block linearization method described in step S2 is: remove the nonlinear layer in all branches in the original module, then introduce a linear scaling layer to replace the original nonlinear layer, obtain the branch after block linearization replacement, and finally add a BN layer after feature fusion of all branches after block linearization replacement.

6. The improved YOLOv8 coal gangue detection method according to claim 5, characterized in that: The block squeezing method described in step S2 is: simplify the sequential structure in each branch after the linearization substitution of the block, considering multiple convolutional layers, the formula is as follows: Y = W N (...(W j ...(W2(W1*X))))=W e *X Among them, represents the input tensor, represents the output tensor, represents the weight of the jth layer, C i represents the input channel, C0 represents the output channel, W e represents the end-to-end mapping matrix; Simplify the parallel structure between branches after multiple block linearization substitutions by: Among them, W m represents the mth branch, represents uniform weight.

7. The improved YOLOv8 coal gangue detection method according to claim 5, characterized in that: The original module is the Bottleneck module in the C2f module.

8. The improved YOLOv8 coal gangue detection method according to claim 3, characterized in that: The calculation process of the SegNext_Attention module is as follows: the input feature map first aggregates local information through deep convolution, and then captures the overall feature maps of different scales through multi-branch deep strip convolution. The multi-branch deep strip convolution output feature map is jump-connected with the local information aggregated by the deep convolution. Finally, 1*1 convolution is used to model different channels to obtain the attention map. The attention map is used as the input feature of the SegNext_Attention module to re-weight the attention weight. The formula is: Among them, F represents input features, Att represents attention map, Out represents output, and DW-Conv represents deep convolution. Represents element-by-element matrix multiplication operation, Scale i represents the i-th branch of a multi-branch depthwise strip convolution, Scale0 represents a skip connection, and each branch has two depthwise stripe convolutions.

9. The improved YOLOv8 coal gangue detection method according to claim 8, characterized in that: The training process in step S3 is as follows: inputting the training set into the constructed OSM-YOLOv8n model, using the backbone network to extract features of the input coal gangue image, using the neck network to enhance and fuse the features extracted by the backbone network, and using the head network to output a prediction frame according to the features enhanced and fused by the neck network; The MPDIoU loss function is used to calculate the loss according to the predicted box and the real box in the data set, and the model parameters are updated by the stochastic gradient descent algorithm. The performance of the OSM-YOLOv8n model after each round of training is evaluated using the test set and the parameter selection model is adjusted until the predetermined training rounds are reached or the model converges, thereby obtaining the final trained OSM-YOLOv8n model. The performance evaluation uses precision, recall, and average precision to verify the performance of the improved model, uses the number of frames transmitted per second to verify the detection speed of the improved model, and uses the floating-point operation amount to verify the complexity of the model calculation.

10. The improved YOLOv8 coal gangue detection method according to claim 9, characterized in that: The MPDIoU loss function in step S2 is: in, Indicates the coordinates of the upper left corner of the prediction box, Indicates the coordinates of the lower right corner of the prediction box, Indicates the coordinates of the upper left corner of the real box, represents the coordinates of the lower right corner of the true box, d1 represents the straight-line distance between the predicted box and the upper left corner of the true box, d2 represents the straight-line distance between the predicted box and the lower right corner of the true box, IoU represents the ratio of the intersection and union of the true box and the predicted box, and h and w represent the height and width of the gangue image.

Citation Information

Patent Citations

  • Coal gangue sorting method based on target detection

    CN118334306A

Cited By

  • Intelligent behavior detection method for miner safety

    CN120564273A

  • Dual-energy X-ray ore detection method based on dual-trunk YOLOv11

    CN120852963A

  • Dual-energy X-ray mineral detection method based on dual-backbone YOLOv11

    CN120852963B

  • Feature extraction method, device and equipment for segment to be spliced, medium and product

    CN122049406A

  • A pipe splicing feature extraction method, device, equipment, medium and product

    CN122049406B