# DGSS-YOLOv8s: A Real-Time Model for Small and Complex Object Detection in Autonomous Vehicles
## 3 Methodology
### Architecture Overview
#### 3.1.3 Detect_SA Module  
Traditional detection modules mainly rely on local feature extraction, making it difficult to comprehensively capture the global information in an image, limiting the performance of the model in complex scenes. Although the Transformer architecture [40] performs well in capturing global contextual information, its typical Self-Attention (SA) mechanism is often limited in practical applications due to its high computational complexity and memory consumption. Specifically, standard SA exhibits quadratic complexity (\(O(N^{2})\)) with respect to the number of input tokens (\(N\)) [40], requiring large memory (\(O(N^{2})\)) for attention maps, and the accompanying Feed-Forward Network (FFN) layers also contribute significantly to parameters and computation [57], hindering high-FPS applications on high-resolution inputs. These factors--quadratic computational cost, large memory footprint, and expensive FFN layers--are the primary limitations that Detect_SA aims to overcome for real-time applications. To address these limitations while still benefiting from global context modeling, we constructed the Detect_SA module by integrating the Memory-efficient Self-Attention module [58] in the detection header of YOLOv8s. Our Detect_SA implementation achieves efficiency by employing grouped query attention combined with a bottleneck structure using \(1\times 1\) convolutions to reduce channel dimensions before the SA computation and notably omitting the large FFN typical in Transformer blocks. Figure 5 illustrates the schematic structure of Detect_SA. The Memory-efficient Self-Attention module retains the global context-capturing capability of the Self-Attention layer while reducing the computational complexity and memory footprint by removing the FFN part and introducing \(1\times 1\) convolution [58]. Specifically, \(1\times 1\) convolution is used to reduce the number of input channels, making Self-Attention a bottleneck layer with smaller input/output channels, followed by restoring the channel dimensions through \(1\times 1\) convolution. To further enhance the expressive power of the model, the module also contains an additional bypass \(1\times 1\) convolution for retaining the uncompressed residual information. Compared to incorporating a standard Transformer block (SA+FFN) with similar input/output dimensions, Detect_SA achieves global context modeling with significantly lower theoretical computational cost and memory footprint. While precise memory figures depend on implementation details and input size, the removal of the FFN and the use of bottlenecking substantially reduce parameters and intermediate activation storage compared to the standard SA's \(O(N^{2})\) memory for attention maps plus FFN costs [57]. This  
Figure 4: Structural diagram of CSPmodule. efficiency is crucial for maintaining high real-time FPS, as substantiated by the minimal FPS decrease observed in our ablation studies (detailed in Section 4.4), where adding this module yielded accuracy gains with only a modest impact on speed. This makes it suitable for efficient, high-FPS detection tasks in resource-constrained environments such as self-driving vehicles. Regarding adaptability, the core principles of Detect_SA (bottle-necking, grouped attention, FFN removal) are general and could potentially be adapted to other object detection architectures, particularly those using convolutional heads where inserting such an attention mechanism might enhance feature representation. However, seamless integration would require architectural adjustments specific to the target model (e.g., channel dimensions, connection points). Within the scope of this specific study on DGSS-YOLOv8s, we did not perform a direct head-to-head benchmark comparing Detect_SA against a standard SA module integrated into the same YOLOv8s detection head on datasets like COCO [4] or KITTI.