Computer Science
Computer Science-2021.gz:143454
Computer Science
51353003eff2f93e820bcbe9fab33c5ad596fa31
Localize to Classify and Classify to Localize: Mutual Guidance in Object Detection

Most deep learning object detectors are based on the anchor mechanism and resort to the Intersection over Union (IoU) between predefined anchor boxes and ground truth boxes to evaluate the matching quality between anchors and objects. In this paper, we question this use of IoU and propose a new anchor matching criterion guided, during the training phase, by the optimization of both the localization and the classification tasks: the predictions related to one task are used to dynamically assign sample anchors and improve the model on the other task, and vice versa. Despite the simplicity of the proposed method, our experiments with different state-of-the-art deep learning architectures on PASCAL VOC and MS COCO datasets demonstrate the effectiveness and generality of our Mutual Guidance strategy.


Introduction
Supervised object detection is a popular task in computer vision that aims at localizing objects through bounding boxes and assigning each of them to a predefined class. Deep learning-based methods largely dominate this research field and most recent methods are based on the anchor mechanism [1,2,3,4,5,6,7,8,9,10,11,12]. Anchors are predefined reference boxes of different sizes and aspect ratios uniformly stacked over the whole image. They help the network to handle object scale and shape variations by converting the object detection problem into an anchor-wise bounding box regression and classification problem. Most stateof-the-art anchor-based object detectors resort to the Intersection over Union (IoU) between the predefined anchor boxes and the ground truth boxes (called IoU anchor in the following) to assign the sample anchors to an object (positive anchors) or a background (negative anchors) category. These assigned anchors are then used to minimize the bounding box regression and classification losses during training.
This IoU anchor -based anchor matching criterion is reasonable under the assumption that anchor boxes with high IoU anchor are appropriate for localization and classification. However, in reality, the IoU anchor is insensitive to objects' content/context, thus not "optimal" to be used, as such, for anchor matching. In Figure 1, we show several examples where IoU anchor does not well reflect the matching quality between anchors and objects: anchors A and anchors B have exactly the same IoU anchor but possess very different matching qualities. For example, on the first line of Figure 1, anchors A covers a more representative and informative part of the object than anchors B; On the second line, anchors B contains parts of a nearby object which hinders the prediction on the jockey/left person.
Deep learning-based object detection involves two sub-tasks: instance localization and classification. Predictions for these two tasks tell us "where" and "what" objects are on the image respectively. During the training phase, both tasks are jointly optimized by gradient descent, but the static anchor matching strategy does not explicitly benefit from the joint resolution of the two tasks, which may then yield to a task-misalignment problem, i.e., during the evaluation phase, the model might generate predictions with correct classification but imprecisely localized bounding boxes as well as predictions with precise localization but wrong classification. Both predictions significantly reduce the overall detection quality.
To address these two limitations of the existing IoU anchor -based strategy, we propose a new, adaptive anchor matching criterion guided by the localization and by the classification tasks mutually, i.e., resorting to the bounding box regression prediction, we dynamically assign training anchor samples for optimizing classification and vice versa. In particular, we constrain anchors that are well-localized to also be well-classified (Localize to Classify), and those well-classified to also be well-localized (Classify to Localize). These strategies lead to a content/contextsensitive anchor matching and avoid the task-misalignment problem. Despite the simplicity of the proposed strategy, Mutual Guidance brings consistent Average Precision (AP) gains over the traditional static strategy with different deep learn-ing architectures on PASCAL VOC [13] and MS COCO [14] datasets, especially on strict metrics such as AP75. Our method is expected to be more efficient on applications that require a precise instance localization, e.g., autonomous driving, robotics, outdoor video surveillance, etc.
The rest of this paper is organized as follows: in Section 2, we discuss some representative related work in object detection. Section 3 provides implementation details of the proposed Mutual Guidance. Section 4 compares our dynamic anchor matching criterion to the traditional static criterion with different deep learning architectures on different public object detection datasets, and discusses reasons for the precision improvements. Section 5 brings concluding remarks.

