{'fraction_non_alphanumeric': 0.028985931147445083, 'fraction_numerical': 0.013454619906987628, 'mean_word_length': 4.744287634408602, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
TSAA: A Two-Stage Anchor Assignment Method towards Anchor Drift in Crowded Object Detection

Among current anchor-based detectors, a positive anchor box will be intuitively assigned to the object that overlaps it the most. The assigned label to each anchor will directly determine the optimization direction of the corresponding prediction box, including the direction of box regression and category prediction. In our practice of crowded object detection, however, the results show that a positive anchor does not always regress toward the object that overlaps it the most when multiple objects overlap. We name it anchor drift. The anchor drift reflects that the anchor-object matching relation, which is determined by the degree of overlap between anchors and objects, is not always optimal. Conflicts between the fixed matching relation and learned experience in the past training process may cause ambiguous predictions and thus raise the false-positive rate. In this paper, a simple but efficient adaptive two-stage anchor assignment (TSAA) method is proposed. It utilizes the final prediction boxes rather than the fixed anchors to calculate the overlap degree with objects to determine which object to regress for each anchor. The participation of the prediction box makes the anchor-object assignment mechanism adaptive. Extensive experiments are conducted on three classic detectors RetinaNet, Faster-RCNN and YOLOv3 on CrowdHuman and COCO to evaluate the effectiveness of TSAA. The results show that TSAA can significantly improve the detectors' performance without additional computational costs or network structure changes.


Introduction
Object detection is an essential task in computer vision. As one of the most common methods, anchor-based models have achieved state-of-the-art (SOTA) performance in many branch research fields such as crowded object detection [38,13,42], remote sensing target detection [37,22], small target detection [15,24,32,19], pedestrian detection [40,3,9,33,41,4], etc. In anchor-based networks, dense anchor boxes paved across the feature maps ensure that the objects with random locations, shapes, and scales can be captured by the detector as much as possible. In classic anchor-based methods, such as Faster RCNN [28], YOLO  [25,26,27,34,1], SSD [21], and RetinaNet [17], anchor boxes are firstly judged as positive or negative samples, then the positive ones are uniquely assigned to one of the objects. This matching relationship is defined according to Intersection over Union (IoU) between the preset anchor boxes and object boxes. Once one anchor box matches one unique object, this matching relationship will be kept during optimization.However, whether this fixed but stiff matching relation is optimal for anchor-based detectors has hardly been discussed in previous works.
According to the observation, in crowded scenes, some anchor boxes do not always regress to the objects they are initially assigned to, which is called anchor drift. The anchor drift can confuse the prediction head and will make the prediction boxes incompact. When the objects are sparse, i.e., objects do not overlap others, the prediction head will learn a kind of regression pattern, as shown in Fig1(a) and Fig1(b), the red anchor box will respectively regress to the objects as the green arrow indicated, because there is only one choice for the anchor to regress. However, the situation will be changed when objects become crowded. As shown in Fig1(c), although the anchor box will still be judged as positive when objects A and B overlap, the prediction head will be confused about which object to regress for each anchor? For example, when the anchor box is assigned to object A but the prediction head decides to follow the regression pat-tern learned in Fig1(b), the anchor will drift since the preset optimization target is different from the actual situation. Thus the prediction head will be confused because the optimization forces the anchor to regress to object A, which will conflict with the pattern learned from the situation in Fig1(b). This conflict probably causes the final prediction boxes to neither regress to object A nor to object B precisely and will generate an ambiguous prediction box which will increase the incompactness of prediction boxes.
In this paper, we propose a two-stage anchor assignment (TSAA) method to untie the binding relationship between anchors and objects during the optimization process and give the positive anchors another chance to rematch one of the objects adaptively. It is well known that the predicted coordinate offsets and the anchor boxes are in one-to-one correspondence. Before the prediction output, we integrate the predicted coordinate offsets with the corresponding anchor boxes and restore the prediction boxes into the image coordinate system. Then we calculate the IoU between the prediction boxes and the object boxes and assign the prediction boxes to the objects with the maximum IoU respectively, which means each anchor box is simultaneously assigned to the object it is most likely to match since the anchor boxes and prediction boxes are one-to-one. According to the new matching relationship, we calculate the box coordinate offset targets and define category labels to optimize the networks. The participation of the prediction box makes the anchor-object assignment mechanism adaptive. This adaptive anchor-object reassignment can avoid the conflict shown in Fig1(c) and reduce the ambiguous predictions.
Extensive experiments are conducted on classic anchorbased detectors. The experimental results show that the TSAA method can decrease the Missing Rate on RetinaNet, Faster RCNN with FPN, and YOLOv3 by 4.35%, 0.81%, and 0.19% on CrowdHuman [30], respectively, which means the TSAA can effectively suppress the false-positive predictions. The contributions can be summarized as follows: • The anchor drift phenomenon, which can increase the false-positive rate of anchor-based detectors in crowded scenes, is discovered and introduced. • A two-stage anchor assignment method is proposed to solve the anchor drift problem. • Extensive experiments are conducted to demonstrate that the TSAA method can effectively solve the anchor drift phenomenon and decrease ambiguous predictions to enhance the compactness of prediction boxes.  [6], RoIAlign [10], PrRoI pooling [14] were proposed to improve RoI pooling process. FPN [16] was proposed to fuse deep and shallow features to improve the object scale variety problem. Similar to the RPN, one-stage detectors pave dense anchor boxes across feature maps and directly output dense predictions based on each anchor box. SSD proposed a onestage framework that utilizes multi-scale feature maps to detect multi-scale objects. RetinaNet proposed a focal loss to make the training process pay more attention to the hard samples. YOLO series utilized the K-means algorithm to count the scales and ratios distribution of target boxes in datasets and found 9 clusters as anchors. [23] proposed an adaptive anchor boxes optimization method AABO, which was based on Bayesian optimization and the Sub-Sample method and could automatically and efficiently search for optimal anchor settings. On account of anchor settings will dramatically influence the performance of detectors, anchor-free detectors have been proposed recently to avoid the negative impact brought by anchors. CornerNet [11] and CenterNet [44] were keypoint-based methods to represent target boxes by corner points and center points, respectively. FCOS [31] utilized multi-scale features to solve the ambiguity when objects overlap each other.

Crowded Object Detection
In general, two reasons make it difficult to detect crowded objects compared with sparse scenes: 1) similar features of highly overlapped instances are indistinguishable from each other; 2) heavily overlapped prediction boxes are easily suppressed during the NMS process. [5] proposed a novel concept that each proposal predicts multiple rather one objects to solve the problem of feature confusion problem. Meanwhile, a set-NMS was proposed to preserve the prediction boxes generated based on the same proposals during the traditional NMS process. [29] followed the iterative scheme to detect a subset of objects at each iteration, and there were no interactions between iterations. [36] introduced a crowded object feature extraction module, which fuses the spatial pyramid and the pixel shuffle module to boost YOLO detectors' distinguishable feature extraction ability. [2,20,43,12] paid attention to the improvements in the NMS process. Soft NMS decreased the confidence score according to overlap degree rather than suppressing heavily overlapped boxes directly as the hard NMS. Adaptive NMS predicted the density of each object and suppresses all boxes whose overlap degree are greater than the density. R 2 NMS predictd the visible boxes and uses that to guide the NMS process since the visible boxes rarely overlap each other. NOH-NMS predictd the relative position information of another object box with the largest overlap based on each prediction box and used the relative information to guide the NMS process. In addition, the bad compactness of prediction boxes will increase the false-positive rate in crowded scenes. [39] proposed an aggregation loss to enforce the proposals located closely and compactly to the ground-truth object. [35] introduced a novel box regression loss named repulsion loss, whose motivation was to make the prediction box attracted by its target and repulsed by other surrounding objects.

