# Pedestrian-Crossing Detection Enhanced by CyclicGAN-Based Loop Learning and Automatic Labeling
## 4 System Implementation
### Image Generation Module  
After data collection and preprocessing, we employ CycleGAN to generate synthetic pedestrian-crossing images under various environmental conditions. These generated images retain visual similarity to the original input while allowing feature-level transformations--such as converting daytime scenes into night, rain, or glare conditions. The purpose of this augmentation process is to enhance dataset diversity and improve the robustness of the YOLO-based pedestrian-crossing detection module trained in the subsequent stages. This image generation module is implemented using the open-source CycleGAN repository available on [[https://github.com/junyanz/pytorch-CycleGAN-and-pix2](https://github.com/junyanz/pytorch-CycleGAN-and-pix2) pix]([https://github.com/junyanz/pytorch-CycleGAN-and-pix2](https://github.com/junyanz/pytorch-CycleGAN-and-pix2) pix) ([PERSON]  
Figure 5: Percentages of weather patterns in real images. and Taesung Park) (accessed on 5 June 2025) [39], leveraging the PyTorch 1.4.0 deep-learning framework and executed within the Google Colab environment. The CycleGAN architecture comprises two main components: the generator and the discriminator. The generator itself consists of three submodules: the encoder, transformer, and decoder. In the encoder stage, input images from domain A are first resized to \(256\times 256\) pixels and passed through a series of convolutional neural network (CNN) layers for feature extraction. We configure the number of output features in the convolutional layers to 32. This decision is based on the observation that simpler detection tasks do not require a large number of extracted features. Setting the feature count to 64, for example, may lead to excessive memory usage and overemphasis on high-frequency features (such as sharp edges), which are not essential for this task. Instead, we prioritize low-frequency features--such as smooth color transitions--that are more representative of the pedestrian crossing as a whole. The encoder depth is fixed at three layers, corresponding to the RGB color channels. The batch size for training is set to 32, a standard setting commonly used in CycleGAN training to balance performance and resource efficiency. In the transformer stage, the extracted features are interpreted as combinations of image characteristics, and the network learns to map them to a different domain distribution. We adopt a ResNet-9 block structure for this purpose. By adding residual connections, the network ensures that information from earlier layers is preserved in deeper layers. This residual learning technique helps to maintain the spatial and structural integrity of the original input, ensuring that key features such as object shape and size are not lost during transformation. Finally, in the decoder stage, a series of deconvolutional layers are used to reconstruct the image from the transformed feature vector. The decoder outputs a \(256\times 256\) image corresponding to domain B. Like the encoder, the decoder uses 32 convolutional features to maintain consistency and avoid introducing unnecessary complexity. The full architecture and training process of the generator are illustrated in Figure 6.  
To complete the adversarial training process of CycleGAN, it is essential to construct a discriminator network alongside the generator. The discriminator extracts visual features from the input image to distinguish between real and synthetic data. As in the generator, we set the number of output features extracted from the convolutional layers to 32. A final convolutional layer with a one-dimensional output is appended to produce the final prediction score. The discriminator then classifies the input image as either a real (original) image or a fake (generated) image produced by the generator. Figure 6: Generator architecture and training process. In selecting the environmental conditions for this study, practical considerations and real-world driving scenarios in Taiwan's urban areas played a central role.