# RS-YOLOX: A High-Precision Detector for Object Detection in Satellite Remote Sensing Images
## 3 Proposed Methods
### Varifocal Loss Function (VFL)  
The YOLOX model divides the loss function into classification loss, regression loss, and confidence loss, and the total loss function is the sum of the three. YOLOX uses the BCE function to calculate the classification loss and the confidence loss of the objects, using IoU or GIoU as the loss for prediction boxes regression. To solve the problem of unbalanced samples in satellite remote sensing images, this article replaces the BCE function with the VFL function [39]. VFL is an optimization of Focal Loss [41], and Focal Loss is an optimization of BCE. The loss function of BCE is as follows:  
\[\text{BCE}=-\log(\text{P}_{\text{t}})=\begin{cases}-\log(\hat{y}),&\text{y}=1 \\ -\log(1-\hat{y}),&\text{y}=0\end{cases} \tag{4}\]  
In the above formula, \(y=1\) represents a positive sample and \(y=0\) represents a negative sample. As a classic loss function, BCE is widely used in classification and detection tasks, but it does not suppress the number of negative samples and so cannot solve the problem of serious imbalance between positive and negative samples.  
Focal Loss improves BCE, and its calculation formula is as follows:  
\[\text{FL}=-\alpha_{\text{t}}(1-\text{P}_{\text{t}})^{\gamma}\log(\text{P}_{ \text{t}})=\left\{\begin{array}{ll}-\alpha(1-\hat{y})^{\gamma}\log\hat{y},& \text{y}=1\\ -(1-\alpha)\hat{y}^{\gamma}\log(1-\hat{y}),&\text{y}=0\end{array}\right. \tag{5}\]  
\(\alpha\) is used to adjust the weight of positive and negative samples, and \((1-\text{Pt})^{\gamma}\) is used to reduce the influence of bad samples. The so-called bad samples refer to samples that are too easy to judge. If the sample is too easy to detect, its \(\text{P}_{\text{t}}\) value will be high. VFL uses 1 to subtract this Pt value, thereby reducing the weight of the sample and the model's attention to sample detection. Thus, the model pays more attention to learning those samples that are difficult to detect.  
On the basis of Focal Loss, Varifocal Loss proposes an asymmetric weighting operation, and its calculation formula is as follows:  
\[\text{VFL}=\left\{\begin{array}{ll}-\text{q}(\text{q}\log(\hat{y})+(1-\text{ q})\log(1-\hat{y}))&\text{q}>0\\ -\text{\text{\  
The large-size image to be detected is divided into several parts P\({}_{1}\), P\({}_{2}\),..., P\({}_{\rm I}\). The aspect ratio is maintained, and the size of each slice is adjusted. Then, each slice is put into the model for detection. The model detects the objects that exist in each slice and combines the detection results into a complete image. The method of merging the detection results of the sliced pictures is to map the position coordinates of the targets in all the sliced pictures to the original picture, so that the detection result of a complete large picture can be obtained. Finally, the Non-Maximum Suppression (NMS) algorithm is used to the removed duplicate prediction boxes.  
Object detection implementations in the SAHI framework can use any object detection algorithm. To subtly realize the object detection of high-resolution images, the framework uses image slicing and largely avoids the problem of missed detection and false detection of small targets in large-sized images. In practical applications, to avoid cutting off objects in the image, we performed overlapping cuts on the original image, and the duplicate detection frames obtained by mapping the target coordinates back to the original image could be filtered out in subsequent NMS processing. Satellite remote sensing images are usually high-resolution images, so SAHI is suitable for remote sensing image detection.