Analysis of Anchor Drift
In current anchor-based detectors, anchor boxes are manually defined and fixed. Each anchor box will be judged as positive or negative, and the positive ones will be uniquely assigned to one of the objects. Once the positive anchorobject matching relationship is defined, the optimizer will force the network to satisfy that relationship. This matching relationship is significant because it determines which object each output corresponds to and which object will dominate the feature extraction. In general object detection, i.e., there is rare overlap between objects, it is reasonable that each anchor box should be assigned to the object with the maximum IoU value. However, when the objects become crowded, the situation will be changed.
In the experiment on crowded object detection, we output the IoU values between the prediction boxes that correspond to the same objects during the training process of an anchor-based detector. In expectation,these IoU values should all tend to 1 since their defined regression destinations are the same. However, the actual results are different. Although some anchors are assigned to the same objects, the IoU values between their corresponding prediction boxes are possibly closer to 0 than 1, which means some of these anchors do not regress to the objects they were initially assigned to.AS shown in Fig2, we count the minimum IoU of target-prediction-pair (MITP) in each image during training process and output mean MITP of each epoch. The most loose prediction box in an image can reflect the lower bound of the prediction boxes' compactness. In Fig2 we can see that the most loose prediction box generated by the original RetinaNet may be very far away from its target box. Since the numbers in Fig2 are mean MITP in each epoch, the MITP in certain image can be smaller than the mean values , even tends to 0. The reason that some anchors deviate from the preassigned objects is explained in Fig3. When the objects are sparse and do not overlap others, as shown in Fig3(a), the anchor will naturally regress to the unique object it could choose, as the green arrows indicated. However, when objects become crowded, something conflicting with the pattern in Fig3(a) will happen. As shown in Fig3(b), it is obvi- Figure 3: Causes of Anchor Drift Phenomenon ous that the IoU between the anchor and object B is greater than that between the anchor and object A, so in the way of general anchor assignment method, the anchor will be assigned to object B, and the optimizer will force the anchor to regress to object B, as the green arrows shown. But when A occurs in the position in Fig3(b), this forced optimization will conflict with the regression pattern learned from the situation in Fig3(a). With these conflicts existing, there will be three possible negative results during the training process: 1) if the regression direction is pulled back forcibly to object B, the prediction precision of the objects similar to the Fig3(a) might be impacted. 2) if the detector insists on regressing to object A, the anchor drift will happen. Object B might be ignored if this anchor is the only one assigned to it, which will decrease the Recall rate. 3) if the two forces in 1) and 2) cannot beat each other, the prediction will be ambiguous between object A and object B and not compact, which is the most common in actual. The compactness will influence the Missing Rate, which is sensitive to the false-positive rate.
It is clear that the above three possible bad results are caused by the stiff original anchor-object assignment method, which directly assigns the anchors to the object with which they overlap the most despite the actual location and occlusion relationship of the crowded objects.

