A coal gangue image segmentation method based on DCNPSPNet
By improving the PSPNet network structure and training strategy, the DCNPSPNet model solves the problems of low segmentation accuracy and poor real-time performance in coal and gangue sorting, achieving high-precision, lightweight, and real-time coal and gangue image segmentation, and adapting to complex mining conditions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI UNIV OF SCI & TECH
- Filing Date
- 2026-04-01
- Publication Date
- 2026-07-03
AI Technical Summary
Existing coal gangue sorting technologies suffer from problems such as insufficient sorting accuracy, high operating costs, high misjudgment rate, insufficient model generalization ability, and difficulty in meeting the real-time detection needs of industrial sites. In particular, when dealing with densely distributed coal gangue and small pieces of coal, the segmentation edges are blurred and the number of parameters is large, resulting in computational redundancy.
We adopt the DCNPSPNet model and improve the PSPNet network structure by replacing the residual blocks of the backbone network with lightweight attention residual blocks that integrate the CBAM attention mechanism, replacing the traditional dilated convolution with hybrid dilated convolution, and introducing the GELAN module for pyramid pooling. We combine data augmentation and staged training strategies to optimize the loss function to improve segmentation accuracy and model lightweighting.
It achieves high-precision, lightweight, and real-time segmentation of coal gangue images, adapts to complex mining conditions, improves the model's generalization and stability, and meets the real-time detection needs of industrial sites.
Smart Images