Related work
Modern CNN-based object detection methods can be divided into two major categories: two-stage detectors and single-stage ones. Both categories give similar performance with a small edge in accuracy for the former and in efficiency for the latter. Besides, both categories of detectors are massively based on the anchor mechanism which usually resorts to IoU anchor for evaluating the matching quality between anchors and objects when assigning training labels and computing the bounding box regression and classification losses for a training example. Our method aims to improve this anchor matching criterion.

Anchor-based object detection
Two-stage object detectors. Faster RCNN [1] defines the generic paradigm for two-stage object detectors: it first generates a sparse set of Regions of Interest (RoIs) with a Region Proposal Network (RPN), then classifies these regions and refines their bounding boxes. The RoIs are generated by the anchor mechanism. Multiple improvements have been proposed based on this framework: R-FCN [2] suggests position-sensitive score maps to share almost all computations on the entire image; FPN [3] uses a top-down architecture and lateral connections to build high-level semantic feature maps at all scales; PANet [4] enhances the multi-scale feature fusion by adding bottom-up path augmentation to introduce accurate localization signals in lower layers; Libra RCNN [5] proposes the Balanced Feature Pyramid to further integrate multi-scale information into FPN; TridentNet [15] constructs a parallel multi-branch architecture and adopts a scale-aware training scheme for training object scale specialized detection branches. Cascade RCNN [6] further extends the two-stage paradigm into a multi-stage paradigm, where a sequence of detectors are trained stage by stage.
Single-stage object detectors. SSD [7] and YOLO [16] are the fundamental methods for single-stage object detection. From this basis, many other works have been proposed: FSSD [10] aggregates contextual information into the detector by concatenating features of different scales; RetinaNet [9] proposes the Focal Loss to tackle the imbalanced classification problem that arises when trying to  separate the actual object to detect from the massive background; RFBNet [11] proposes Receptive Field Block, which takes the relationship between the size and the eccentricity of the reception fields into account; RefineDet [17] introduces an additional stage of refinement for anchor boxes; M2Det [12] stacks multiple thinned U-shape modules to tackle the so-called appearance-complexity variations. While these methods introduce novel architectures to improve results for the object detection task, they all rely on the standard IoU anchor -based matching. We identify this component as a possible limitation and propose a novel matching criterion, that could be adapted to any existing deep architecture for object detection.

Anchor-free object detection
The idea of anchor-free object detection consists in detecting objects not from predefined anchors boxes, but directly from particular key-points [18,19,20,21] or object centres [22,23,24,25]. However, these methods do not lead to a substantial accuracy advantage compared to anchor-based methods. The main idea of our Mutual Guidance could also be applied to this class of object detectors, and the experimental results with anchor-free detectors are included in the supplementary material.

Approach
As already sketched in the introduction, in order to train an anchor-based object detector, the predefined anchors should be assigned as positive ("it is a true object") or negative ("it is a part of the background") according to an evaluation of the matching between the anchors and the ground truth objects. Then, the bounding box regression loss is optimized according to the positive anchors, and the instance classification loss is optimized according to the positive as well as the negative anchors. When training an anchor-based single-stage object detector with a static anchor matching strategy, the IoU between predefined anchor boxes and ground truth boxes (IoU anchor ) is the usual matching criterion. As shown in the IoU anchor column of Figure 2, anchors with more than 50% of IoU anchor are labelled as "positive", those with less than 40% of IoU anchor are labelled as "negative", the rest are "ignored anchors". Note that at least one anchor should be assigned as positive, hence if there is no anchor with more than 50% of IoU anchor , the anchor with the highest IoU anchor is considered.
The proposed Mutual Guidance consists of two components: Localize to Classify and Classify to Localize.