Two-stage Anchor Assignment Method
In this section, we propose a simple but effective anchor assignment method to assign the anchor boxes to objects adaptively.
According to the analysis above, the anchor drift is led by the inflexible traditional anchor assignment method, as shown in Fig 4(a). The IoU values between the anchor boxes and object boxes are calculated firstly, and then these anchors are assigned to the objects with the largest IoU uniquely, as the dark yellow arrow labeled with 1 shown in Fig4(a). In the training process, the regression targets will be defined by these matching pairs, as the white arrow labeled with 3 shown in Fig4(a). These anchor boxes are preset manually. The hyper-parameters related to anchor boxes, such as scales and ratios, are always seen as shortcomings of the anchor-based detectors. They will directly determine which object each prediction corresponds to and will natu- rally influence the performance of detectors.
In TSAA, the anchor assignment process is divided into two stages. In the first stage, the IoU values between all anchors and objects are calculated, and each anchor box is judged as positive or negative using a fixed IoU threshold as the generic anchor assignment method: where a is the anchor, a p is the positive anchor, a n is the negative anchor, t is anyone object, and N t is the IoU threshold.
To keep the Recall rate, each object is assigned one positive anchor with the largest IoU value. This process is shown as the green arrow labeled with 1 and the white arrow labeled with 2 in Fig4(b). We name the anchors that have been determined as positive as first-stage positive anchors (FSPA). As we know, each anchor box corresponds to a unique box prediction, so we restore all the prediction offsets whose corresponding anchors belong to the FSPA into the image coordinate and get the corresponding positive predicted boxes: is the prediction offset corresponding to a p , and the x, y, w, h denote the box's center point and its width and height.Different detectors have diverse restore functions since they adopt different training target building methods. For RetinaNet and Faster-RCNN, the restore functions restore are: For YOLOv3, the restore functions are: In In the second stage, we assign these restored positive prediction boxes p B to one of the objects uniquely which have the largest IoU with these positive prediction boxes: where the T = {t 1 , t 2 , ..., t M } is the ground-truth boxes, P B = {p B1 , p B2 , ..., p BN } is the set of positive prediction boxes, iou(P B , T ) outputs a matrix with size N × M containing the IoU value of each (p Bi , t j ) pair: Along each row of I we assign each prediction box to the object which overlaps it the most, as the dark yellow arrow labeled 4 shown in Fig4(b).Since the prediction boxes and anchors are in a one-to-one correspondence, we have also uniquely assigned each positive anchor box to one of the objects. We name these positive anchors which have been assigned to someone object the second-stage positive anchors(SSPA), as the white arrow labeled 5 shown in Fig3(b). Finally, with these object-anchor pairs, we obtain the training target offsets using the inverse operation of the restore function, as the white arrows labeled 6 shown in Fig4(b). In TSAA, we assign each anchor by its corresponding prediction box, which means the network can participate in the assignment process rather than just depending on those manually preset and always-fixed anchors themselves to decide which objects to regress. Therefore, TSAA can avoid the ADP since it can ensure each anchor box directly match the object it will predict finally.
In the original anchor assignment method, to ensure the recall rate, each object will be assigned at least one anchor box with the largest IoU value, even if this largest IoU value is less than the IoU threshold. This mechanism is usually called low-quality-matching. In TSAA, we preserve this mechanism and adopt the original anchors rather than the prediction boxes to conduct the low-quality-matching step. This step is vital in TSAA. At the beginning of the training process, the network is initialized randomly, and the prediction boxes generated by the randomly initialized network are meaningless. If we only adopt the prediction boxes to decide the matching relationship, the network is hard to converge. Since the low-quality-matching relationship is fixed so that it can play the role of the teacher to guide the initial converge direction. In brief, the anchors selected by the low-qualitymatching step are assigned to one of the targets fixedly in the whole training process, and the rest anchors are adaptively assigned according to their corresponding prediction boxes.