Figure CN122336280A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep learning technology, and in particular to a coal gangue image segmentation method based on DCNPSPNet. Background Technology
[0002] During coal mining, coal gangue is inevitably extracted as a by-product. The large amount of coal gangue generated during mining results in resource waste and reduced energy efficiency. The high ash content and low calorific value of coal gangue make it unusable directly, and its large-scale accumulation occupies land resources and causes environmental pollution. The presence of coal gangue also affects coal quality, reduces its calorific value, increases transportation costs, and causes environmental pollution during combustion.
[0003] Therefore, accurate and efficient coal gangue separation is a crucial step in improving coal resource utilization, reducing environmental pollution, and achieving green mine construction. On the one hand, coal gangue separation can improve coal purity, enhance the market competitiveness of coal products, and meet the stringent quality requirements of different users. On the other hand, effectively separating coal gangue can reduce pollutant emissions during coal combustion, mitigate negative environmental impacts, and promote the clean and efficient utilization of coal resources. This has profound significance for ensuring energy supply security, promoting the sustainable development of the energy industry, and achieving environmental protection goals.
[0004] Previous coal gangue separation technologies had the following problems: 1. Traditional coal gangue sorting methods suffer from insufficient sorting accuracy due to technical defects, resulting in resource waste, high operating costs, and serious environmental pollution; 2. Intelligent coal gangue sorting technology usually uses sensors such as X-ray and near-infrared sensors. However, these sensors have a high false judgment rate in some special scenarios, poor generalization ability, and high cost.
[0005] With the development of deep learning technology, semantic segmentation methods based on convolutional neural networks have been gradually applied to the field of coal gangue image segmentation. Among them, models such as PSPNet and DeepLabv3+ have become mainstream segmentation models due to their strong contextual feature extraction capabilities. However, existing technologies still have many drawbacks in practical coal gangue segmentation applications: First, the traditional ResNet50 backbone network has weak feature capture capabilities for densely clustered coal gangue, small coal pieces, and other small targets, which easily leads to missed detections and blurred segmentation edges. Second, conventional dilated convolution has a grid effect, and continuous use of convolution with the same dilation rate will result in excessively large feature sampling intervals, loss of local detail information, and affect segmentation accuracy. Third, the original pyramid pooling module of PSPNet is a fixed-scale pooling, which has poor feature extraction flexibility, large model parameters, computational redundancy, and slow inference speed, making it difficult to meet the real-time detection needs of industrial sites. Fourth, considering the characteristics of imbalanced categories and blurred boundaries in coal gangue images, the loss function design of existing models is too simple, which cannot take into account both difficult samples and edge segmentation accuracy, resulting in insufficient model generalization ability. Summary of the Invention
[0006] To overcome the shortcomings of the prior art, this invention provides a coal gangue image segmentation method based on DCNPSPNet, which can adapt to both simple and scattered and complex and dense dual scenes, and balances segmentation accuracy, model lightweighting and real-time inference.
[0007] To achieve the above objectives, the present invention adopts the following technical solution, including: A coal gangue image segmentation method based on DCNPSPNet includes the following steps: S1. Collect coal gangue images containing both scattered and dense distributions, perform pixel-level annotation on the coal gangue images to label coal, coal gangue, and background, and construct a coal gangue image dataset. S2, Construct the DCNPSPNet model for coal gangue image segmentation, where the PSPNet model is used as the base network; Replace the residual blocks of the backbone network with lightweight attention residual blocks that integrate the CBAM attention mechanism, while retaining the identity mapping structure; Replace the traditional dilated convolution of the backbone network with hybrid dilated convolution; Replace the pyramid pooling module with the GELAN module. S3, the DCNPSPNet model was trained using a coal gangue image dataset; S4 inputs the coal gangue image to be tested into the trained DCNPSPNet model and outputs the pixel-level segmentation results of the coal gangue image.
[0008] Preferably, in step S1, data enhancement is also performed on the coal gangue image, including geometric transformation, brightness adjustment, and addition of Gaussian noise.
[0009] Preferably, the CBAM attention mechanism is located after the convolution operation and before the residual connection in the residual block, performing channel attention and spatial attention sequentially.
[0010] Preferably, the hybrid dilated convolution adaptively adjusts the dilation rate based on the downsampling factor.
[0011] Preferably, the GELAN module adopts a three-branch parallel architecture, including a depthwise separable convolution branch, a global context branch, and a local enhancement branch. The outputs of the three branches are concatenated through channels, fused by 1×1 convolutions, residual connections, and ReLU activation to output features.
[0012] Preferably, the model training adopts a phased training strategy of freezing and then thawing, combining the Adam optimizer and the composite loss function to train the model, and evaluates the model performance through evaluation metrics to complete the tuning of model parameters.
[0013] Preferably, the composite loss function is a linear combination of four functions: cross-entropy loss, Dice loss, Focal loss, and boundary loss, as shown below: ; ; ; ; ; in, This is a composite loss; These are the cross-entropy loss, Dice loss, Focal loss, and boundary loss functions, respectively. is the corresponding loss weight; n is the total number of pixels in the image; c is the category number, divided into three categories: coal, coal gangue, and background; Category weights; The true label is the true probability that the i-th pixel in the image belongs to category c. The model predicts the probability, which is the probability that the i-th pixel in the image is predicted to be of class c. It is a smoothing factor; As a category balance factor; For the corrected predicted probability, if ,but ,like ,but ; As a focusing factor; Let be the true boundary label of the i-th pixel; Let be the distance from the i-th pixel to the nearest real boundary.
[0014] The preferred phased training strategy is as follows: in the frozen phase, only the GELAN module is trained; in the unfrozen phase, all model parameters are tuned; and the model performance is evaluated using the average intersection-union ratio (mIoU) and average pixel accuracy (mPA) as evaluation metrics.
[0015] The present invention also provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the aforementioned coal gangue image segmentation method based on DCNPSPNet.
[0016] The present invention also provides a computer program product comprising a computer program / instructions that, when executed by a processor, implement the aforementioned coal gangue image segmentation method based on DCNPSPNet.
[0017] The advantages of this invention are: (1) This invention addresses the technical pain points of existing coal gangue image segmentation models, such as low segmentation accuracy of densely clustered targets, missed detection of small coal targets, large number of model parameters, slow inference speed, obvious grid effect, and poor adaptability to working conditions. By optimizing the PSPNet network structure, improving the feature extraction and fusion method, and optimizing the training strategy, this invention achieves high-precision, lightweight, and real-time segmentation of coal gangue images.
[0018] (2) The dataset covers both scattered and dense scenarios. Combined with phased training and composite loss function, it effectively addresses issues such as imbalance of coal gangue categories, blurred boundaries, and missed detection of small targets. The generalization and stability of the model are greatly improved, making it suitable for various complex mining conditions.
[0019] (3) The CBAM attention mechanism is integrated into the residual block to achieve dual feature calibration of channel and space, strengthen key features such as small coal pieces and coal gangue adhesion boundaries, and suppress background noise; the hybrid dilated convolution optimizes the distribution of sampling points, eliminates grid effect, and preserves image detail features; the GELAN module achieves efficient fusion of multi-scale features through a three-branch parallel structure, which greatly improves the segmentation accuracy for densely adhered scenes.
[0020] (4) Compared with mainstream segmentation models such as traditional PSPNet and DeepLabv3+, the DCNPSPNet model of this invention has achieved breakthrough improvements in segmentation performance, model efficiency and scene adaptability, and has both high theoretical innovation and industrial practical value.
[0021] (5) By introducing lightweight technologies such as depth-separable convolution and channel compression, the DCNPSPNet model of this invention has a reduced total number of parameters and a smaller model size compared to the traditional PSPNet (ResNet50), effectively reducing memory usage and adapting to industrial deployment.
[0022] (6) Compared with the traditional PSPNet model, the DCNPSPNet model of this invention improves FPS and can meet the real-time segmentation and detection requirements of coal gangue images in industrial sites, taking into account both accuracy and speed. Attached Figure Description
[0023] Figure 1 This is a flowchart of a coal gangue image segmentation method based on DCNPSPNet according to the present invention.
[0024] Figure 2 This is a schematic diagram of the image geometric transformation of the present invention.
[0025] Figure 3 This is a schematic diagram of the image brightness adjustment method of the present invention.
[0026] Figure 4 A schematic diagram of adding Gaussian noise to the image of this invention.
[0027] Figure 5 This is a diagram of the CBAM structure.
[0028] Figure 6 This is a diagram of a hybrid dilated convolution structure.
[0029] Figure 7 This is a diagram of the GELAN architecture.
[0030] Figure 8 This is a diagram of the DCNPSPNet architecture.
[0031] Figure 9 This is the segmentation result of DCNPSPNet on dispersed coal gangue.
[0032] Figure 10 This is the segmentation result of DCNPSPNet on dense coal gangue.
[0033] Figure 11 This is a graph of DCNPSPNet parameters. Detailed Implementation
[0034] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0035] Example 1 Please see Figure 1 , Figure 1This is an overall flowchart of the coal gangue image segmentation method of the present invention. This embodiment introduces a coal gangue image segmentation method based on DCNPSPNet, including the following steps: S1. Obtain coal gangue images containing both dispersed and dense distributions (i.e., coal gangue images containing both simple and complex environments), perform pixel-level image annotation on the coal gangue images, and annotate the coal, coal gangue, and background pixels to construct a coal gangue image dataset.
[0036] S2. A coal gangue image segmentation model (DCNPSPNet model) is constructed. To improve the recognition accuracy of small coal pieces mixed in densely distributed coal gangue, the structure of the PSPNet network is optimized. The residual blocks of the backbone network (ResNet50) are replaced with lightweight attention residual blocks, and the CBAM attention mechanism is integrated in each residual block. At the same time, the identity mapping design of the traditional ResNet50 is retained to ensure training stability. Meanwhile, the traditional dilated convolution in the backbone network is replaced with hybrid dilated convolution (HDC). In the pyramid pooling module, a Generalized Efficient Layer Aggregation Network (GELAN) is introduced to replace the traditional convolution, which improves the flexibility of the model.
[0037] S3 uses a coal gangue image dataset to train the DCNPSPNet model. During the model training process, parameter tuning is performed to improve the model's performance, and the model's performance is demonstrated through evaluation metrics.
[0038] S4 inputs the coal gangue image to be tested into the trained DCNPSPNet model and outputs the pixel-level segmentation results of the coal gangue image.
[0039] This invention performs data augmentation processing on the original coal gangue image, including geometric transformations, brightness adjustment, and the addition of Gaussian noise, to enrich the diversity of the dataset. Image geometric transformations include: image rotation by 180°, horizontal flipping, and vertical flipping. Specifically, the `cv2.rotate` function is used to rotate the image by 180 degrees, the `cv2.flip` function is used to flip the image horizontally, and the `cv2.flip` function is used to flip the image vertically. A schematic diagram of the image after geometric transformation is shown below. Figure 2 As shown; Image brightness adjustment: Convert the image to the HSV color space and increase (or decrease) the value of the luminance channel to brighten (or darken) the image. An illustration of the adjusted image brightness is shown below. Figure 3 As shown; Adding Gaussian noise to an image: The added Gaussian noise is a random signal that follows a normal distribution. Gaussian noise is typically composed of the superposition of many independent, small random factors. An illustration of an image after adding Gaussian noise is shown below. Figure 4 As shown.
[0040] The coal gangue image dataset used in this invention includes coal gangue images in both simple and complex environments, comprehensively covering the differences in actual working conditions to observe the accuracy of the model in segmenting coal gangue images under different environments. In the dataset used in this invention, coal gangue images in simple environments refer to images with a small amount of coal gangue that is scattered, while coal gangue images in complex environments refer to images with a large amount of coal gangue that is densely and adhered together. The difference between the two is that when segmenting coal gangue images in complex environments, the model is required to have high accuracy in segmenting small targets, and to be able to segment coal and coal gangue more accurately when they are adhered together. Therefore, the DCNPSPNet model proposed in this invention is an optimization aimed at solving this problem.
[0041] The improved structure of the DCNPSPNet model of this invention is shown below: 1. CBAM attention mechanism CBAM (Convolutional Block Attention Module) is a lightweight attention module that can be embedded into various convolutional neural networks. It achieves feature selection and spatial focusing through a sequential combination of channel attention and spatial attention. The model structure is as follows: Figure 5 As shown.
[0042] In CBAM, spatial attention uses both average pooling and max pooling to improve boundary localization accuracy and focuses on selecting important spatial regions, while channel attention selects important feature types. Therefore, the execution order of the two in CBAM is channel attention first, followed by spatial attention. Furthermore, CBAM can adaptively adjust attention for different categories, improving the detection accuracy of small targets.
[0043] In the DCNPSPNet model, a CBAM attention mechanism is embedded before the residual connection of each residual block, allowing each layer to learn an attention mechanism suitable for the features of that layer, thus achieving attention collaboration from local to global.
[0044] In the DCNPSPNet model, the CBAM module is designed with independent configuration for each layer. The `cbam_layers` parameter allows independent control over whether each residual layer of the ResNet uses the CBAM module. This hierarchical configuration allows the model to flexibly apply attention mechanisms at different levels of abstraction, adapting to the characteristics of features at different depths. Furthermore, the CBAM module is deeply integrated with the backbone network, embedding channel and spatial attention directly within the residual blocks. During the construction of each residual layer in the backbone network, the `cbam_layers` configuration determines whether to insert the CBAM module after the convolutional operation and before the residual connections, ensuring that the attention mechanism directly affects the feature representation.
[0045] 2. Hybrid dilated convolution Hybrid Dilated Convolution (HDC) is an improved dilated convolution strategy designed to address the gridding effect problem in traditional dilated convolution. The gridding effect refers to the gaps between non-zero elements after applying multiple dilated convolutions with the same dilation rate, resulting in the loss of some detail. Therefore, HDC uses a combination of convolutional layers with different dilation rates and ensures that the sampling points in the receptive field are evenly distributed, covering a continuous region. This maximizes the receptive field while avoiding information loss. Its structure is as follows: Figure 6 As shown. In the improved backbone network, HDCs with hole ratios of 2 and 4 are used respectively.
[0046] In the DCNPSPNet model, HDC adaptively adjusts the dilation rate of dilated convolutions based on different downsampling factors. When the downsampling factor is 8, a dilation rate of 2 is applied to layer 3 (the third residual layer), and a dilation rate of 4 is applied to layer 4 (the fourth residual layer); when the downsampling factor is 16, a dilation rate of 2 is applied to layer 4. This design ensures that a reasonable receptive field is maintained at different downsampling rates.
[0047] In the DCNPSPNet model, the combination of CBAM and HDC achieves attention-enhanced feature extraction. CBAM helps HDC better select important features, expanding the receptive field while maintaining attention to key regions. This collaborative design is particularly suitable for image segmentation tasks, requiring a balance between global context and local details.
[0048] 3. GELAN module The traditional fixed-scale pyramid pooling module is replaced by the GELAN module. The GELAN module is based on the ELAN architecture and has greater flexibility.
[0049] Traditional pyramid pooling modules use a fixed 4-scale pooling, while GELAN can adaptively learn features, improving the flexibility of feature extraction, and its continuous multi-scale feature extraction enriches scale information. GELAN introduces depthwise separable convolutions, improving computational efficiency. The combination of GELAN's global context branch and attention mechanism replaces simple concatenation after pooling, enabling better modeling of long-range dependencies. In terms of feature fusion, GELAN replaces simple channel concatenation with learnable fusion and residual connections. Furthermore, GELAN has fewer parameters and a faster convergence speed. The GELAN model structure is as follows: Figure 7 As shown.
[0050] In the GELAN architecture, depthwise separable convolution is used instead of traditional convolution. This is the key technology for achieving a lightweight backbone. It ensures that GELAN has good feature extraction capabilities while achieving the low computation and low latency required for real-time semantic segmentation.
[0051] The GELAN module is the core of the DCNPSPNet model in this invention. The GELAN module employs a three-way parallel fusion design with residual connections. The three branches are a depthwise separable branch, a global context branch, and a local enhancement branch. This parallel architecture can simultaneously capture features of different scales and types.
[0052] The depthwise separable branch uses depthwise separable convolutions to efficiently extract features. First, a 1×1 convolution is used to compress the input channels to 1 / 4 of the original dimension, reducing computation. Then, a 3×3 depthwise convolution is used to extract spatial features, with each input channel processed independently. Finally, a 1×1 convolution is used to restore the channel dimension and align it with other branches. This design significantly reduces the number of parameters and computation while maintaining feature extraction capabilities.
[0053] The global context branch captures long-range dependencies through global average pooling. First, it compresses the feature map to a 1×1 size using global average pooling to capture global statistical information. Then, it uses 1×1 convolution for channel adjustment and feature transformation. Finally, it restores the original spatial size through bilinear interpolation upsampling. This branch primarily processes global context information, compensating for the limited receptive field of local convolutions.
[0054] The local enhancement branch enhances local detail information through convolution, employing a double 3×3 convolution design. The first 3×3 convolution performs feature transformation and dimensionality adjustment, while the second 3×3 convolution further extracts local spatial features, maintaining the same dimensionality as the depthwise separable branch output. This branch focuses on local details and boundary information, improving segmentation accuracy.
[0055] Finally, the outputs of the three branches are concatenated along the channel dimension. A 1×1 convolution is used to fuse multi-branch features, reducing the number of channels, and skip connections are used to add the input features to the fused features. Finally, a ReLU activation function is applied. This design maintains the independence of each branch while achieving effective feature integration, and residual connections ensure the stability of the gradient flow.
[0056] In this invention, the DCNPSPNet model structure is as follows: Figure 8 As shown, the overall operation of the DCNPSPNet model involves extracting multi-level features through a backbone network, integrating information at different scales through a GELAN module, and finally generating pixel-wise predictions through a classification layer. While maintaining high performance, the DCNPSPNet model achieves a significant reduction in the number of parameters and an improvement in computational efficiency through techniques such as depthwise separable convolution, channel compression, and parameter sharing. Furthermore, techniques such as residual connections, batch normalization, and Dropout directly alleviate the gradient vanishing problem, accelerate training convergence, and reduce the risk of overfitting. In this embodiment, the specific structural parameters of the DCNPSPNet model are as follows: Figure 11 As shown, the model input image size is 473×473, and the output needs to be a segmentation image of the same size. Therefore, bilinear upsampling is required to restore the size. Figure 11 In this context, s represents stride, p represents fill, and d represents void ratio.
[0057] In this embodiment, firstly, a GPU-compatible version of PyCharm Community Edition compatible with Windows 10 is downloaded from the Anaconda official website. Then, a virtual environment is created in Anaconda Prompt, and the libraries required by PSPNet are installed within this environment. These include OpenCV for video processing and image manipulation, NumPy for numerical computation, Pillow for image processing, and TQDM for displaying the training progress bar. After the environment is set up, the code for this invention is opened in PyCharm, and the Python interpreter is updated to the conda environment. Finally, model training and prediction are performed.
[0058] In this embodiment, coal areas are marked in red and coal gangue areas are marked in green, generating PNG format annotation files to construct a VOC standard dataset. The dataset is stored according to the VOC specification, with the original images stored in the JPEGImages folder and the corresponding segmented and annotated images stored in the SegmentClass folder. The dataset is partitioned using text files in the ImageSets folder. The coal gangue image dataset is divided into a training set and a validation set in a 9:1 ratio, i.e., the training set accounts for 90% and the validation set accounts for 10%. Subsequent model training and performance verification will be based on this partition.
[0059] For the dataset processing stage, a custom dataset class is used in the PSPnetDataset module to load images and their corresponding labels, perform normalization, and data augmentation operations. At the same time, a custom data concatenation function is used in the pspnet_dataset_collate module to adapt to the requirements of multi-scale image input and label alignment, ensuring the standardization of data input. Furthermore, random image transformations are implemented using the PIL and NumPy libraries to further enrich data diversity and enhance the model's generalization ability.
[0060] Setting training parameters is a crucial step in the model training process of machine learning and deep learning, directly affecting the model's performance, training efficiency, and final results. The training parameters of the model in this invention are shown in Table 1 below.
[0061] Table 1 Training parameters of the model
[0062] In Table 1, `Pretrained` is a key hyperparameter of the model, controlling whether to load ImageNet pre-trained weights, directly affecting the model's convergence speed, overfitting risk, and final segmentation accuracy. `aux_branch` controls whether to enable auxiliary branches, which are key components designed to address the vanishing gradient problem in deep networks and improve training stability. `CUDA` is a hardware acceleration switch for the model's training / inference phases, controlling whether to use GPUs for computation, directly determining the model's running speed.
[0063] The model training adopts a phased training strategy of freezing and then unfreezing. In the freezing phase, only the GELAN module is trained, and in the unfreezing phase, all model parameters are tuned. The model is trained by combining the Adam optimizer and the composite loss function, and the model performance is evaluated by the average intersection-union ratio mIoU and the average pixel accuracy mPA, thus completing the tuning of the model parameters.
[0064] The model training employs a freeze-then-thaw strategy, first learning general features and then task-specific features. This phased training approach leads to more stable model convergence. During the freeze phase, the initial learning rate is 1×10⁻⁶. -5 The initial iterations start from 0, with 60 training iterations and a batch size of 4. Smaller batches can alleviate memory pressure but may affect convergence speed. The total number of iterations during the unfreezing phase is 160, with a learning rate of 1×10⁻⁶. -3 The batch size is 2, and the learning rate scheduling strategy is to multiply the learning rate by 0.1 every 20 iterations to alleviate overfitting. The reason for the different learning rates in the two stages is that a smaller learning rate is used in the freezing stage to protect the backbone network features, while a larger learning rate is needed in the unfreezing stage to update the frozen parameters.
[0065] In the relevant settings, the value of `num_workers` is 1 during the freeze phase and 4 during the unfreeze phase. Here, `num_workers` refers to the number of parallel threads for data loading. Multithreading can speed up data reading, but it needs to be adjusted according to the number of CPU cores. The `pin_memory` setting is set to `True`, which caches data in the GPU's video memory, thereby accelerating data transfer efficiency.
[0066] The composite loss function is a linear combination of four functions: cross-entropy loss, Dice loss, Focal loss, and boundary loss. Specifically, when there is severe class imbalance, the weight of the cross-entropy loss is reduced; when the coal gangue region is smaller than the background region, the weight of the Dice loss is increased; when there are samples or pixels that the model struggles to classify, the weight of the Focal loss is moderated; and the weight of the boundary loss is appropriately adjusted to handle blurred boundaries. If a certain loss function is of little use, its weight can be set to 0. The formula for the loss function is as follows: ; ; ; ; ; in, This is a composite loss; These are the cross-entropy loss, Dice loss, Focal loss, and boundary loss functions, respectively. is the loss weight; n is the total number of pixels in the image; c is the category number, divided into three categories: coal, coal gangue, and background; These are category weights used to balance the differences in the number of samples in each category; if the proportion of coal gangue and coal is small, their corresponding weights are increased. The true label is the true probability that the i-th pixel in the image belongs to category c. The value is 1 if it belongs to category c, and 0 otherwise. The model predicts the probability, which is the probability that the i-th pixel in the image is predicted to be of class c, and its value ranges from (0,1). This is a smoothing factor, and its value is a very small constant to prevent the denominator from being 0. This is the class balancing factor, used to balance the number of samples in each class, with a value range of (0,1). For the corrected predicted probability, if ,but ,like ,but ; As a focusing factor, >0 increases the weight of difficult cases; the larger the value, the stronger the focusing effect on difficult samples. Let be the true boundary label of the i-th pixel; It represents the distance from the i-th pixel to the nearest real boundary. The closer the distance, the greater the weight, thus enhancing the boundary region segmentation effect.
[0067] In this model, a stepwise addition method is used to determine the optimal combination of loss functions. Initially, only cross-entropy loss is used, and the optimal combination is determined. Then, adding Dice loss can specifically address class imbalance, determining... Add Focal loss to handle difficult cases and determine the outcome. Finally, add boundary loss to handle blurred boundaries and determine the result. .
[0068] Adam is an adaptive learning rate optimization algorithm, suitable for non-convex optimization problems.
[0069] In this embodiment, mIoU (mean intersection-to-union ratio) and mPA (mean pixel accuracy) are used to measure the performance of the model.
[0070] The Intersection over Union (IoU) ratio is the geometric ratio of the area of intersection between the predicted region and the actual labeled region to the area of union. It represents the ratio of the area of the overlapping portion of the two regions to the total area covered after they are merged. This index characterizes the degree of overlap between the predicted and actual values, with an accuracy value approaching 1. The average IoU ratio is the average of the IoU ratios for all categories.
[0071] Pixel accuracy (PA) refers to the proportion of correctly predicted pixels out of the total number of pixels, while average pixel accuracy is the average of pixel accuracy across all categories.
[0072] In this embodiment, the segmentation results of the DCNPSPNet model on dispersed and densely distributed coal gangue images are as follows: Figure 9 , Figure 10 As shown.
[0073] Furthermore, to demonstrate the advantages of the image segmentation model used in this invention in image segmentation tasks, the same dataset was used to train other models (DeepLabv3+, PSPNet) and combined with different backbone networks (MobileNetv2, ResNet50, Xception) to test their performance.
[0074] DeepLabv3+ focuses on improving detail recovery in semantic segmentation tasks. While retaining core modules such as dilated convolutions and dilated spatial pyramid pooling, it introduces a more efficient decoder structure and a lightweight design. DeepLabv3+'s decoder recovers resolution through simple upsampling, while DeepLabv3+ introduces a complex decoder that combines low-level features with high-level semantic information, improving the precision of edge and small object segmentation. Its encoder relies on backbone networks like Xception to extract features at different levels, which contain rich semantic information, although the resolution gradually decreases. Dilated convolutions are used in the backbone network to increase the receptive field and acquire multi-scale contextual information. DeepLabv3+ improves the dilated spatial pyramid pooling module, adjusting its structure and parameters to enhance cross-scale feature extraction efficiency. The core idea of DeepLabv3+'s backbone network Xception is to maximize the channel separation concept of the Inception module, achieving higher computational efficiency and model performance through depthwise separable convolutions.
[0075] In this embodiment, the DeepLabv3+ model is trained and evaluated on this dataset by combining Xception with the Mobilenetv2 backbone network, and the PSPNet model is trained by combining ResNet50 with the Mobilenetv2 backbone network. The performance of the DCNPSPNet model proposed in this invention is compared with that of the DCNPSPNet model. The comparison results are shown in Table 2 below.
[0076] Table 2 Comparison of Evaluation Indicators for Each Model
[0077] As shown in Table 2, DCNPSPNet demonstrates a performance improvement over PSPNet (ResNet50). Specifically, in terms of mIoU, coal shows a 3% improvement, while gangue shows a 2.02% improvement; in terms of mPA, coal shows a 2.41% improvement, and gangue shows a 2.31% improvement. Compared to the DeepLabv3+ model, DCNPSPNet also shows a performance improvement of approximately 1% to 5%. Therefore, the DCNPSPNet model proposed in this paper exhibits the best performance.
[0078] Furthermore, DCNPSPNet's lightweight design reduces the number of parameters compared to PSPNet. The lightweight comparison is shown in Table 3 below.
[0079] Table 3 Comparison of Model Lightweighting
[0080] As shown in Table 3, the total number of parameters in DCNPSPNet is reduced by 6,928,135, or approximately 6.93 million, compared to PSPNet, representing a reduction of about 14.12%. Furthermore, DCNPSPNet uses FP32 format to store model parameters, which is 26.43 MB smaller than PSPNet. DCNPSPNet's minimum FPS is 99.98 fps, meaning the model can process 99.98 frames per second, an improvement of about 10% compared to PSPNet, indicating improved stability.
[0081] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A coal gangue image segmentation method based on DCNPSPNet, characterized in that, Includes the following steps: S1. Collect coal gangue images containing both scattered and dense distributions, perform pixel-level annotation on the coal gangue images to label coal, coal gangue, and background, and construct a coal gangue image dataset. S2, Construct the DCNPSPNet model for coal gangue image segmentation, where the PSPNet model is used as the base network; Replace the residual blocks of the backbone network with lightweight attention residual blocks that integrate the CBAM attention mechanism, while retaining the identity mapping structure; Replace the traditional dilated convolution of the backbone network with hybrid dilated convolution; Replace the pyramid pooling module with the GELAN module. S3, the DCNPSPNet model was trained using a coal gangue image dataset; S4 inputs the coal gangue image to be tested into the trained DCNPSPNet model and outputs the pixel-level segmentation results of the coal gangue image.
2. The coal gangue image segmentation method based on DCNPSPNet according to claim 1, characterized in that, In step S1, data augmentation is also performed on the coal gangue image, including geometric transformation, brightness adjustment, and the addition of Gaussian noise.
3. The coal gangue image segmentation method based on DCNPSPNet according to claim 1, characterized in that, The CBAM attention mechanism is located after the convolution operation and before the residual connection in the residual block, performing channel attention and spatial attention in sequence.
4. The coal gangue image segmentation method based on DCNPSPNet according to claim 1, characterized in that, Hybrid dilated convolution adaptively adjusts the dilation rate based on the downsampling factor.
5. The coal gangue image segmentation method based on DCNPSPNet according to claim 1, characterized in that, The GELAN module adopts a three-branch parallel architecture, including a depthwise separable convolution branch, a global context branch, and a local enhancement branch. The outputs of the three branches are concatenated through channels, fused by 1×1 convolutions, residual connections, and ReLU activation to output features.
6. The coal gangue image segmentation method based on DCNPSPNet according to claim 1, characterized in that, The model training adopts a phased training strategy of freezing and then thawing, combining the Adam optimizer and composite loss function to train the model, and evaluates the model performance through evaluation metrics to complete the tuning of model parameters.
7. The coal gangue image segmentation method based on DCNPSPNet according to claim 6, characterized in that, The composite loss function is a linear combination of four functions: cross-entropy loss, Dice loss, Focal loss, and boundary loss, as shown below: in, This is a composite loss; These are the cross-entropy loss, Dice loss, Focal loss, and boundary loss functions, respectively. is the corresponding loss weight; n is the total number of pixels in the image; c is the category number, divided into three categories: coal, coal gangue, and background; Category weights; The true label is the true probability that the i-th pixel in the image belongs to category c. The model predicts the probability, which is the probability that the i-th pixel in the image is predicted to be of class c. It is a smoothing factor; As a category balance factor; For the corrected predicted probability, if ,but ,like ,but ; As a focusing factor; Let be the true boundary label of the i-th pixel; Let be the distance from the i-th pixel to the nearest real boundary.
8. The coal gangue image segmentation method based on DCNPSPNet according to claim 6, characterized in that, The phased training strategy is as follows: during the freeze phase, only the GELAN module is trained; during the unfreeze phase, all model parameters are tuned; and the model performance is evaluated using the average intersection-union ratio (mIoU) and average pixel accuracy (mPA) as evaluation metrics.
9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the coal gangue image segmentation method based on any one of claims 1-8.
10. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processor, implements the coal gangue image segmentation method based on any one of claims 1-8.