# Study on Few-Shot Object Detection Approach Based on Improved RPN and Feature Aggregation
## 3 Definitions and Improved Network Framework
### Basic Network Framework  
This paper proposes a few-shot object detection algorithm based on improved RPN and feature aggregation (IFA-FSOD). We use the classical two-stage object detector Faster R-CNN as the basic detection framework, which includes a backbone network [27], a region proposal network (RPN), and R-CNN (RoI Pooling and Full Connected (FC) layers). As shown in Figure 1, the backbone network is used to extract features from preprocessed images, and RPN utilizes anchor boxes to transform these features into a set of high-quality, category-independent region proposals. Finally, the R-CNN classifier and regressor output category scores and bounding box coordinates, respectively.  
In the structure of Faster R-CNN, traditional Faster R-CNN detectors perform poorly in FSOD due to the need for a large amount of annotated sample data. Therefore, we propose a new few-shot object detection framework (IFA-FSOD) based on Faster R-CNN.  
As shown in Figure 2, the framework mainly consists of a feature extractor, an improved RPN, RoI Align, and a newly added feature aggregation module. We chose RestNet-101 [26] as the backbone network for the feature extraction of images. For querying images, we directly use RestNet-101 for feature extraction. For supporting images, first enlarge the target area in the image, then crop the target area and adjust the cropped image to the same size. Next, the processed image is input into a shared feature backbone network to extract features that support the image. In the process of generating proposal features, the original RPN [8] was improved. Traditional RPN mainly distinguishes foreground and background through simple linear or nonlinear classifiers. We introduce a metric learning-based nonlinear classifier to better calculate the similarity between extracted features and new class features, making similar features closer in the image space. After RoI Align, a feature aggregation module is introduced to obtain more comprehensive feature information. This module effectively aggregates features generated by RoI pooling of different scales. We still use a two-stage detection structure, similar to Faster R-CNN. The total loss \(L\) of the IFA-FSOD model consists of loss \(L_{RPN}\) and loss \(L_{R-CNN}\), as shown in Formula (1).  
\[L=\lambda L_{RPN}+(1-\lambda)L_{R-CNN} \tag{1}\]  
where \(\lambda\) is a hyperparameter used to balance the losses of the \(RPN\) and \(R-CNN\) parts. Parameter \(\lambda\) has an impact on model performance. (1) Balance different loss items: In target detection, the loss function usually consists of several parts, such as classification loss, boundary box regression loss, etc. These loss items may have different orders of magnitude and importance. By introducing the weighting parameter \(\lambda\), these loss items  
Figure 1: The basic detection framework of Faster R-CNN structure.  
can be weighted to balance their contribution to the total loss, so that the model can pay more attention to the performance of different aspects in the training process. (2) Improve model generalization. Reasonable \(\lambda\) value selection can help the model to better generalize to unseen data. When a loss item accounts for a large proportion of the total loss, the model may pay too much attention to the loss item, resulting in good performance on a specific task, but the generalization ability on datasets will decline. By adjusting the \(\lambda\) value, the model can achieve a better balance on multiple tasks or datasets, so as to improve the generalization ability.