Research on Coal Gangue Image Recognition Method Based on EMAM-YOLO Authors: Ying Jia, Baoshan Li, Yongxing Du, Wenxiang Zheng, Yu Li, Shiyan Wu Published: 2026 ABSTRACT Aiming at the problems of low target detection accuracy and poor robustness caused by factors such as uneven illumination, coal dust interference, and diverse coal-gangue morphologies in the complex environment of underground coal mines, a real-time coal-gangue image detection model based on EMAM-YOLO is proposed. This model uses YOLOv12n as the baseline framework and integrates multidimensional optimization modules to enhance comprehensive performance. First, the lightweight EfficientNetV1 network is adopted to reconstruct the backbone feature extraction structure, effectively reducing the number of model parameters while ensuring high-precision feature representation. Second, a Multiscale Attention Feature Pyramid Network (MAFPN) is introduced to strengthen the cross-scale interaction between shallow detail information and deep semantic information, improving the detection capability for coal-gangue targets of various sizes. Then, an Adaptive Spatial Feature Fusion detection head (Detect_ASFF) is designed to optimize the multiscale feature fusion strategy by learning dynamic weights, enhancing the model’s localization accuracy for occluded and deformed targets. Finally, a multiscale channel attention (MCA) mechanism is incorporated to guide the network to focus on key feature channels and suppress redundant information, further improving feature discrimination capability. The primary technical contribution of this work is 2-fold: (1) a novel adaptive spatial feature fusion detection head (Detect_ASFF) that learns dynamic spatial weights, representing a structural innovation within the head; (2) the specific combination and synergistic interaction of EfficientNetV1, MAFPN, Detect_ASFF, and MCA, each addressing a distinct drawback of YOLOv12n for coal-gangue detection. Experimental results on a self-built coal-gangue data set show that the EMAM-YOLO model achieves a mean average precision (mAP50–95) of 81.17%, which is 5.04 percentage points higher than the baseline YOLOv12n, with only 2.59 M parameters and a detection speed of 69.89 FPS, achieving a good balance between detection accuracy and real-time performance. Compared with mainstream algorithms such as Faster R–CNN, SSD, YOLOv8n, and YOLOv10n, the proposed model exhibits stronger robustness and better detection performance under simulated complex working conditions, and can provide effective technical support for intelligent coal washing in mines. Introduction The coal gangue generated during coal mining is the main solid pollutant. If mixed with raw coal, it will not only reduce the quality of coal combustion, but also increase the pollution emissions during subsequent utilization. Therefore, achieving accurate identification of coal gangue is of great significance for the coal washing and processing process. − The traditional methods for identifying coal gangue mainly include density sorting, radiographic testing, and manual picking. − Although they have a certain degree of accuracy, they generally have problems such as low efficiency, high cost, complex operation, and limited adaptability. In recent years, image recognition technology based on deep learning has been widely applied in the field of coal gangue target detection. Li Na et al. proposed a lightweight coal gangue recognition method based on FNF-YOLO. Through feature fusion optimization, lightweight detection head, and improved loss function, the mAP was increased by 3.5% while reducing 50% of parameters and 45.7% of computation, achieving more efficient and accurate detection performance. Li Deyong et al. proposed a real-time coal gangue detection model BRS-YOLOv10n for complex underground environments in coal mines. By integrating BiFormer visual converter, RepLKNet super large convolution kernel, SKNet dynamic attention mechanism, and InnerCIoU loss function, the model achieves an average accuracy of 92.3% and a detection speed of 62.6 FPS, significantly better than existing mainstream methods, while improving feature extraction and convergence efficiency. Kingdom Law et al. proposed an intelligent recognition model for coal gangue based on CFS-YOLO. By introducing ConvNeXt V2 feature extraction module, Focal EIOU loss function, and SimAM attention mechanism, the model achieved an average detection accuracy of 90.2% and real-time detection performance of 90.09 FPS in complex coal mine environments, significantly improving the robustness and efficiency of coal gangue recognition. Zhang Lei et al. constructed the YOLOv5s SDE model, which introduced SE module, depthwise separable convolution, and EIoU loss function. By reducing 22.2% of parameters and 24.1% of computation, the model achieved an average accuracy of 92.5% and a detection speed of 59.9 FPS, effectively improving the real-time detection performance of belt conveyor coal gangue under complex working conditions. Ge Qingnan et al. proposed a coal gangue recognition method based on the KRB-YOLOv5s algorithm. Through K-means++anchor box optimization and the introduction of RepLKNet large kernel convolution and BiFPN feature fusion network, an average detection accuracy of 94.5% was achieved in complex coal mine environments, which was 3.3 percentage points higher than the benchmark model and effectively improved the robustness and accuracy of coal gangue sorting. Considering the changeable environment such as high concentration of coal dust, complex lighting conditions and various shapes of coal gangue in actual coal mine production, the existing coal gangue recognition methods are difficult to take into account the requirements of detection speed and accuracy. Therefore, based on YOLOv12, this article adopts a lightweight backbone network EfficientNetV1 to optimize the feature extraction structure, improve computational efficiency, and reduce parameter count; Introducing a multiscale attention feature pyramid network (MAFPN) to enhance the model’s multiscale feature fusion capability; Adopting an adaptive spatial feature fusion detection head (Detect_ASFF) to further optimize target localization and classification accuracy; And by incorporating multiscale channel attention (MCA) mechanism, the feature expression ability of the model under complex working conditions is enhanced. EMAM-YOLO Model Overall Architecture The EMAM-YOLO algorithm is a network optimized on the YOLOv12n model, and its main network structure is shown in Figure . The model mainly consists of four parts: input terminal, backbone network, neck network, and head. EMAM-YOLO network model structure. Despite its efficiency on general tasks, native YOLOv12n has four specific drawbacks for coal-gangue detection: (1) its backbone lacks lightweight depthwise separable convolutions and channel attention, leading to parameter redundancy and weak fine-grained feature extraction; (2) its FPN uses simple summation for multiscale fusion, failing to handle large scale variation and severe occlusion; (3) its detection head applies fixed spatial weight fusion, which cannot adaptively focus on deformed or occluded gangue targets; (4) its single-scale channel attention misses cross-scale dependencies, reducing feature selection robustness under complex lighting and dust. To address these issues, the core improvement work of this model includes: ①adopting a lightweight backbone network EfficientNetV1 to optimize the feature extraction structure, and through its efficient deep separable convolution and channel attention mechanism, significantly reducing the number of parameters while enhancing feature representation ability, improving computational efficiency and model generalization performance; ②introducing the Multi Scale Attention Feature Pyramid Network (MAFPN), through bidirectional cross scale connections and attention weighted fusion mechanism, enhances the semantic information interaction between features at different levels, effectively improving the model’s multiscale object detection capability in complex scenes; ③design an adaptive spatial feature fusion detection head (Detect_ASFF) that uses a dynamic weight learning strategy to adaptively adjust the spatial contribution of features at different scales, optimize target localization accuracy and classification confidence, and enhance the robustness of the model to occluded and deformed targets; ④integrating multiscale channel attention (MCA) mechanism, capturing cross scale channel dependencies through parallel multi branch channel modeling, adaptively focusing on key feature channels and suppressing redundant information, further enhancing feature selection and representation capabilities. Through the collaborative optimization of the above modules, the model achieves a better balance between computational efficiency, multiscale fusion accuracy, and feature discrimination ability. EfficientNet Backbone Network With the development of convolutional neural networks, the model size continues to expand, but hardware memory limitations require better efficiency while pursuing higher accuracy. Traditional convolutional neural networks such as AlexNet, GoogleNet, SENet, etc., although their accuracy continues to improve, have too many parameters and face hardware bottlenecks. Therefore, EfficientNet aims to study the model efficiency of convolutional neural networks that can surpass existing accuracy, achieved through model scaling. EfficientNet proposes a new composite scaling method that uses composite coefficients to uniformly scale the width, depth, and resolution of the network. The specific formula is 1 depth:d=αϕ 2 width:w=βϕ 3 resolution:r=γϕ Among them, α, β, and γ are constants determined through small grid search, and satisfy the conditions of α·β 2·γ 2 ≈ 2, α ≥ 1, β ≥ 1, and γ ≥ 1. This method is based on the observation that there is a correlation between network width, depth, and resolution. Balancing the scaling of these three dimensions is crucial for improving model performance, while traditional single dimensional scaling methods have limitations. MAFPN Neck Structure The PAFPN structure used in traditional YOLO series algorithms has limitations in multiscale feature fusion: first, it lacks multiscale fusion across resolution layers. PAFPN mainly integrates multiscale feature maps and ignores shallow and low spatial information (such as the importance of P3 layer for small targets), resulting in insufficient small target detection capability. Second, the small target detection path is single. Only processing small object detection layers through a one-way top-down path and two modules limits the model’s ability to learn subtle features. To address the aforementioned issues, MAFPN enhances shallow information preservation and cross layer feature interaction by introducing bidirectional connections and multi branch assisted fusion, thereby improving multiscale object detection performance. MAFPN, as the neck structure of YOLO detector, consists of two core paths: ① bottom up path: using SAF module to extract multiscale features (P2–P5) of the backbone network, perform preliminary auxiliary fusion in the shallow neck layer, and preserve shallow spatial information. ② Top down pathway: By establishing dense connections in the deep layers of the neck through the AAF module, features from different resolution layers (such as shallow high-resolution layers, low resolution layers, same level layers, and front layers) are aggregated to guide the detection head to output multiscale information. Both paths use the RepHELAN module for feature extraction and utilize dynamic size convolution kernels to achieve adaptive receptive fields.(1)Shallow assisted fusion (SAF) module (1)Shallow assisted fusion (SAF) module Shallow assisted fusion (SAF) module It is designed to preserve shallow spatial information on the backbone network and enhance small object detection capability. Structurally connect the shallow features (such as P3) and neck features of the backbone network in a bidirectional manner, and control the number of channels through 1 × 1 convolution to avoid information interference. The structure is shown in Figure . The formula for fusion is 4 Pn′=concat(δ(C(Down(Pn−1))),Pn,U(Pn+1′)) Architecture of superficial assisted fusion. Among them, P n–1 is the shallow feature, P n is the main feature, U (·) is the upsampling, C is the 1 × 1 convolution, and δ is the SiLU activation function. By fusing high-resolution shallow features and enhancing the network’s ability to capture small target edges and details, experiments have shown that SAF can improve small target detection performance (APs) by 1%.(2)Advanced assisted fusion (AAF) module (2)Advanced assisted fusion (AAF) module Advanced assisted fusion (AAF) module It is designed to achieve cross layer and multiscale information exchange in the deep neck layer, and improve the accuracy of medium and large object detection. Structurally, the shallow high-resolution layer (P′ n+1), low resolution layer (P′ n–1), same level layer (P′ n ), and previous layer (P″ n–1) are densely connected, and the number of channels in each layer is balanced through 1 × 1 convolution. The structure is shown in Figure . The formula for fusion is 5 Pn″=concat(δ(C(Down(Pn−1′))),δ(C(Down(Pn−1″)))Pn′,C(U(Pn+1′))) Architecture of advanced assisted fusion. By enriching the gradient information on the output layer through multidirectional connections, experiments have shown that AAF can improve the performance of medium targets (APm) and large targets (API) by about 1.1% and 1.9%, respectively. Detect_ASFF Detection Head In object detection, handling multiscale objects is a challenging problem. Although feature pyramids or multilevel feature pyramids are commonly used methods to solve multiscale problems, the inconsistency between features of different scales in single-stage detectors limits their performance improvement. To address this issue, the adaptive spatial feature fusion (ASFF) module has been proposed. The structure is shown in Figure . Structural schematic of Detect_ASFF. In YOLO, there are three feature layers with different resolutions and channel numbers. For a certain layer l, adjust the features x n of other layers n (n ≠ l) to have the same shape as x l. For upsampling, first apply a 1 × 1 convolutional layer to compress the number of channels, and then use interpolation to improve the resolution; For downsampling (such as 1/2 scale), use a 3 × 3 convolutional layer (with a step size of 2) to simultaneously modify the number of channels and resolution; for downsampling at a 1/4 ratio, add a 2-step max pooling layer before the 2-step convolution. Let the adjusted feature vector be xijn→l , and the fusion formula is 6 yijl=αijl·xij1→l+βijl·xij2→l+γijl·xij3→l Among them, α ij l , β ij l , and γ ij l are spatial importance weights for network adaptive learning, and α ij l +β ij l +γ ij l = 1, α ij l , β ij l , γ ij l ∈[0,1]. Calculate the weight scalar graphs λ α l , λ β l , and λ γ l from x 1→l, x 2→l, and x 3→l using a 1 × 1 convolutional layer, and learn them through standard backpropagation. MCA Attention Mechanism The core component of MCANet is Multi Scale Cross Axis Attention (MCA). The structure is shown in Figure . Structural schematic of MCA. For axial attention, it decomposes self-attention into two parts, each responsible for computing self-attention along the horizontal or vertical dimension. Based on this, Axial DeepLab can sequentially aggregate features along the horizontal and vertical directions, making it possible to capture global information. Axial attention is more efficient than self-attention, reducing computational complexity from O (HW × HW) to O (HW × (H + W)). However, in many image processing tasks, the data set is relatively small, and axial attention is difficult to achieve long–distance interaction, which is not conducive to capturing the spatial structure or shape required in the task. MCA is a multiscale cross axis attention algorithm, which is divided into two parallel branches to calculate horizontal and vertical axis attention. Each branch consists of three 1D convolutions with different kernel sizes, used to encode multiscale contextual information along one spatial dimension, and then aggregate features along another spatial dimension through cross axis attention. Taking the top branch as an example, given the feature map F (the combination of the last three stages of the encoder feature map), three parallel 1D convolutions are used to encode it. The output is fused by summing and fed into a 1 × 1 convolution, with the formula is 7 Fx=Conv1×1(∑i=02Conv1Dix(Norm(F))) Among them, Conv1D x i (·)­represents 1D convolution along the x-axis dimension, norm (·) is layer normalization, and F x is the output. For 1D convolution, set the kernel size to 1 × 7, 1 × 11, and 1 × 21. The output F y of the bottom branch can be obtained in a similar way. For the F x of the top branch, it is fed into the y-axis attention. To better utilize the multiscale convolution features from two spatial directions, the cross attention between F x and F y is calculated using F x as the key sum matrix and F y as the query matrix. The calculation process is F T = MHCA y (F y , F x , F x ), where MHCAy (·,·,·) represents the multi head cross attention along the x-axis. The bottom branch encodes the context along the y-axis in a similar way, i.e. F B = MHCA x (F x , F y , F y ), where MHCA x (·,·,·) represents multi head cross attention along the y-axis. The output of MCA is 8 Fout=Conv1×1(FT)+Conv1×1(FB)+F Data Collection and Processing Coal Gangue Image Acquisition Experimental Device The collection of coal gangue samples comes from an experimental device independently built in the laboratory, as shown in Figure . The device mainly consists of a belt conveyor, MV-CS050-20GC Gigabit Ethernet industrial area array camera, coal gangue samples, equipment rack, adjustable light source, corresponding light source controller, and computing mechanism. The acquisition system communicates between the camera and the computer through a USB interface, displays real-time acquisition images, and saves coal gangue images. Experimental device for coal gangue image acquisition. Data Collection and Processing The experimental data is sourced from a self-made coal gangue data set in the laboratory. The coal gangue samples were collected from a mine in Zhungeer Banner, Inner Mongolia. During the collection process, 500 images were obtained by changing the placement of coal and gangue, adjusting the light source, selecting different sizes and shapes of coal and gangue, and adjusting the quantity of coal and gangue. Some of the coal gangue samples are shown in Table . Image labels are annotated using LabelImg software, which includes two types of labels: “Coal” and “Gangue”. Coal represents coal, Gangue represents gangue, and is divided into training set, validation set, and testing set in a ratio of 6:2:2. 1Coal and Gangue Samples under Complex Conditions Coal and Gangue Samples under Complex Conditions Results and Discussion Network Environment and Training Parameter Configuration This experiment is based on the PyTorch deep learning framework, conducted on the Windows 10 operating system, and uses YOLOv12n as the benchmark network model. The experimental platform is equipped with NVIDIA GeForce RTX 4070 GPU (16 GB), programming language is Python 3.10, CUDA version 12.6. The computer hardware model is Intel (R) Core (TM) i7 14650HX with 32GB of memory. The specific training parameters are shown in Table . 2Experimental Parameter Settingsparametervaluestraining rounds100batch size4input image size640 × 640initial learning rate0.01momentum factor0.937optimizer typeSGDbounding box loss gain7.5 Experimental Parameter Settings Model Evaluation Indicators In order to systematically and quantitatively evaluate the comprehensive performance of the model, this article selects six key indicators from three core dimensions: detection accuracy, model complexity, and inference efficiency. In terms of detection accuracy, precision (P %) and recall (R %) are used to measure the accuracy of the model’s prediction results and its ability to detect all real targets, respectively; further introduction of mean average precision (mAP) for comprehensive evaluation, where mAP50% reflects the average accuracy at an intersection to union ratio threshold of 0.5, while mAP50–95% imposes stricter and more comprehensive requirements on the localization accuracy of bounding boxes by calculating the average value at multiple thresholds ranging from 0.5 to 0.95. In terms of model complexity, measuring the size and computational burden of the model through parameter count (Params/M) is key to evaluating whether the model is easy to store and deploy. Finally, the frame rate per second (FPS/F·S1–) serves as a visual indicator to measure the actual inference speed of the model, directly determining whether it can meet the real-time requirements in real-world applications. This set of indicators together constitutes a complete evaluation system that objectively reflects the balance between accuracy, efficiency, and practicality of the model. The mathematical expressions for each indicator are as follows. 9 P=TPTP+FP 10 R=TPTP+FN 11 AP=∫01P(R)dR 12 mAP=∑iCAPiC Among them, TP (True Positive) represents positive examples that have been correctly classified, known as true examples; FP (False Positive) represents positive cases that have been misclassified, known as false positives or false positives; FN (False Negative) refers to negative examples that have been misclassified, known as false negative examples or missed detections; C represents the number of categories; I represents the i-th category. Comparative Experimental Results of Different Lightweight Models In the comparative experiment of model lightweighting, this paper selected multiple mainstream lightweight neural networks as backbone networks for comparative experiments, comprehensively evaluating the performance of each model in terms of detection accuracy, parameter quantity, and inference speed. The experimental results are shown in Table . 3Model Lightweight Comparison Experimentmodel P % R %mAP50%mAP50–95%Params/MFPS/F·S1– EfficientNetV195.5197.3898.9780.536.4857.81EfficientNetV295.0398.2998.9782.7421.0241.42MobileViTV195.9095.9498.5981.006.8843.50GhostNetV394.8696.5898.7380.7213.1653.83MobileOne89.6287.4094.2373.171.24144.24VanillaNet88.5092.3896.1871.741.59140.25MobileNetV291.9195.5097.5479.003.0087.14MobileNetv483.0387.8092.1168.343.62119.96 Model Lightweight Comparison Experiment From the data in Table , it can be seen that EfficientNetV1 performs excellently in all indicators, with an accuracy (P) of 95.51%, a recall (R) of 97.38%, mAP50 reaching 98.97%, and mAP50–95 reaching 80.53%. Its detection accuracy ranks among the top in all comparison models. Meanwhile, the parameter count of EfficientNetV1 is 6.48 M, which is at a moderate level, and the inference speed reaches 57.81 FPS, which can meet the real-time detection requirements. EfficientNetV2, which has similar performance to EfficientNetV1, although mAP50 also reaches 98.97% and mAP50–95 is slightly higher (82.74%), its parameter count is as high as 21.02 M, more than three times that of EfficientNetV1, and its inference speed is reduced to 41.42 FPS. Its deployment advantage is not significant in resource limited scenarios. The mAP50 of MobileViTV1 reaches 98.59%, but the parameter count is 6.88 M, and the inference speed is only 43.50 FPS, which is lower than the overall performance of EfficientNetV1. The mAP50 of GhostNetV3 is 98.73%, but it has a parameter count of 13.16 M and an inference speed of 53.83 FPS, which is slightly inferior in terms of parameter count and speed. In terms of inference speed, MobileOne performs the most outstandingly, with an FPS of 144.24 and only 1.24 M parameters, making it the model with the smallest number of parameters. However, its mAP50 is 94.23%, which is slightly lower than EfficientNetV1. VanillaNet also has a fast inference speed (140.25 FPS) and a small parameter count (1.59 M), but with an mAP50 of 96.18%, there is still room for improvement in detection accuracy. MobileNetV2, as a classic lightweight model, exhibits a balanced performance in terms of parameter count (3.00 M) and inference speed (87.14 FPS), with mAP50 reaching 97.54%, but its overall accuracy is still inferior to EfficientNetV1. MobileNetV4 achieves the fastest inference speed (119.96 FPS) among models with moderate parameter counts (3.62 M), but its mAP50 (92.11%) and mAP50–95 (68.34%) are the lowest in the comparison, indicating that its lightweight design compromises feature representation capability for coal-gangue detection. Taking into account the factors of detection accuracy, model parameter quantity, and inference speed, EfficientNetV1 achieves the best balance between accuracy and efficiency. Its mAP50 detection accuracy of 98.97%, parameter quantity of 6.48 M, and inference speed of 57.81 FPS make it the backbone network ultimately selected in this paper. Comparative Experimental Results of Different Neck Networks In object detection tasks, the neck network (Neck) is responsible for the transmission and fusion of multiscale features, and its design directly affects the model’s perception ability of objects of different sizes. To explore more efficient feature aggregation methods, we conducted comparative experiments on various neck structures under a unified backbone network and training configuration. The experimental results are shown in Table . 4Comparison Experiments of Different Neck Typesmodel P % R %mAP50%mAP50–95%Params/MFPS/F·S1– ASF90.6692.0096.3476.062.8985.79SEAM91.9691.0796.7273.562.6694.77GSConv89.8691.3995.6176.232.5983.89WFU90.7291.0496.3075.303.6094.86HSFPN86.6888.3693.9471.711.84106.73MAFPN90.3690.3296.4477.672.3186.45 Comparison Experiments of Different Neck Types From the data in Table , it can be seen that ASF achieved the highest mAP50 (96.34%) and mAP50–95 at 76.06%, while maintaining a smooth speed of 85.79 FPS, demonstrating the powerful ability of adaptive feature fusion. SEAM also excels in accuracy and speed, demonstrating an efficient feature enhancement mechanism with a mAP50 of 96.72% and a FPS of 94.77. GSConv has unique advantages in lightweight design, achieving 95.61% mAP50 and 83.89 FPS with only 2.59 M parameters, making it suitable for resource sensitive scenarios. At a high precision of 96.30%, WFU achieved an excellent speed of 94.86 FPS, balancing receptive field expansion and computational efficiency. HSFPN, with a very small parameter size of 1.84 M and a maximum frame rate of 106.73 FPS, has become a representative of extreme lightweight and is suitable for tasks with extremely high real-time requirements. After comprehensive consideration, we ultimately chose MAFPN as the neck network. This model is highly competitive in accuracy (mAP50:96.44%, mAP50–95:77.67%), second only to ASF and SEAM; The parameter count (2.31 M) and computational complexity (6.8G) are both at a low level, while the inference speed of 86.45 FPS ensures efficient deployment performance. MAFPN achieves the optimal balance between detection accuracy, model lightweighting, and inference speed, and is the neck structure with the best overall performance in this experiment. Comparison Experiment Results of Different Detection Heads The detection head serves as the decision-making core of the object detection network, responsible for transforming the fused features of the neck network into the final classification and localization results. To improve detection accuracy and efficiency, we conducted comparative experiments on various detection head structures based on the unified backbone and neck, focusing on the balance between their perception ability and computational cost on targets of different scales. The experimental results are shown in Table . 5Comparison Experiment of Different Detection Headsmodel P % R %mAP50%mAP50–95%Params/MFPS/F·S1– Detect_ASFF89.7092.0996.4676.794.2588.33Detect_DyHead87.5189.9195.0272.942.35102.79Detect_MBConv87.9989.3894.0073.322.24104.03xiaomubiao88.8488.1894.9075.672.7269.50 Comparison Experiment of Different Detection Heads From the data in Table , it can be seen that Detect_ASFF performs the most outstandingly among all models, ranking first in accuracy with 96.46% mAP50 and 76.79% mAP50–95. At the same time, the inference speed of 88.33 FPS also ensures efficient real-time detection capability, reflecting the powerful advantage of adaptive feature fusion in the detection head. Detect_SyHead performs excellently in lightweight design, achieving 95.02% mAP50 and a maximum frame rate of 102.79 FPS with only 2.35 M parameters and 4.9G computing power, setting a benchmark for speed and efficiency. DetectnMBConv also demonstrates the potential of efficient convolution in designing detection heads with a very small parameter size of 2.24 M and an excellent speed of 104.03 FPS. Xiaomubiao closely follows in accuracy, with 94.90% mAP50 and 75.67% mAP50–95 demonstrating its targeted optimization ability for small targets. After comprehensive consideration, we ultimately chose Detect_ASFF as the detection head. This model is far ahead in detection accuracy, with mAP50 reaching 96.46% and mAP50–95 reaching 76.79%, significantly better than other comparison models; At the same time, the inference speed of 88.33 FPS remains smooth while ensuring accuracy, and the parameter count (4.25 M) and computational complexity (9.8G) are also within an acceptable range. Comparative Experimental Results of Different Attention Mechanisms The attention mechanism aims to guide the model to focus on key features and suppress redundant information, which is an effective means to improve the accuracy of object detection. To investigate the enhancement effect of different attention modules on feature expression, we conducted comparative experiments on commonly used attention mechanisms, and the experimental results are shown in Table . 6Comparison Experiment of Different Attention Mechanismsmodel P % R %mAP50%mAP50–95%Params/MFPS/F·S1– MCA93.4891.4696.8076.992.5690.31A2C 2f_PPA88.3991.2296.6676.504.5653.75PPA91.5290.0395.8175.274.7386.38GAMAttention88.1791.8595.6775.822.99105.45CBAM88.5890.3895.6475.642.57103.54 Comparison Experiment of Different Attention Mechanisms From the data in Table , it can be seen that MCA performs the most outstandingly among all models, ranking first in accuracy with 96.80% mAP50 and 76.99% mAP50–95. At the same time, the inference speed of 90.31 FPS also ensures efficient real-time detection capability, demonstrating its unique advantages in multiscale feature calibration. A2C 2f_PPA closely follows in accuracy, with a mAP50 of 96.66% and a mAP50–95 of 76.50%, demonstrating the effectiveness of combining the PPA module with the C 2f architecture. PPA itself also performs well, with 95.81% mAP50 and 86.38 FPS reflecting its stable feature enhancement ability. GAMAttention achieved an excellent speed of 105.45 FPS with a high precision of 95.67%, balancing global attention mechanism and computational efficiency. As a classic spatial channel attention module, CBAM demonstrates its universality in different tasks with a mAP50 of 95.64% and a smooth speed of 103.54 FPS. After comprehensive consideration, we ultimately chose MCA as the attention module. This model leads the way in detection accuracy, with mAP50 reaching 96.80% and mAP50–95 reaching 76.99%, significantly better than other comparison models; At the same time, the parameter count (2.56 M) and computational complexity (6.3G) remain at a low level, and the inference speed of 90.31 FPS fully meets the real-time detection requirements. Ablation Experiment In order to comprehensively evaluate the impact of each module on YOLOv12 object detection performance, this paper designed a systematic ablation experiment, and the experimental results are shown in Table . The experiment uses the original YOLOv12n as the baseline and introduces the EfficientNetV1 backbone network (module A), MAFPN neck structure (module B), Detect_ASFF detection head (module C), and MCA attention mechanism (module D). The effectiveness of each module is verified by comparing accuracy, parameter quantity, and inference speed. Analysis shows that. 7Ablation Experiment TablebaselineABCD P % R %mAP50%mAP50–95%Params/MFPS/F·S1– √ 91.1591.4396.3076.132.56103.87√√ 95.5197.3898.9780.536.4857.81√ √ 90.3690.3296.4477.672.3186.45√ √ 89.7092.0996.4676.794.2588.33√ √93.4891.4696.8076.992.5690.31√√√ 89.3392.9596.8279.541.3199.13√√ √ 90.9391.9896.8080.312.0881.29√√ √90.9692.2496.3678.011.4982.19√√√√ 92.6994.1497.7381.122.5952.78√√√ √91.9294.1497.4880.461.9768.85√√√√√92.1794.4797.7581.172.5969.89 Ablation Experiment Table The introduction of Module A (EfficientNetV1 backbone network) brings the most significant performance improvement: compared to the baseline, mAP50 has increased from 96.30% to 98.97% (+2.67%), mAP50–95 has increased from 76.13% to 80.53% (+4.4%), and the recall rate R has reached 97.38%, indicating that EfficientNetV1’s powerful feature extraction ability can effectively capture key target information. But the parameter count increased from 2.56 M to 6.48 M, and the FPS decreased from 103.87 to 57.81, indicating that the performance improvement comes at the cost of computational overhead. When module B (MAFPN neck structure) is used alone, all indicators are basically the same as baseline (mAP50:96.44% vs 96.30%), but the parameter quantity slightly decreases to 2.31 M and FPS slightly decreases to 86.45. This indicates that MAFPN has a certain potential for lightweighting while maintaining performance, but its individual effect is not significant. Module C (Detect_ASFF detection head) exhibits interesting characteristics: the recall rate R has increased to 92.09% (+0.66%), but the accuracy rate P has slightly decreased (89.70% vs 91.15%), and mAP50–95 has only increased by 0.66%. This indicates that ASFF’s multiscale feature fusion helps recall more targets, but may introduce some false positives. When module D (MCA attention mechanism) is used alone, the effect is significant: the accuracy P reaches 93.48% (+2.33%), the recall R increases from 91.43% to 91.46%, and mAP50 reaches 96.80%. This indicates that MCA can effectively suppress background noise, improve detection confidence, and enhance feature discrimination while maintaining recall. In the dual module combination, the A + B combination performed the most outstandingly: although the parameter count was reduced to 1.31 M (a decrease of 79.8% compared to using A alone) and the FPS increased to 99.13, mAP50 slightly decreased to 96.82%. This verifies that the lightweight design of MAFPN can effectively compress the feature dimension of EfficientNetV1, achieving a balance between accuracy and efficiency. The A + C combination maintains a high mAP50–95 (80.31%) while the parameter count is only 2.08 M, demonstrating good compatibility between ASFF and EfficientNetV1. The A + D combination achieved 78.01% mAP50–95 with only 1.49 M parameters, indicating that MCA attention can efficiently compress features. In the three module combination, the A + B + C combination achieves the best comprehensive performance: mAP50–95 reaches 81.12%, 4.99% higher than the baseline, the accuracy rate P reaches 92.69%, and the recall rate R reaches 94.14%. The parameter size of 2.59 M is moderate, and the FPS of 52.78 meets the real-time detection requirements. This indicates a synergistic effect among the three modules: EfficientNetV1 extracts rich features, MAFPN efficiently fuses multiscale information, and ASFF optimizes detection head feature selection. The performance of A + B + D combination is slightly lower than A + B + C, but the FPS is higher (68.85 vs 52.78), indicating that MCA attention has better computational efficiency while maintaining accuracy. The A + B + C + D complete model achieves optimal detection performance: mAP50 reaches 97.75%, mAP50–95 reaches 81.17%, and the recall rate R reaches 94.47%. Compared with the baseline, mAP50–95 increased by 5.04%, accuracy increased by 1.02%, and recall increased by 3.04%. The parameter count of 2.59 M only increased by 0.03 M compared to the baseline, and the FPS of 69.89 maintained good real-time performance. This indicates that the four modules have a positive synergistic effect: EfficientNetV1 provides a high-quality feature foundation, MAFPN achieves efficient feature pyramid construction, ASFF optimizes multiscale feature fusion, and MCA attention mechanism enhances key region response. This ablation study provides empirical evidence for the modular improvement of YOLOv12, demonstrating that by reasonably combining lightweight backbone networks, efficient feature pyramids, and attention mechanisms, detection accuracy can be significantly improved while maintaining real-time performance. Comparative Experiment of Different Object Detection Networks To comprehensively evaluate the performance advantages of the proposed method in this paper, mainstream object detection algorithms such as Faster R–CNN, SSD, and YOLO series (v5n/v8n/v9t/v10n/v11n/v12n) were selected for comparative experiments, with precision P, recall R, mAP50, mAP50–95, parameter count Params, and inference speed FPS as the core evaluation indicators. The experimental results are shown in Table . 8Comparison Experiment of Object Detection Algorithmsmodel P % R %mAP50%mAP50–95%Params/MFPS/F·S1– Faster R–CNN23.6955.2329.8111.0928.2915.52SSD909088.8272.8323.88154.2YOLOv5n92.1792.1197.5979.472.50142.02YOLOv8n94.4393.9298.1681.123.01136.55YOLOv9t95.4594.3298.0180.361.9774.82YOLOv10n82.4883.9991.3573.932.70113.96YOLOv11n92.0392.1997.4278.692.58131.75YOLOv12n91.1591.4396.3076.132.56103.87Ours92.1794.4797.7581.172.5969.89 Comparison Experiment of Object Detection Algorithms From the comprehensive indicator mAP50–95, our method in this article ranks first with a score of 81.17%, which is 5.04 percentage points higher than the original YOLOv12n (76.13%) and has a slight advantage over YOLOv8n (81.12%). On the mAP50 index, Ours reached 97.75%, ranking third only after YOLOv8n′s 98.16% and YOLOv9t′s 98.01%. In terms of recall rate R, Ours outperforms all comparison models with a score of 94.47%, 0.55 percentage points higher than YOLOv8n (93.92%), and 3.04 percentage points higher than YOLOv12n (91.43%), indicating that our method can effectively capture more targets and reduce missed detections. The overall performance of the YOLO series is excellent: YOLOv8n ranks second with an mAP50–95 of 81.12%, followed closely by YOLOv9t with 80.36%, YOLOv5n reaches 79.47%, while YOLOv10n performs poorly with only 73.93%, even lower than SSD’s 72.83%. The traditional two-stage detector Faster R–CNN has the lowest accuracy (mAP50–95 only 11.09%), which is difficult to meet practical application requirements. In terms of parameter size, YOLOv9t is the lightest at 1.97 M, while our method in this paper is 2.59 M, which is basically on par with YOLOv12n (2.56 M) and YOLOv11n (2.58 M), and significantly better than YOLOv8n′s 3.01M. Compared with SSD (23.88 M) and Faster R–CNN (28.29 M), our method reduces the parameter size by nearly 91%, demonstrating extremely high parameter efficiency. In terms of inference speed, SSD leads with 154.2 FPS, followed closely by YOLOv5n with 142.02 FPS. Our method in this article achieves 69.89 FPS, although not as fast as lightweight models such as YOLOv5n, it far exceeds the real-time detection requirements (>30 FPS) and has sufficient practicality in precision first application scenarios. Taking into account various indicators, Ours was ultimately selected as the optimal model in this article, mainly based on the following considerations: first, the detection accuracy is optimal. Our mAP50–95 leads all comparison models with 81.17%, which is higher than YOLOv8n (81.12%) and YOLOv9t (80.36%), especially in terms of recall rate R (94.47%), ensuring that key targets are not missed, which is crucial for practical applications. Second, the parameter efficiency is high. Our parameter size is only 2.59 M, which is on par with YOLOv12n and much lower than YOLOv8n′s 3.01M. The model is lightweight and easy to deploy. Third, significant improvements have been made. Compared with the original YOLOv12n, Ours showed a 5.04 percentage point increase in mAP50–95 and a 3.04 percentage point increase in recall rate while keeping the parameter count basically unchanged (2.59 M vs 2.56 M), fully verifying the effectiveness of the improved module in this paper. Fourthly, there is a good balance between accuracy and speed. The inference speed of 69.89 FPS fully meets the real-time detection requirements and has significant advantages in tasks that pursue high precision. In summary, the model proposed in this article demonstrates excellent performance and practical value in object detection tasks by integrating accuracy, efficiency, and real-time performance. Among them, figure a represents coal gangue samples with a light intensity of 200 lx (darkest) and a small number (<10), figure b represents coal gangue samples with a light intensity of 900 lx (brightest) and a medium number (10–20), figure c represents coal gangue samples with a light intensity of 200 lx (darkest) and a medium number (10–20), and figure d represents coal gangue samples with a light intensity of 550 lx (medium brightness) and a large number (>20). As shown in Figure , except for YOLOv5n, YOLOv9 tiny, and the EMAM-YOLO12n model proposed in this paper, other YOLOv8n, YOLOv10n, YOLOv11n, and YOLOv12n all showed varying degrees of missed detection, re detection, and false detection. The EMAM-YOLO12n model proposed in this paper exhibited the highest detection confidence score, accurately identifying coal and gangue, and demonstrating the best detection performance. Therefore, in simulating complex working conditions for coal gangue identification tasks, the EMAM-YOLO12n model demonstrates strong robustness and significant detection accuracy, outperforming other comparative models. Detection results of YOLO series algorithms under different operating conditions (a) low-light, small-sample coal gangue (200 lx, <10 pieces); (b) high-light, medium-sample coal gangue (900 lx, 10–20 pieces); (c) lowest-light, moderate-sample coal gangue (100 lx, 10–22 pieces); (d) medium-light, large-sample steel gangue (550 lx, >20 pieces). To further analyze the comprehensive detection performance of EMAM-YOLO12n EMAM-YOLO12n, YOLOv5n, YOLOv8n, YOLOv9-tiny, YOLOv10n, YOLOv11n, YOLOv12n Visualize and display partial results under different brightness conditions and coal gangue numbers, as shown in Figure (missed detections are represented by yellow circles, re detections are represented by red circles, and false detections are represented by orange circles). Generalization Experiment This experiment used the data set from ref for generalization validation. The data set contains coal gangue samples of different particle sizes and numbers, with a total of 500 high-resolution images, as shown in Figure . Examples of other mining data sets. To verify the generalization ability of our algorithm, we compared it with YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, and YOLOv12n under the same experimental conditions on the data set in ref The results are shown in Table , with bolded values indicating the optimal values. 9Comparative Experimental Results on the Dataset of Ref model P % R %mAP50%mAP50–95%Params/MFPS/F·S1– YOLOv8n91.7892.5898.5981.173.018.1YOLOv9t94.6895.2998.2181.381.977.6YOLOv10n72.3476.9183.7368.102.708.2YOLOv11n92.3791.8196.4877.922.586.3YOLOv12n94.8191.9398.1577.632.566.3Ours95.8098.3199.1081.962.5626.4 Comparative Experimental Results on the Dataset of Ref According to the experimental results in Table , the EMAM-YOLO12 algorithm performs better than YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, and YOLOv12n, with higher detection accuracy and good overall performance. Although YOLOv9t performs well in terms of parameter count (only 1.97 M), its FPS is low (62.63 F/s) and real-time performance is poor, which is not conducive to deployment on terminal devices. Although YOLOv10n has a fast inference speed (100.25 F/s), its detection accuracy is significantly insufficient, with an mAP50 of only 83.73%, far lower than the model proposed in this paper. YOLOv8n, YOLOv11n, and YOLOv12n have achieved a certain balance between accuracy and speed, but still fall short in key indicators such as recall and mAP50–95% compared to our model. The model in this article achieved an accuracy of 95.80%, a recall rate of 98.31%, an mAP50 of 99.10%, and an mAP50–95% of 81.96%, all of which are superior to all comparison methods. In terms of parameter quantity, the model in this article only requires 2.56 M, which is comparable to YOLOv12n and much lower than YOLOv8n. Moreover, the FPS reaches 87.68F/s, meeting the real-time detection requirements. In summary, the EMAM-YOLO12 algorithm in this article achieved the highest detection accuracy and recall rate on other mining data sets, demonstrating stronger generalization ability and engineering application value. Conclusion (1)This paper proposes an EMAM-YOLO coal-gangue detection model for complex underground mining environments. The primary technical contribution is 2-fold: first, the novel design of an adaptive spatial feature fusion detection head (Detect_ASFF) that learns dynamic spatial weightsrepresenting a structural innovation within the detection head; second, the specific combination and synergistic interaction of four complementary modules (EfficientNetV1, MAFPN, Detect_ASFF, and MCA), each targeting a distinct drawback of the native YOLOv12n for coal-gangue detection. The experimental results showed that the average accuracy (mAP50–95) of the model reached 81.17%, with an accuracy rate of 92.17% and a recall rate of 94.47%. The detection speed was 69.89 FPS, which was 5.04% higher than the original YOLOv12n in terms of average accuracy. It can accurately and efficiently complete the detection task of coal and gangue.(2)This article systematically optimizes YOLOv12n by introducing a lightweight EfficientNetV1 backbone network, a multiscale attention feature pyramid network (MAFPN), an adaptive spatial feature fusion detection head (Detect_ASFF), and a multiscale channel attention (MCA) mechanism. Compared with existing mainstream object detection algorithms, the EMAM-YOLO model can more accurately identify coal and gangue in simulated complex environments such as low light, multiple targets, and different degrees of occlusion, significantly reducing missed and false detection rates, and effectively improving the robustness and accuracy of the model in practical application scenarios.(3)The EMAM-YOLO model ensures high detection accuracy while controlling the parameter count at 2.59 M, balancing model performance and lightweight requirements. However, considering the resource constraints of underground mobile platforms or edge computing equipment, future research can further explore model compression and pruning technology, or introduce more efficient convolution operators, in order to continuously improve the detection speed of models and better adapt to the hardware environment of intelligent sorting in coal mines under the premise of maintaining accuracy. (1)This paper proposes an EMAM-YOLO coal-gangue detection model for complex underground mining environments. The primary technical contribution is 2-fold: first, the novel design of an adaptive spatial feature fusion detection head (Detect_ASFF) that learns dynamic spatial weightsrepresenting a structural innovation within the detection head; second, the specific combination and synergistic interaction of four complementary modules (EfficientNetV1, MAFPN, Detect_ASFF, and MCA), each targeting a distinct drawback of the native YOLOv12n for coal-gangue detection. The experimental results showed that the average accuracy (mAP50–95) of the model reached 81.17%, with an accuracy rate of 92.17% and a recall rate of 94.47%. The detection speed was 69.89 FPS, which was 5.04% higher than the original YOLOv12n in terms of average accuracy. It can accurately and efficiently complete the detection task of coal and gangue. This paper proposes an EMAM-YOLO coal-gangue detection model for complex underground mining environments. The primary technical contribution is 2-fold: first, the novel design of an adaptive spatial feature fusion detection head (Detect_ASFF) that learns dynamic spatial weightsrepresenting a structural innovation within the detection head; second, the specific combination and synergistic interaction of four complementary modules (EfficientNetV1, MAFPN, Detect_ASFF, and MCA), each targeting a distinct drawback of the native YOLOv12n for coal-gangue detection. The experimental results showed that the average accuracy (mAP50–95) of the model reached 81.17%, with an accuracy rate of 92.17% and a recall rate of 94.47%. The detection speed was 69.89 FPS, which was 5.04% higher than the original YOLOv12n in terms of average accuracy. It can accurately and efficiently complete the detection task of coal and gangue. (2)This article systematically optimizes YOLOv12n by introducing a lightweight EfficientNetV1 backbone network, a multiscale attention feature pyramid network (MAFPN), an adaptive spatial feature fusion detection head (Detect_ASFF), and a multiscale channel attention (MCA) mechanism. Compared with existing mainstream object detection algorithms, the EMAM-YOLO model can more accurately identify coal and gangue in simulated complex environments such as low light, multiple targets, and different degrees of occlusion, significantly reducing missed and false detection rates, and effectively improving the robustness and accuracy of the model in practical application scenarios. This article systematically optimizes YOLOv12n by introducing a lightweight EfficientNetV1 backbone network, a multiscale attention feature pyramid network (MAFPN), an adaptive spatial feature fusion detection head (Detect_ASFF), and a multiscale channel attention (MCA) mechanism. Compared with existing mainstream object detection algorithms, the EMAM-YOLO model can more accurately identify coal and gangue in simulated complex environments such as low light, multiple targets, and different degrees of occlusion, significantly reducing missed and false detection rates, and effectively improving the robustness and accuracy of the model in practical application scenarios. (3)The EMAM-YOLO model ensures high detection accuracy while controlling the parameter count at 2.59 M, balancing model performance and lightweight requirements. However, considering the resource constraints of underground mobile platforms or edge computing equipment, future research can further explore model compression and pruning technology, or introduce more efficient convolution operators, in order to continuously improve the detection speed of models and better adapt to the hardware environment of intelligent sorting in coal mines under the premise of maintaining accuracy. The EMAM-YOLO model ensures high detection accuracy while controlling the parameter count at 2.59 M, balancing model performance and lightweight requirements. However, considering the resource constraints of underground mobile platforms or edge computing equipment, future research can further explore model compression and pruning technology, or introduce more efficient convolution operators, in order to continuously improve the detection speed of models and better adapt to the hardware environment of intelligent sorting in coal mines under the premise of maintaining accuracy.