# Channel Pruning-Based YOLOv7 Deep Learning Algorithm for Identifying Trolley Codes
## 2 Development of the Algorithm
### YOLOv7 Algorithm
#### 2.3.2 Identifying Trolley Codes Based on YOLOv7  
In order to mitigate the negative impact of background variations and changes in illumination caused by constant changes in lighting conditions and the position of the workpiece during image acquisition, we employed a deep learning-based approach for object detection. This method allows us to accurately identify trolley codes [17,18] and enhance the algorithm's robustness. The You-Only-Look-Once (YOLO) network is an algorithm for target detection that operates in a single stage [19]. It utilizes convolutional kernels of sizes \(1\times 1\) and \(3\times 3\) and is built upon the architecture of GoogleNet [17]. The proposed approach employs a singular convolutional neural network (CNN) to analyze the image, enabling simultaneous computation of both classification outcomes and object coordinates. The speed of YOLO is greatly improved by employing end-to-end target localization and classification techniques [19]. YOLO has gained widespread popularity in the domain of target recognition due to its exceptional real-time performance and ability to detect multiple targets [20, 21, 22, 23, 24]. Compared to its predecessors in the YOLO series, YOLOv7 incorporates the ELAN network architecture, which enhances the model's ability to understand image content and consequently improves detection accuracy. YOLOv7 incorporates a multi-scale detection mechanism, which enables target detection on feature maps of varying scales. This integration enhances the model's ability to detect objects of different sizes, including both small and large objects. Additionally, YOLOv7 incorporates a wider range of complex data augmentation techniques, including CutMix and Mosaic. These strategies aim to augment the diversity of the training data, thereby enhancing the model's generalization capability [25]. As depicted in Figure 5, the preprocessed image is fed into the backbone network. According to the three-layer output in the backbone network, the head layer consistently generates three layers of feature maps with varying sizes through the backbone network. After the implementation of the RepVGG block and convolution, the model is capable of performing three types of image detection tasks, namely classification, front and rear background classification, and border detection. The final results are then generated based on these tasks. Figure 4: Technical flow of the proposed method. The basis of our research lies in the thorough collection of data, encompassing a diverse range of real-world images that feature tram codes in different environmental conditions and scenarios. After the completion of data collection, the data set is labeled using LabelMe 4.5.13 software, and the resulting labels are saved in a kt format. The annotated dataset was divided into two subsets, namely a training set consisting of 1248 images and a test set consisting of 311 images. The ratio between the training and testing sets was maintained at 4:1. For the purpose of object detection, we have selected the well-established YOLOv7 model, renowned for its exceptional performance in various object detection tasks. To leverage the benefits of transfer learning, we initiated the training process by utilizing the YOLOv7 model that had been pre-trained on the COCO dataset. However, in order to tailor the model to our particular task of tram code recognition, we implemented parameter modifications. Key adjustments encompass modifying the batch size, altering the number of iterations, fine-tuning the learning rate, and specifying object classes. Before commencing the training of the model, the images were resized to a standardized input size of 640 \(\times\) 640 pixels, ensuring their compatibility with the model's input specifications. The model's learning rate is set at 0.01, and the number of iterations is determined to be 300 rounds. Taking into consideration the image characteristics and GPU performance of the car encoding dataset, we initially chose a batch size of 16.