Localize to Classify
If an anchor is capable to precisely localize an object, this anchor must cover a good part of the semantically important area of this object and thus could be considered as an appropriate positive sample for classification. Drawing on this, we propose to leverage the IoU between regressed bounding boxes (i.e., the network's localization predictions) and ground truth boxes (noted IoU regressed ) to better assign the anchor labels for classification. Inspired by the usual IoU anchor , we compare IoU regressed to some given thresholds (discussed in the next paragraph) and then define anchors with IoU regressed greater than a high threshold as positive samples, and those with IoU regressed lower than a low threshold as negative samples (see IoU regressed column of Figure 2).
We now discuss a dynamic solution to set the thresholds. A fixed threshold (e.g., 50% or 40%) does not seem optimal since the network's localization ability gradually improves during the training procedure and so does the IoU regressed for each anchor, leading to the assignment of more and more positive anchors which destabilizes the training. To address this issue, we propose a dynamic thresholding strategy. Even though the IoU anchor is not the best choice to accurately indicate the matching quality between anchors and objects, the number of assigned positive and ignored anchors does reflect the global matching conditions (brought by the size and the aspect ratio of the objects to detect), thus these numbers could be considered as reference values for our dynamic criterion. As illustrated in Figure 2, while applying the IoU anchor -based anchor matching strategy with the thresholds being 50% and 40%, the number of positive anchors (N p ) and ignored anchors (N i ) are noted (N p = 6 and N i = 3 for the boat). We then use these numbers to label the N p highest IoU regressed anchors as positive, and the following N i anchors as ignored. More formally, we exploit the N p -th largest IoU regressed as our positive anchor threshold, and the (N p +N i )-th largest IoU regressed as our ignored anchor threshold. Using this, our Localize to Classify anchor matching strategy evolves with the network's localization capacity and maintains a consistent number of anchor samples assigned to both categories (positive/negative) during the whole training procedure.

Classify to localize
As with the Localize to Classify process, the positive anchor samples in Classify to Localize are assigned according to the network's classification predictions (noted Classif score). Specifically, Classif score is the predicted classification score for the object category, e.g., the Classif score of Figure 2 indicates the classification score for the boat category.
Nevertheless, this Classif score is not effective enough to be used directly for assigning good positive anchors for the bounding box regression optimization. It is especially true at the beginning of the training process, when the network's weights are almost random values and all predicted classification scores are close to zero. The IoU regressed is optimized on the basis of the IoU anchor , therefore we have IoU regressed ≥ IoU anchor in most cases (even at the beginning of the training), and this property helps to avoid such cold start problem and ensures training stability. Symmetrically to the Localize to Classify strategy, we now propose a Classify to Localize strategy based on an IoU amplif ied defined as: where σ is a hyper-parameter aiming at adjusting the degree of amplification, p represents the mentioned Classif score. Inspired by the focal loss [9], we chose eq. 1 as the simplest one able to amplify the IoU of anchors according to the correct classification predictions p. Its behavior is shown in Figure 3. The IoU amplif ied is always higher than the IoU anchor , and the amplification is proportional to the predicted Classif score. In particular, the amplification is stronger for smaller σ (note that σ should be larger than 1), and disappears when σ becomes large. Similarly to the Localize to Classify strategy, we apply a dynamic thresholding strategy to keep the number of assigned positive samples for the localization task and for the classification task consistent, e.g., we assign in Figure 2, the top 6 anchors with the highest IoU amplif ied as positive samples. Note that there is no need for selecting ignored or negative anchors for the localization task since the background does not have an associated ground truth box.
As discussed in Section 1, IoU anchor is not sensitive to the content or the context of an object. Our proposed Localize to Classify and Classify to Localize, however, attempt to adaptively label the anchor samples according to their visual content and context information. Considering anchor F and anchor H in Figure 2, one can tell that anchor H is better than anchor F for recognizing this boat, even with a smaller IoU anchor . Using both our strategies, anchor H has been promoted to positive thanks to its excellent prediction quality on both tasks whereas anchor F has been labelled as negative even though it has a large IoU anchor .

About the task-misalignment problem
Since Localize to Classify and Classify to Localize are independent strategies, they could possibly assign contradictory positive/negative labels (e.g, the anchor C in Figure 2 is labelled negative for the classification task but positive for the bounding box regression task). This happens when one anchor entails a good prediction on one task and a poor prediction on the other (i.e. they are misaligned predictions). Dealing with such contradictory labels, as we do with Mutual Guidance, does not harm the training process. On the contrary, our method tackles the task-misalignment problem since the labels for one task are assigned according to the prediction quality on the other task, and vice versa. This mechanism forces the network to generate aligned predictions: if the classification prediction from one anchor is good while its localization prediction is bad, the Mutual Guidance will give a positive label on the localization task to this anchor, to constrain it to be better at localizing as well while giving a negative label (i.e. background) on the classification task to avoid misaligned predictions. In fact, the predicted classification score of this mislocalized anchor should be low enough for the anchor to be suppressed by the NMS procedure in the inference phase. The same reasoning holds for a good localization prediction with a bad classification one.
On the contrary, if a network always assigns similar positive/negative labels (as done in standard IoU anchor -based methods) to both tasks during training, one cannot guarantee that there will be no misalignment of the localization and the classification predictions at inference time. Keeping anchors (after NMS) with misaligned predictions is harmful for strict evaluation metrics such as AP75.

Experimental Setting
Network architecture and parameters. In order to test the generalization performance of the proposed method, we implement our method on the single-stage object detectors FSSD [10], RetinaNet [9] and RFBNet [11] using both ResNet-18 [26] or VGG-16 [27] as backbone networks in our experiments. Note that RFBNet is not implemented with ResNet-18 as backbone since the two architectures are not compatible. The backbone networks are pre-trained on ImageNet-1k classification dataset [28]. We adopt the Focal Loss [9] and Balanced L1 Loss [5] as our instance classification and bounding box regression loss functions respectively for all experiments. The input image resolution is fixed to 320 × 320 pixels for all experiments (single scale training and evaluation). Unless specified, all other implementation details are the same as in [11]. Following the results of Figure 3, we decided to fix our only new hyper-parameter σ to 2 for all experiments. σ is used to set the degree of amplification when computing IoU amplif ied in Eq. (1). It needs to be greater than 1 for the exponent to be positive and lower than 3 since this does not bring any amplification as shown in Figure 3.
Datasets and evaluation metrics. Extensive experiments are performed on two benchmark datasets: PASCAL VOC [13] and MS COCO [14]. PASCAL VOC dataset has 20 object categories. Similarly to previous works, we utilize the combination of VOC2007 and VOC2012 trainval sets for training, and rely on the VOC2007 test for evaluation. MS COCO dataset contains 80 classes. Our experiments on this dataset are conducted on the train2017 and val2017 set for training and evaluation respectively. For all datasets, we use the evaluation metrics introduced in the MS COCO benchmark: the Average Precision (AP) averaged over 10 IoU thresholds from 0.5 to 0.95, but also AP50, AP75, AP s , AP m , AP l . AP50 and AP75 measure the average precision for a given IoU threshold (50% and 75%, respectively). The last three aim at focusing on small (area < 32 2 ), medium (32 2 < area < 96 2 ) and large (area > 96 2 ) objects respectively. Since the size of the objects greatly varies between MS COCO and PASCAL VOC, these size-dependent measures are ignored when experimenting with PASCAL VOC dataset.

Results
Experiments on PASCAL VOC. We evaluate the effectiveness of both components (Localize to Classify and Classify to Localize) of our proposed approach w.r.t. the usual IoU anchor -based matching strategy when applied on the same deep learning architectures. The results obtained on the PASCAL VOC dataset are given in Table 1. Both proposed anchor matching strategies consistently boost the performance of the "vanilla" networks and their combination (Mutual Guidance) leads to the best AP and all other evaluation metrics.
In particular, we observe that the improvements are small on AP50 (around 0.5%) but significant on AP75 (around 3%), which means that we obtain more precise detections. As analysed in Section 3.3, this comes from the task-misalignment problem faced with the usual static anchor matching methods. This issue leads to retain well-classified but poorly-localized predictions and suppress well-localized but poorly-classified predictions, which in turns results in a significant drop of the AP score at strict IoU thresholds, e.g., AP75. In Mutual Guidance, however, training labels for one task are dynamically assigned according to the prediction quality on the other task and vice versa. This connection makes the classification and localization tasks consistent along all training phases and as such avoids this task-misalignment problem. We also notice that Localize to Classify alone brings, for all five architectures, a higher improvement than Classify to Localize alone. We hypothesize two possible reasons for this: 1) most object detection errors come from wrong classification instead of imprecise localization, so the classification task is more difficult than the localization task and thus, there is more room for the improvement on this task; 2) the amplification proposed in Eq. (1) may not be the most appropriate one to take advantage of the classification task for optimizing the bounding box regression task.
Experiments on MS COCO. We then conduct experiments on the more difficult MS COCO [14] dataset and report our results in Table 2. Note that according to the scale range defined by MS COCO, APs of small, medium and large objects are listed. In this dataset also, our Mutual Guidance strategy consistently brings some performance gains compared to the IoU anchor -based baselines. We notice that our AP gains on large objects is significant (around 2%). This is because larger objects generally have more matched positive anchors, which offers more room for improvements to our method. Since the Mutual guidance strategy only involves the training phase, and since there is no difference between IoU anchor -  Table 2. AP performance of different architectures for object detection on MS COCO dataset using 2 different anchor matching strategies: the usual IoU anchor -based one and our complete approach marked as Mutual Guidance. The best score for each architecture is in bold.
based and our method during the evaluation phase, these improvements can be considered cost-free.

