# Engineering Vehicle Detection Based on Improved YOLOv6
## 3 Methods  
### Backbone  
The Swin Transformer [6], recognized as a versatile backbone for general-purpose computer vision, has attracted significant attention since its introduction. In real-world traffic scenarios, engineering vehicles are often partially obscured by other vehicles, utility poles, green belts, and other obstacles, leading to incomplete captures, posing a common challenge in detection tasks. To address this challenge, we selected the Swin Transformer as the backbone. Its strength lies in its excellent global feature extraction capability and hierarchical feature representation mechanism, which enables the network to capture both fine-grained and coarse-grained features. This ability not only ensures effective detection of local features but also adapts to the challenges posed by varying object sizes, making it well-suited for the accurate detection requirements in intelligent transportation systems. The Vision Transformer (ViT) is a model that harnesses the Transformer architecture to a visual domain. It processes visual data by dividing images into multiple small patches and applying self-attention mechanisms. Compared to the ViT, the Swin Transformer introduces a patch merging operation, which allows it to seize features on multiple scales across various levels. It improves its efficacy in dealing with objects of notably different dimensions [30; 31]. As is shown in Figure 1, building upon the ViT, the Swin Transformer initiates processing with smaller patches and gradually consolidates adjacent patches as it delves into deeper layers of the Transformer architecture. This process constructs a hierarchical representation, empowering the backbone to effectively process both fine-grained and coarse-grained information at various levels. For this study, we employ a Swin Transformer as feature extraction network for the object detection model and extract features from engineering vehicles in the dataset [6]. The framework of the Swin Transformer is illustrated within the blue dashed lines in Figure 2, which denotes the backbone segment. The Swin Transformer comprises four primary stages. Analogous to the structure of CNN, the feature dimension is halved, and the channel count is doubled at the end of each stage. Figure 1: Hierarchical feature mapping diagram built by the Swin Transformer. The original images are preprocessed using methods such as Mosaic, random affine transformation, MixUp, HSV color space adjustment, and random flipping. After preprocessing, the image is dissected into several patches by the Patch Partition module, preparing for subsequent feature extraction and self-attention calculations. After going through the linear embedding layer mapping, the image is input into the Swin Transformer block to calculate self-attention. Figure 3 displays a diagram of the Swin Transformer block's architecture. Unlike the multi-head self-attention in the ViT [31], the Swin Transformer replaces it with W-MSA, a variant of the self-attention mechanism that reduces computation load by processing self-attention independently in isolated local windows. W-MSA divides the feature map into local windows with no overlap, and each window independently performs self-attention calculations. This update simplifies the computation of the attention mechanism. Figure 3: Swin Transformer block structure diagram. The multi-head self-attention modules of the Transformer are replaced with window multi-head self-attention (W-MSA) and shifted window multi-head self-attention (SW-MSA). This substitution is advantageous for diminishing the computational complexity associated with self-attention. Figure 2: The framework of the improved YOLOv6. To tackle the challenge of facilitating information sharing among different windows, the second part utilizes the SW-MSA module. It is an enhanced version of W-MSA, which improves information interaction between windows by shifting the window partition lines, thereby enhancing the model's ability to capture global image features.