Variants toward Two-Stage Detectors
The TSAA can both be integrated into the one-stage and two-stage detectors. However, there is something different between these two types of detectors when adopting the TSAA method. The two-stage detectors contain the RoI pooling, which crops the deep features to extract instance features. The proposal boxes generated by the RPN are crucial and dominate the instance feature extraction. Therefore, we use the proposal (anchor) boxes and their corresponding prediction boxes together to determine which objects each proposal (anchor) box should be assigned: In summary, the TSAA uses the prediction boxes in oneto-one correspondence with the anchor boxes to replace the manually preset anchor boxes in the original anchor assignment process. With the knowledge learned from training history integrated into each anchor box, each anchor box's regression tendency will help them to find the most suitable object to regress. Hence, the conflict between the inflexible original anchor assignment method and the diversity of object distribution will be avoided naturally. The TSAA method is summarized in Algorithm 1.

Dataset and metrics
An ideal anchor-object assignment method should be effective for crowded object detections and robust for generic (multi-class and less-crowded) object detection.
For crowded scenes, we adopt CrowdHuman to evaluate the effectiveness of TSAA. Compared with other datasets, CrowdHuman has much higher crowdedness. It contains 22.64 instances per image as well as 2.40 dense pair-wise (IoU>0.5) instances on average. There are three kinds of annotations in CrowdHuman, i.e., full-body, head, and visible. We only adopt full-body annotations. For general scenes, we adopt COCO [18], which is the most convincing large-scale dataset in object detection. COCO contains 80 categories of instances and 9.34 instances per image on average. Using these two datasets, we can evaluate the TSAA in two kinds of extreme object distributions and demonstrate its robustness comprehensively.
We take the following three criteria as metrics to evaluate our method: AP(Average Precision) is the most common metric in object detection, reflecting both the recall and precision ratios JI(Jaccard Index) evaluates how much the prediction box set overlaps the ground truth box set. In crowded object detection, JI is usually used to indicate the counting ability of a detector. A larger JI means better performance.

