## 2 Unsafe Behavior Identification Model
### Improved YOLOv5s Model Construction
#### 2.2.3 Adding a (160 \(\times\) 160) Small-Object Detection Layer  
The YOLOv5s architecture uses three detection heads for multi-scale prediction. For 640 \(\times\) 640 input images, the Neck network generates feature maps at 8\(\times\), 16\(\times\), and 32\(\times\) downsampling ratios corresponding to:  
1. Small-scale detection layer (80 \(\times\) 80): high-resolution features with limited receptive fields, optimized for sub-50 px targets through fine-grained spatial details
2. Medium-scale detection layer (40 \(\times\) 40): balanced resolution and receptive fields, targeting 50-150 px objects with moderate contextual awareness
3. Large-scale detection layer (20 \(\times\) 20): low-resolution features with expansive receptive fields, specialized in detecting >150 px targets through semantic abstraction  
In construction environments characterized by distant small targets (typically <30 px) and expansive spatial layouts, the original YOLOv5s' small-scale detection head (80 \(\times\) 80) demonstrates inadequate performance due to insufficient receptive field granularity. To address this limitation, we introduce an auxiliary detection head (160 \(\times\) 160) through the following modifications:  
1. Neck network enhancement: Incorporate an additional upsampling operation within the feature pyramid structure. 2. Cross-layer feature fusion: Integrate the third-stage upsampled features with the backbone's second-layer outputs (C3/C4 level), combining high-resolution spatial details from shallow layers with rich semantic information from deeper hierarchies. 3. Multi-scale representation learning: Leverage fused feature maps to simultaneously preserve fine-grained textures for small objects and capture contextual relationships across large-scale scenes. The added 160 \(\times\) 160 detection head specifically addresses architecture-specific challenges: PPE part occlusion, where multi-scale feature fusion improves recall for objects under 50 px (e.g., unfastened helmet straps), and adverse lighting compensation, where cross-layer connections enhance low-light feature representations, which improves AP on night-shift test images [27]. The integration of the 160 \(\times\) 160 detection layer introduces additional computational overhead, which warrants further discussion. While this architectural modification enhances the model's capability in detecting small objects, it also increases computational complexity. This is primarily attributed to the sampling operations on the feature map, the cross-scale connection with the P3 layer, and the enhancement of the convolutional block. Moreover, due to the expansion of the feature cache required for backpropagation and the additional gradient computation graph, VRAM consumption at a resolution of 640 \(\times\) 640 increases significantly. The newly added prediction layer has a size of 160 \(\times\) 160, creating a total of four prediction scales: 80 \(\times\) 80, 40 \(\times\) 40, 20 \(\times\) 20, and 160 \(\times\) 160. In the original model, there are nine cluster anchors. After the addition of the new prediction layer, the model now uses 12 cluster anchors, which are allocated according to the detection scale of the feature map, as detailed in Table 2. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multicolumn{1}{c}{**Classes**} & \multicolumn{3}{c}{**More Information**} \\
**Feature Map** & **20 \(\times\) 20** & **40 \(\times\) 40** & **80 \(\times\) 80** & **160 \(\times\) 160** \\ \hline Receptive field & Large & Middle & Small & Minimum \\ \hline \multirow{3}{*}{Anchor box} & (116,90) & (30,61) & (10,13) & (5,7) \\  & (156,198) & (62,45) & (16,30) & (9,13) \\ \cline{1-1}  & (73,326) & (59,119) & (33,23) & (11,15) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Feature map detection scale allocation. In summary, to address the limitations of the original model, the YOLOv5s architecture is enhanced by optimizing the loss function, incorporating the CA mechanism, and adding a new detection layer for small targets.