Qualitative analysis
Label assignment visualization. Here, we would like to explore the reasons for the performance improvements by visualizing the difference in the label assignment between the IoU anchor -based strategy and the Mutual Guidance strategy during training. Some examples are shown in Figure 4. White dotted-line boxes represent ground truth boxes; Red anchor boxes are assigned as positive by IoU anchor -based strategy, while considered as negative or ignored by Localize to Classify (the top two lines in Figure 4) or Classify to Localize (the bottom two lines in Figure 4); Green anchor boxes are assigned as positive by Localize to Classify but negative or ignored by IoU anchor -based; Yellow anchor boxes are assigned as positive by Classify to Localize but negative or ignored by IoU anchorbased. From these examples, we can conclude that the IoU anchor -based strategy only assigns the "positive" label to anchors with sufficient IoU with the ground truth box, regardless of their content/context, whereas our proposed Localize to Classify and Localize to Classify strategies dynamically assign "positive" labels to anchors covering semantic discriminant parts of the object (e.g., upper body of a person, main body of animals), and assign "negative" labels to anchors with complex background, occluded parts, or anchors containing nearby objects. We believe that our proposed instance-adaptive strategies make the label assignment more reasonable, which is the main reason for performance increase.
Detection results visualization. Figure 5 illustrates on a few images from the PASCAL VOC dataset the different behaviours shown by our Mutual Guidance method and the baseline anchor matching strategy. As analysed in Section 3.3, Fig. 4. Visualization of the difference in the label assignment during training phase (images are resized to 320 × 320 pixels). Red, yellow and green anchor boxes are positive anchors assigned by IoU anchor -based, Localize to Classify and Classify to Localize respectively. Zoom in to see details.
we can find misaligned predictions (good at classification but poor at localization) from IoU anchor -based anchor matching strategy. As shown in the figure, our method gives better results when different objects are close to each other in the image, e.g. "man riding a horse" or "man riding a bike". With the usual IoU anchor -based anchor matching strategy, the instance localization and classification tasks are optimized independently of each other. Hence, it is possible that, during the evaluation phase, the classification prediction relies on one object whereas the bounding box regression targets the other object. However, such a problem is rarer with the Mutual Guidance strategy. Apparently, our anchor matching strategies introduce interactions between both tasks and makes the predictions of localization and classification aligned, which substantially eliminated such false positive predictions.