Detectors and Detailed Settings
We select three classic anchor-based detectors, whose anchor assignment methods are not exactly the same as each other, to cover as comprehensive anchor assignment methods as possible.
RetinaNet is a classic one-stage anchor-based detector. It judges an anchor as positive or negative by two fixed IoU thresholds, i.e., anchors boxes whose IoU value with any objects are greater than a fixed threshold N t1 will be judged as positive samples; anchors boxes whose IoU value with any objects are less than another fixed threshold N t2 will be judged as negative samples; the rest will be ignored. We set N t1 =0.5 and N t2 =0.4 in our experiment. We use ResNet50 pre-trained on ImageNet as the backbone of RetinaNet. The anchor scales are set the same as the [17] with denser coverage situation, and set the aspect ratios H:W ={1 : 1, 1 : 2, 1 : 3} for CrowdHuman and {2 : 1, 1 : 1, 1 : 2} for COCO. For training, the batch size is set as 16, split into 4 GeForce RTX3090 GPUs. Each training runs for 50 epochs on CrowdHuman and 13 epochs for COCO. We optimize the detector using Stochastic Gradient Descent (SGD) with 0.0001 weight decay and 0.9 momenta. The initial learning rate is set to 0.005 for the first 32 epochs, 0.0005 for the next 10 epochs and 0.00005 for the last 8 epochs on CrowdHuman, and 0.01 for the first 8 epochs, 0.001 for next 3 epoch and 0.0001 for the last 2 epochs on COCO. The short edge of each training and testing image is resized to 800 pixels for both CrowdHuman and COCO. All testing results, including Faster-RCNN and YOLOv3 below, are generated with the NMS threshold of 0.5.
Faster RCNN with FPN is the most classic two-stage anchor-based detector. In the first stage, it adopts the same anchor assignment method as the RetinaNet. We set the N t1 =0.7 and N t2 =0.3 respectively. In the second stage, the proposals whose IoU values with any objects greater than a fixed threshold N t3 will be judged as positive, we set N t3 =0.5, and the rest proposals are judged as negative. In experiments, we use TSAA only in the second stage to research the effectiveness of TSAA towards the anchors (proposals) generated by the RPN. Each training runs for 30 epochs on CrowdHuman and 11 epochs on COCO. The initial learning rate is set to 0.02 for the first 23 epochs, 0.002 for the next 4 epochs and 0.0002 for the last 3 epochs on CrowdHuman, and 0.02 for the first 8 epochs, 0.002 for the last 3 epochs on COCO. The anchor scales in RPN are the same as [16], and other settings are the same as the RetinaNet above.
YOLOv3 is another classic one-stage detector whose anchor assignment method is different from others. In original YOLOv3, an anchor box can be judged as positive only if two conditions are met simultaneously: 1) the center point of one of the object boxes is located in the feature cell grid that anchor corresponds; 2) the IoU between the anchor box and the object in condition 1) are greater than a fixed threshold. Fig5 shows the difference between RetinaNet and YOLOv3. The anchor assignment method in YOLOv3 provides highquality anchor boxes that are more aligned with objects spatially. In the improved YOLOv3, the condition 1) has another choice, i.e., the width ratio or height ratio between anchor and object is less than a fixed value R t . To increase the variety of anchor assignment methods, we choose the improved condition 1) in the experiment and set R t =4.0. The anchor judgment process is as follows: where the W a and H a are width and height of anchor, W t and H t are width and height of the target object, C a and C t are the center points' coordinates of anchor and object, and ⌊x⌋ gives the largest integer less than or equal to x. YOLOv3 uses the K-means algorithm to cluster the aspect ratios of ob- Figure 5: The difference in anchor assignment between Reti-naNet and YOLOv3. The green frame is the target, and the red frame A and B are anchor boxes. In RetinaNet, frames A and B will all be assigned to the green target since their IoU values are greater than the threshold. In YOLOv3, however, only frame A will be assigned to the green target because the center point of frame B is out of the grid where the green box's center point is located. jects in the dataset into 9 clusters. For training, the batch size is set to 96 on CrownHuman and 128 on COCO, split into 4 GPUs. On CrowdHuman, the image size is set to 640×640 pixels for training and 672×672 pixels for testing, and on COCO is set to 416 × 416 for training and testing. Each training runs T = 300 epochs. We optimize the detector using SGD with a momentum of 0.937, and a cosine learning rate scheduling strategy is adopted

