## 3 Materials and Methods
### Combining Adaptive Ensemble Attention with GAN  
Integrating Adaptive Ensemble Attention into a Generative Adversarial Network (GAN) enhances the segmentation performance for ADAS. The generator in the GAN is equipped with self-attention, spatial attention, and channel attention mechanisms, adaptively fused to focus on relevant features based on the scene complexity. This ensures precise and context-aware segmentation outputs, making it ideal for diverse driving scenarios. The generator uses self-attention to capture long-range dependencies within the image, such as aligning lane markings or detecting relationships between objects at a distance. This mechanism enables the model to understand the broader spatial context, which is crucial for segmenting large-scale structures like roads or detecting vehicles in distant lanes. Spatial attention is incorporated to identify critical regions in the image, such as traffic signs, pedestrians, or vehicles. It prioritizes spatially significant areas, ensuring the model pays more attention to parts of the image that are most relevant for segmentation. Channel attention complements these mechanisms by recalibrating feature maps to emphasize important features, such as road textures or vehicle edges, and suppress irrelevant information like background noise. The AEA mechanism dynamically combines these three types of attention based on the input image and the driving scenario. For example, in open highway scenarios, self-attention may dominate to capture global dependencies such as lane alignment. Conversely, in crowded urban settings, spatial attention takes precedence to focus on pedestrians, parked vehicles, and other objects in close proximity. Regardless of the scenario, channel attention ensures that critical features are prioritized across the network. This adaptive integration makes the generator versatile and robust in handling varying complexities in real-world driving environments. The discriminator in the GAN evaluates the segmentation mask generated by the generator. It distinguishes between real (ground truth) and fake (generated) masks by analysing the concatenated pair of the original image and its corresponding segmentation mask. Through adversarial training, the discriminator pushes the generator to refine its outputs, ensuring that the generated masks not only match the ground truth but also appear highly realistic. This feedback loop between the generator and discriminator significantly improves the overall segmentation quality. During training, the generator optimizes a combination of losses, including the segmentation loss (e.g., cross-entropy) to ensure pixel-wise accuracy and the adversarial loss to improve the mask's realism. The discriminator, on the other hand, minimizes its error in distinguishing real masks from generated ones. This adversarial setup encourages the generator to produce masks that are increasingly difficult for the discriminator to classify as fake. By combining the strengths of GANs with Adaptive Ensemble Attention, the system dynamically adapts to the complexities of input images. This fusion enables robust and precise semantic segmentation across diverse environments, including urban traffic, highways, and rural roads. The integration of these attention mechanisms ensures that the GAN captures both global and local dependencies, handles occlusions effectively, and adapts to challenges like varying lighting and weather conditions. This approach makes Adaptive Ensemble Attention GAN a powerful tool for advancing the capabilities of ADAS in real-world autonomous driving applications. Let \(X\)\(\in\)RH \(\times\) W \(\times\) C represent the input image, where H is the height, W is the width, and C is the number of channels. The Adaptive Ensemble Attention mechanism integrates three types of attention: self-attention \(SA\), spatial attention SPA, and channel attention CA. Self-attention captures long-range dependencies within the image.