Conclusion
In this paper, we question the use of the IoU between predefined anchor boxes and ground truth boxes as a good criterion for anchor matching in object detection and study the interdependence of the two sub-tasks (i.e. localization and classification) involved in the detection process. We propose a Mutual Guidance Fig. 5. Examples of detection results using an IoU anchor -based anchor matching strategy (odd lines) and our proposed Mutual Guidance one (even lines). The results are given for all images after applying a Non-Maximum Suppression process with a IoU threshold of 50%. Zoom in to see details.

Mutual guidance
mechanism, which provides an adaptive matching between anchors and objects by assigning anchor labels for one task according to the prediction quality on the other task and vice versa. We assess our method on different architectures and different public datasets and compare it with the traditional static anchor matching strategy. Reported results show the effectiveness and generality of this Mutual Guidance mechanism in object detection.
Abstract. The principle of Mutual Guidance in object detection is to assign labels of one task according to the prediction on the other task, and vice versa. Apparently, it is not limited to anchor-based methods, but applicable for any object detector that performs localization and classification tasks. Here we introduce the application of Mutual Guidance in anchor-free methods. Experiments conducted on PASCAL VOC dataset demonstrate the consistent precision improvements brought by our method on this category of detectors.

Summary of Mutual Guidance
In order to realize a content/context-sensitive label assignment and avoid the task-misalignment problem, we propose the Mutual Guidance mechanism in object detection, which can be summarised as follows: -When assigning labels for the classification task: • If the prediction of localization is good, the label is assigned as positive (i.e., "object") to encourage good predictions on both tasks; • If the prediction of localization is poor, the label is assigned as negative (i.e., "background") to avoid misaligned false positive detection; -When assigning labels for the localization task: • If the prediction of classification is good, the label is assigned as positive (i.e., we optimize this sample) to encourage good predictions on both tasks; • If the prediction of classification is poor, the label is assigned as negative (i.e., we do not optimize this sample) to avoid unnecessary optimizations.