Ablation Studies on CrowdHuman
In this section, ablation studies on CrowdHuman is conducted using the three classic detectors mentioned above.

Model
AP MR −2 JI RetinaNet [30] 80 RetinaNet As shown in Table 1, with TASS, the MR −2 is decreased by 4.45%, JI is increased by 1.45%, and AP is increased by 0.31%. The MR −2 is very sensitive to the falsepositive rate, and the JI evaluates how much the prediction results overlap the ground truth, which means the ambiguous prediction boxes that hesitate between two objects will harm MR −2 and JI. As analyzed, anchor drift in crowded scenes will make some prediction boxes ambiguous, so the improvements in MR −2 and JI prove that TSAA can help to increase the compactness of the prediction boxes and suppress the false-positive prediction caused by ADP. The MR −2 is also a critical metric in pedestrian detection. The significant improvements in MR −2 brought by TSAA are very meaningful for pedestrian detection while increasing no extra computational cost and no extra network structures. In addition, AP is increased by 0.3%, which means that TSAA also enhance the prediction precision.We also compare the That is consistent with our analysis of the anchor drift phenomenon, i.e., the overlapped relationship between two objects sometimes makes the manually set optimization target contradicts the regression experience learned in the training process. With TSAA, it is evident that the compactness of prediction boxes, especially that of the overlapped objects, is significantly improved, and ambiguous prediction boxes are effectively suppressed.
Faster-RCNN with FPN In this section, we explore the effectiveness of TSAA on the proposal boxes, which are not preset manually the same as RetinaNet but generated by RPN. Table2   From Table 2, TSAA reduces MR −2 by 0.81% and increases AP and JI by 0.13% and 0.16%, respectively, which suggests that the anchors generated by the RPN also have the possibility to drift to another surrounding object in crowded scenes. However, the improvements brought by TSAA in FPN are not as significant as in RetinaNet. We speculate the reason is the proposal boxes generated by RPN are more aligned to each object spatially, i.e., they are customized for each object by the RPN. Compared with the manually preset anchor boxes in one-stage detectors, the proposals are high-quality anchors for regression and the anchor drift in the customized anchors(proposals) generated by RPN is not as common as the preset anchors in RetinaNet.
YOLOv3 Although the RetinaNet and YOLOv3 are all one-stage detectors, their anchor assignment methods are different. Compared with the RetinaNet, the anchor-target assignment method in YOLOv3 has an additional position constraint which makes the anchor and the object more center aligned spatially. Furthermore, the center point offset predictions in YOLOv3 are constrained within the feature cell grid, not as free as in RetinaNet, as equations (3) and (4) indicated. The experimental results are shown in Table 3.

Model
AP MR −2 JI YOLOv3 85.14 50.27 72.08 YOLOv3+TSAA 85.40 50.08 72.32 Table 3: Ablation Studies on CrowdHuman. Table 3 shows that the TSAA method can comprehensively improve the performance of YOLOv3 in crowded object detection. Similar to the Faster-RCNN, the improvements in YOLOv3 are not as significant as that in RetinaNet. The AP and JI increased by 0.26% and 0.24%, respectively, and the MR −2 decreased by 0.19%. As mentioned above, the conditions in YOLOv3 to judge anchor as positive are stricter than in RetinaNet, which ensure its positive anchors are more center aligned to corresponding objects spatially. Intuitively, bad alignment in spatial-wise will exacerbate the anchor drift and make detectors generate more ambiguous predictions. Similar to the Faster-RCNN, spatially alignment between anchors and objects guarantees the instance features and anchors are matched. The experimental results also prove that the original anchor assignment mechanism in YOLOv3 is better than that in RetinaNet.

