Table 1 Pseudocode of improving the YOLOv5s model.

From: Accurate real-time obstacle detection of coal mine driverless electric locomotive based on ODEL-YOLOv5s

Algorithm 1: Improved YOLOv5s Algorithm

Require: Training dataset with obstacle images

Ensure: Trained YOLOv5s model

1: Procedure: Data Preparation

2: Collect and annotate dataset for obstacle detection in coal mine roadways

3: Split dataset into training, validation, and testing sets

4: Procedure: Data Augmentation

5: Apply various data augmentation techniques, including adjusting saturation, exposure, and hue of images

6: Perform geometric distortion such as cropping, shearing, rotating, and flipping

7: Introduce data augmentation methods like Mixup, Cutout, Cutmix, and Mosaic

8: Procedure: Build Detection Model

9: Use a backbone network (e.g., CSPDarknet53) to extract image features

10: Fuse features in the neck network by combining shallow and deep feature maps

11: Add a prediction layer in the head for detecting small obstacles by concatenating fused features with 152 × 152-scale shallow feature maps

12: Procedure: Introduce CBAM Attention Mechanism

13: Integrate Convolutional Block Attention Module (CBAM) into YOLOv5s model

14: Extract attention features along channel and spatial dimensions using CBAM

15: Combine attention-enhanced features with original feature maps for adaptive feature refinement

16: Procedure: Train the Model

17: Calculate loss using improved IoU loss function, such as α-CIoU loss:\(L_{\alpha - {\text{CIoU}}} = 1 - {\text{IoU}}^{\alpha } + \left( {\frac{{\rho (b,b^{gt} )}}{c}} \right)^{2\alpha } + \beta \nu\)

18: Adopt Cluster-NMS as the non-maximum suppression processing method

19: Update model parameters through backpropagation and optimization algorithms (e.g., stochastic gradient descent)

20: Evaluate model performance on the validation set during training and make adjustments accordingly

21: Procedure: Model Evaluation and Testing

22: Evaluate trained YOLOv5s model using the testing set

23: Compute metrics such as AP, mAP, recall, precision, etc

24: Test the model on new images from coal mine roadways to assess obstacle detection performance