## 3 Proposed Method
### Loss Function  
The improved YOLOV9 included a three-layer routing attention mechanism, including region routing, token routing, and global routing, aiming to achieve optimal recognition and detection capability under fog, rain, snow, and normal weather conditions. To adapt to image features under different weather conditions, IDP-YOLOV9 adopted a comprehensive loss function during training, which included detection loss and routing attention loss, to enhance the model's adaptability to different weather conditions. The entire network was trained end-to-end under the improved YOLOV9 detection loss to ensure mutual adaptation between internal modules of IDP-YOLOV9. To further address potential domain shifts introduced by synthetic data, IDP-YOLOV9 combined mixed training using real datasets to make the model closer to real-world environments, thus improving the model's robustness under adverse weather conditions. The overall loss function consisted of the detection loss derived from YOLOV9 and the routing attention loss across different layers, forming a composite measure. In addition to detection and routing attention losses, an IoU loss function was introduced to measure the overlap between predicted bounding boxes and ground truth bounding boxes. The incorporation of the IoU loss function enabled the model to predict the position and shape of objects more accurately, thereby improving the accuracy of object detection. The parameters of the routing attention loss layer and the parameters in the IoU loss function were dynamically adjusted based on the processing results of different weather factors by the TRA module. By associating the scale factor ratio with feature parameters, the scale factor ratio could be adjusted to a smaller value when the density of raindrops or snowflakes increased, ensuring that the bounding boxes more accurately captured the target object. Based on the characteristics of rainy and snowy days, the calculation of intersection and union was adjusted by a blur factor. Due to the influence of weather, the object boundaries could be more blurred, so relaxing the definition of intersection enabled better adaptation to these situations. We could reflect the importance of different weather conditions by adjusting the weight parameters in the loss function. When it was rainy or snowy, \(\lambda_{region}\) and \(\lambda_{token}\) could be adjusted to larger values to pay more attention to the generation and adjustment of bounding boxes. \[inter=\left(min\left(b_{r}^{gt},b_{r}\right)-max\left(b_{l}^{gt},b_{l}\right) \right)*\left(min\left(b_{b}^{gt},b_{b}\right)-max\left(b_{t}^{gt},b_{l}\right) \right)*fuzz \tag{27}\]  
\[union=\left(w^{gt}*h^{gt}\right)*\left(r\right)^{2}+\left(w*h\right)*\left(r \right)^{2}-inter \tag{28}\]  
\[IoU^{inner}=\frac{inter}{union} \tag{29}\]  
\[L_{IoU}=1-IoU^{inner} \tag{30}\]  
In the formulas, \(b_{r}^{gt}\), \(b_{l}^{gt}\), \(b_{b}^{gt}\), and \(b_{t}^{gt}\) represent the right, left, bottom, and top boundaries of the ground truth bounding box, while \(b_{r}\), \(b_{l}\), \(b_{b}\), and \(b_{t}\) represent the right, left,bottom, and top boundaries of the predicted bounding box. \(w^{gt}\) and \(h^{gt}\) denote the width and height of the ground truth bounding box, respectively, and \(w\) and \(h\) represent the width and height of the predicted bounding box. \(r\) denotes the scale factor ratio and \(fuzz\) represents the blur factor. The final total loss function can be expressed as follows:  
\[L_{total}=L_{det}+\lambda_{region}\cdot L_{region}+\lambda_{token}\cdot L_{token }+\lambda_{global}\cdot L_{global}+\lambda_{\text{IoU}}\cdot L_{\text{IoU}} \tag{31}\]  
Here, \(L_{det}\) represents the YOLOV9 detection loss and \(L_{region}\), \(L_{token}\), and \(L_{global}\) represent the losses of the region, token, and global routing layers, respectively. Hyperparameters \(\lambda_{region}\), \(\lambda_{token}\), \(\lambda_{global}\), and \(\lambda_{\text{IoU}}\) were used to adjust the weights of their respective losses and balance their effects.