Comparative Experiments
To make the performance of TSAA comparable with the two-stage SOTA pedestrian detectors, we integrate TSAA into the Faster-RCNN-based pedestrian detector CrowdDet. The results of comparative experiments are listed in Table4.
From Table 4, we can see that, among all one-stage detectors, our YOLOv3-based detector achieves the best performance in AP and MR. And in all RetinaNet-based methods, our method also achieves the best performance, especially in MR, which goes a long way beyond others. Among all twostage detectors, the CrowdDet with TSAA generates the best performance. The MR-2 is reduced by 0.25%, and JI is increased by 0.52%. In the set-NMS of CrowdDet, when the IoU between the proposal box and the candidate box is under the threshold (the threshold was set as 0.5 in CrowdDet), the set-NMS is equal to the traditional NMS, i.e., all boxes whose IoU with the current proposal box are under 0.5 will be preserved. That means if the boxes belonging to the same target are not compact enough, the false positive ratio will increase as well. With our TSAA, the compactness of the prediction box is increased, which suppresses the false positive brought by the loose boxes, and MR −2 is reduced. On   the other hand, the increased compactness means high precision. JI reflects how much the prediction boxes set overlaps the ground truth set. The JI is increased by 0.52% means the prediction boxes are closer to the ground truth boxes, and the precision of the prediction box is improved.

Ablation Studies on COCO
An advanced anchor assignment method should not only be customized for specific scenes but also be robust for generic circumstances. In this section, we conduct experiments on COCO. A SOTA performance on COCO is not expacted, so we do not try to refine the detectors in terms of training skills or hyper-parameters to make them achieve SOTAcomparable performance. The purpose of ablation experiments on COCO is to study the impact of TSAA on generic object detection. Training methods and hyper-parameters are the same for the sake of fairness. Table5 shows the experimental results.  Without any changes in network structures and training methods, TSAA improves AP and AP 50 by 0.4% and 0.3% on RetinaNet, respectively. Furthermore, the AP 75 is improved by 0.6%, which is more distinct than AP and AP 50 . The improvements brought by TSAA in Faster-RCNN are not as significant as in RetinaNet, since more object-aligned proposals generated by the RPN can handle the sparse scenes well. However, we can still find that the AP 75 is increased by 0.6%. For YOLOv3, AP and AP 75 are improved by 0.2%, and AP 50 is improved by 0.1%. Among all results of these three detectors, we can find that the improvements in AP 75 are relatively more significant than other metrics, which means that the TSAA contributes to precision of the box regression. That is because the TSAA assists each proposal in finding the more suitable object to regress. In summary, the TSAA is robust to the generic object detection.

Qualitative Results
We visualize the testing results of RetinaNet, as shown in Fig8. As shown by the red frames in Fig8(a), false-positive predictions are prone to occur between two objects in the original RetinaNet. This phenomenon is common in the whole testing set according to our observation. With the TSAA, the false-positive predictions can be effectively suppressed. Besides, the TSAA can also improve the precision of the prediction boxes. In the case where objects in the image are all detected, as the first row in Fig8(b) shown, the results with TSAA tend to be more precise compared with the baseline results in the second row in Fig8(b). This fact indicates that TSAA is quite usable in detection tasks that require high accuracy of box regression. This paper defines and introduces the anchor drift problem in anchor-based detectors in crowded scenes. In crowded scenes, the general anchor-object matching mechanism, which directly assigns each anchor to the object with the largest IoU value, usually generates an ambiguous prediction and leads to a high false-positive rate. To address this, an adaptive two-stage anchor assignment method TSAA is proposed to assign each anchor to the object which overlaps its corresponding prediction box the most. In this way, the network can participate in the anchor assignment process, i.e., adaptively assigning each anchor to the object the network thinks it should be assigned. Consequently, the optimization targets will be consistent with the actual regression targets, and the ambiguous prediction can be avoided. The experimental results show that TSAA can effectively suppress ambiguous predictions and reduce the miss rate in crowded scenes without affecting the performance of generic object detection.