# Pedestrian-Crossing Detection Enhanced by CyclicGAN-Based Loop Learning and Automatic Labeling
## 4 System Implementation
### Detection and Automatic Labeling Module  
After collecting and preprocessing the pedestrian-crossing images--inclusive of augmenting rare-condition samples using CycleGAN--the dataset was partitioned into training and testing sets to facilitate model training and performance evaluation. The pedestrian-crossing detection module in this study was trained using the pretrained yolov4.conv.137 [9], which performs object prediction through grid-based feature localization and generates bounding boxes that identify pedestrian-crossing regions in the input images. Although YOLO has evolved into its twelfth generation, each version possesses distinct advantages [11]. Notably, YOLOv4 achieved substantial improvements in detection accuracy, while subsequent versions have primarily focused on model compression and computational efficiency. The training environment was configured as a virtual machine with 4 GB RAM and a Tesla P100 PCIe 16 GB GPU. For the YOLOv4 training parameters, the number of classes was set to 1, and the number of filters was adjusted to 18. The maximum number of batches was set to 6000, with step sizes at 4800 and 5400. The batch size and subdivisions were both set to 64. According to the detection speed evaluations conducted by [PERSON] et al. [9], the YOLOv4 model consistently achieved a detection speed exceeding 30 FPS, meeting the benchmark for real-time detection. The pedestrian-crossing automatic labeling module was developed using Python 3.7 and comprises several core functions. For video processing, frames are sampled at a rate of six frames per second to prevent redundant captures of the same intersection. Given that the original video resolution is 1080p at 60 frames per second, selecting one frame every ten frames ensures appropriate temporal spacing. At a driving speed of \begin{table}
\begin{tabular}{c c c c c c} \hline
**Situation** & **Dataset 1** & **Dataset 2** & **Dataset 3** & **Dataset 4** & **Dataset 5** \\ \hline Day to Night & 1000 & 2000 & 3000 & 4000 & 5000 \\ \hline Day to Rainy Day & 300 & 600 & 900 & 1200 & 1500 \\ \hline Day to Rainy Night & 200 & 400 & 600 & 800 & 1000 \\ \hline Day to Sun Glare & 200 & 400 & 600 & 800 & 1000 \\ \hline Day to High-Beam Glare & 200 & 400 & 600 & 800 & 1000 \\ \hline \end{tabular}
\end{table} 
Table 2: Training datasets of five different image generations. approximately 50 km/h through green-lit intersections, the pedestrian crossing typically remains visible for 1.5 to 2 s, allowing the system to capture approximately ten unique frames per intersection. Since pedestrian crossings usually appear near the lower portion of the frame where the Y-coordinate is larger (given the image origin is at the top-left corner), while the upper portion of the frame often contains background objects, such as the sky, traffic lights, or distant buildings that could be incorrectly detected as pedestrian crossings, a vertical threshold is applied to filter out such false positives. Specifically, detections with bounding-box centers below this Y-axis threshold (i.e., with smaller Y values) are flagged as potential misclassifications and excluded from the labeling process, while detections with bounding-box centers above this threshold (i.e., with larger Y values) are retained as likely valid detections. As illustrated in Figure 8, the module also includes mechanisms to identify repeated detections of the same pedestrian crossing or splits caused by occlusions (e.g., parked vehicles). These are post-processed and consolidated to ensure consistent labeling of single pedestrian crossings. To prevent missing any pedestrian crossings, frames that were not automatically assigned pseudo-labels undergo manual frame-by-frame inspection and annotation. During video processing, detection results are displayed sequentially for each frame. For every frame in which a pedestrian crossing is successfully detected, the system saves both a jpg image and a corresponding.txt file sharing the same filename.