Applying Mutual Guidance to FCOS
Fully Convolutional One-Stage Object Detection (FCOS) [24] is one of the most representative anchor-free methods, which solves object detection in a per-pixel prediction fashion. On each pixel of feature maps, it classifies the category of this sample point and regresses the four distances to the target bounding box borders. When assigning training labels in FCOS, firstly the corresponding detection layer is selected according to the scale of the object to detect, then positive samples (for both localization and classification tasks) are assigned to all the points inside the ground truth box. Based on that, [?] proposes to only sample the points in the central region of the ground truth box.
When applying Mutual Guidance to FCOS, identical to the implementation in anchor-based methods, two strategies are applied: Localize to Classify and Classify to Localize. Moreover, the same dynamic thresholding strategy is applied. Specifically, for Localize to Classify, we firstly note the number of positive samples assigned by the original strategy (N p ), then label the N p highest IoU regressed points as positive; for Classify to Localize, we amplify each point's centerness score according to its classification prediction, and label the N p highest amplified centerness score points as positive.
Experiments are performed on the PASCAL VOC dataset. ResNet-18 [26] and VGG-16 [27] are adopted as backbone networks in our experiments. Unless specified, all other implementation details are the same as in our paper. Experimental results are listed in Table 1. Same as with anchor-based methods, our Mutual Guidance strategy significantly boosts the detection precision for FCOS, especially on the AP75 metric.
We then conduct qualitative analysis on the label assignment difference and detection result difference between the original FCOS strategy and Mutual Guidance. As shown in Figure 1, the original strategy (red points) assigns positive to points in the central region of the object box regardless of their content/context, whereas the Localize to Classify (yellow points) and Classify to Localize (green points) strategies adaptively assign positive to points with representative semantic information, and assign negative to points on background or nearby objects. Since the labels assigned by the original FCOS strategy are always the same for localization and classification tasks, the task-misalignment problem exists in FCOS as well. Several misaligned false positive detections are observed in Figure  2, however, the proposed Mutual Guidance provides more accurate detection. Fig. 1. Visualization of the difference in the label assignment during training phase (images are resized to 320×320 pixels). The ground truth object in each image is marked by white dotted-line box. Red, yellow and green points are positive samples assigned by original FCOS strategy, Localize to Classify and Classify to Localize respectively. Zoom in to see details.

Mutual guidance
Original strategy Mutual guidance Fig. 2. Examples of detection results using the original FCOS label assignment strategy (odd lines) and our proposed Mutual Guidance one (even lines). The results are given for all images after applying a Non-Maximum Suppression process with a IoU threshold of 50%. Zoom in to see details.