# 3L-YOLO: A Lightweight Low-Light Object Detection Algorithm
## 2 Methods
### 3L-YOLO Model
#### 2.2.3 Improved Dynamic Detection Head Based on Deformable Convolution  
In low-light environments, objects exhibit variations in class, location, and scale. To effectively distinguish objects from low-contrast backgrounds and improve detection accuracy, the network must leverage spatial, scale, and channel information. Inspired by the dynamic head [42] and based on deformable convolution (DCNv3) [43], we propose an object detection head that cascades spatial, scale, and channel attention mechanisms, as illustrated in Figure 6. We first apply spatial attention, scale attention, and channel attention  
Figure 4: Neck module structure design: (**a**) FPN structure in YOLOv8n; (**b**) PANet structure in YOLOv8n; (**c**) BiFPN structure; (**d**) our neck module with multi-scale features and channel attention mechanism. Figure 5: Efficient channel attention mechanism (ECA). mechanisms to the input features and then perform object detection and recognition using the decoupled head of YOLOv8n. Given the feature tensor \(\mathcal{F}\in\mathcal{R}^{L\times S\times C}\), the formulation of three sequential attention is as follows:  
\[\text{W}(\mathcal{F})=\pi_{C}(\pi_{L}(\pi_{S}(\mathcal{F})\cdot\mathcal{F}) \cdot\mathcal{F})\cdot\mathcal{F} \tag{3}\]  
where \(\pi_{C}(\cdot)\), \(\pi_{L}(\cdot)\) and \(\pi_{S}(\cdot)\) are channel attention functions, scale attention, and spatial attention, respectively. In the spatial attention module, deformable convolution (DCNv3) [43] is employed to aggregate the spatial features of objects at the same scale. In comparison with DCNv2 [44] and DCN [45], DCNv3 employs separable convolution, a multi-grouping mechanism, and normalizing modulation scalars along sampling points, thereby enhancing feature extraction capabilities and stabilizing the model's training process. By learning offsets for irregular samples, deformable convolution enables the model to focus on object regions with variations in scale, aspect ratio, and rotation while suppressing background noise. The mathematical formulation of spatial attention is as follows:  
\[\pi_{S}(\mathcal{F})\cdot\mathcal{F}=\sum_{l=1}^{L}\sum_{k=1}^{K}w_{l}\cdot m _{l,k}\cdot\mathcal{F}_{l}(p+p_{k}+\Delta p_{l,k}) \tag{4}\]  
where \(L\) is the level of feature map. \(K\) is the number of sparse sampling locations. \(\Delta p_{l,k}\) is a shifted location of \(p_{k}\) in the \(l\)-th feature map. \(m_{l,k}\) is a self-learned importance scalar at location \(p_{k}\) in the \(l\)-th feature map. In the scale attention module, global pooling, \(1\times 1\) convolution, and the sigmoid function are used to calculate the weights of different scale levels and perform weighted aggregation of features across these levels. \[\pi_{S}(\mathcal{F})\cdot\mathcal{F}=\sigma\bigg{(}f\bigg{(}\frac{1}{SC}\sum_{ S,C}\mathcal{F}\bigg{)}\bigg{)}\cdot\mathcal{F} \tag{5}\]  
where \(f(\cdot)\) is a \(1\times 1\) convolutional layer, and \(\sigma(x)=max\Big{(}0,min\Big{(}1,\frac{x+1}{2}\Big{)}\Big{)}\) is a hard-sigmoid function. In the channel attention module, the threshold for controlling feature channel switching is derived by first performing global pooling, followed by two fully connected layers, and concluding with a normalization layer:  
\[\pi_{S}(\mathcal{F})\cdot\mathcal{F}=max(\alpha_{1}(\mathcal{F})\cdot\mathcal{ F}_{c}+\beta_{1}(\mathcal{F}),\alpha_{2}(\mathcal{F})\cdot\mathcal{F}_{c}+ \beta_{2}(\mathcal{F})) \tag{6}\]  
Figure 6: Dynamic detection head based on DCNv3. The input features are fed into the detect head of YOLOv8n after the application of spatial attention, scale attention, and channel attention mechanisms. DCNv3 is employed as a spatial attention mechanism for aggregating spatial features. where \(\mathcal{F}_{c}\) is the feature slice at the \(c\)-th channel and \([\alpha_{1},\alpha_{2},\beta_{1},\beta_{2}]^{T}\) denotes a hyperfunction that learns to control the activation thresholds derived from the output of the normalization layer.