Back to paper library
CVPR 2021Retail visionPaper notes

CFA

Outside the Box

Original paper

Beyond Bounding-Box: Convex-hull Feature Adaptation for Oriented and Densely Packed Object Detection

Paper authors

Zonghao Guo · Chang Liu · Xiaosong Zhang · Jianbin Jiao · Xiangyang Ji · Qixiang Ye

Publication
CVPR 2021Conference
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@inproceedings{retailproductcfa2021,
  title = {{Beyond Bounding-Box: Convex-hull Feature Adaptation for Oriented and Densely Packed Object Detection}},
  author = {Zonghao Guo and Chang Liu and Xiaosong Zhang and Jianbin Jiao and Xiangyang Ji and Qixiang Ye},
  year = {2021},
  booktitle = {CVPR},
  url = {https://doi.org/10.1109/CVPR46437.2021.00868},
  doi = {10.1109/CVPR46437.2021.00868}
}
On this page

The year before, DRN relabeled SKU-110K with rotated boxes and also made the convolution's sampling grid rotate by an angle.

This paper, from the University of Chinese Academy of Sciences and Tsinghua University, looks at it from a different angle. The authors argue that the problem is not whether the box is rotated correctly but the shape of a "box" itself. Convolution features sit on a square grid, while objects come in all sorts of irregular shapes and are placed one right against the next. Whether the box is upright or tilted, the features of neighboring objects get mixed together.

Their answer is to stop describing objects with boxes and use instead the convex hull enclosed by a set of movable feature points.

Problem Definition

Original Figure 1: the top row shows objects represented by boxes, using two side-by-side airplanes in an aerial image as the example. RepPoint starts from a square grid of points and ends up with a box; the box's receptive-field heat map is a single blob, with the two planes merged together. The bottom row is CFA: it predicts offsets for the feature points and generates convex hulls that fit the shape of the planes, and the receptive-field heat map on the far right splits into two blobs, one for each plane.
Original Figure 1, Guo et al., from PDF page 1, scholarly quotation.

The authors call this problem feature aliasing. When two objects are close together, their receptive fields overlap, and the same patch of features belongs to both objects. The heat map at the far right of the top row shows exactly this. The two planes blur into one blob, and the detector has a hard time telling whether there is one plane here or two.

Products on shelves, cars in parking lots, ships in harbors: all of them are tilted and crowded. Rotated boxes can fit a bit more tightly, but a box is still a rectangle, and each position gets only one box; for crowded objects, the features in the overlap between boxes still get mixed together.

Solution

Original Figure 2: the CFA pipeline. The FPN features on the left split into two paths. The upper path is convex-hull generation: a convolution predicts the offset of each feature point, the Jarvis March algorithm encloses them in a convex hull, and only the localization loss is used for training. The lower path is convex-hull adaptation: deformable convolution (DCN) extracts features and predicts offsets again, giving refined convex hulls; on the right, the convex hulls are divided into set S1 for object 1, set S2 for object 2 and the negative set S−, each with its own loss.
Original Figure 2, Guo et al., from PDF page 3, scholarly quotation.

CFA is built on RepPoints. RepPoints is an anchor-free detector that does not regress the four sides of a box directly; instead, at each position it predicts offsets for 9 points, lets those points move onto the object by themselves, and then derives a box from how the points are distributed. These 9 points are also the sampling points of a deformable convolution, so wherever the points move, that is where the features are taken from.

CFA has two stages. The first encloses the points in convex hulls; the second decides which convex hulls count.

Stage One: Enclosing a Convex Hull

Each position (xi,yi)(x_i, y_i) on the feature map starts with 9 points arranged in a 3×33 \times 3 grid. The network predicts an offset (Δxik,Δyik)(\Delta x^k_i, \Delta y^k_i) for each point, and the points move to their new positions.

After the points move, they are not necessarily convex any more: some may drift into the middle, some may cross over. So after every iteration they are enclosed again with the Jarvis March algorithm (also called gift wrapping): start from the leftmost point and go counter-clockwise, each time picking the next point with the "largest turning angle", until you get back to the start. Points enclosed inside are not counted as vertices of the convex hull.

How do you measure the overlap between a convex hull and an annotated box? The authors use a convex-hull version of GIoU, which the paper calls CIoU:

CIoU(Ci,Bj)=∣Ci∩Bj∣∣Ci∪Bj∣−∣Rj∖(Ci∪Bj)∣∣Rj∣\begin{aligned} \text{CIoU}(C_i, B_j) = {}& \frac{|C_i \cap B_j|}{|C_i \cup B_j|} \\ &- \frac{|R_j \setminus (C_i \cup B_j)|}{|R_j|} \end{aligned}

CiC_i is the convex hull, BjB_j is the annotated rotated box, and RjR_j is the smallest convex polygon enclosing both. The first term is the ordinary IoU; the second subtracts "the part of the smallest enclosing polygon covered by neither", so there is a gradient to push with even when the two don't intersect. The localization loss is 1−CIoU1 - \text{CIoU}.

Stage one is trained with this localization loss alone, so the points learn to move onto the objects.

Original Figure 6: how the convex hulls change during training, with ships moored in a harbor in the top row and cars parked at an angle in a parking lot in the bottom row. The first column shows the annotated boxes (green); the second column is epoch 1, with red convex hulls and points scattered everywhere; by epoch 5 they begin to gather on the objects; by epoch 15 they roughly fit; at the last epoch the red convex hulls almost coincide with the green annotated boxes.
Original Figure 6, Guo et al., from PDF page 7, scholarly quotation.

This figure shows how the convex hulls grow. At first the points drift around; after a few epochs they gradually gather on each car, and in the end every convex hull hugs one car, with most of its points inside the car body. At inference, taking the minimum enclosing rectangle of the convex hull gives the output rotated box.

Stage Two: Deciding Which Convex Hulls Count

Stage two deals with feature aliasing. The key idea is that an object corresponds not to one convex hull but to a group of them; within the group, some convex hulls belong only to this object, while others straddle the neighboring object, and the latter should be down-weighted or even thrown out.

First, Pick a Group of Candidates for Each Object

For each annotated object, the II convex hulls on each FPN level with the highest CIoU against it form the object's convex-hull set SjS_j; those not picked by any object go into the negative set S−S_-. In the experiments, I=6I = 6 works best.

The loss of a positive convex hull is the classification loss (focal loss) plus the localization loss: Li+=Licls+λLilocL^+_i = L^{cls}_i + \lambda L^{loc}_i. The loss of the whole set is a weighted average of the convex-hull losses:

LSj+=1∣Sj∣∑i∈Sjf(Li+) Li+L^+_{S_j} = \frac{1}{|S_j|} \sum_{i \in S_j} f(L^+_i)\, L^+_i

The weight f(L)=1−erf(L)f(L) = 1 - \text{erf}(L) is a decreasing function: the smaller a convex hull's loss, the larger its weight.

Splitting the Set by Gradient Direction

Of these 6 candidates, which should stay? The authors' principle is called "gradient consistency": if a convex hull is a good positive sample, lowering its loss should also lower the loss of the whole set.

Seen as a function of LL, f(L)⋅Lf(L) \cdot L first rises and then falls, with a single peak. To the left of the peak, a lower loss lowers f(L)Lf(L)L, in step with the set; to the right it is the opposite, and a lower loss makes this term larger. So with this peak as the boundary, convex hulls on the left stay in the positive set and those on the right go to the negative set.

Where is the peak? With the ff the paper gives, we solve ddL[(1−erf(L))L]=0\frac{d}{dL}\big[(1 - \text{erf}(L))L\big] = 0 and get L≈0.53L \approx 0.53. In other words, convex hulls whose combined classification and localization loss is below roughly 0.53 count as positives, and those above count as negatives.

Intuitively, the convex hulls with very high loss are mostly the ones sitting between two objects that classification can't make up its mind about either. Kicking them out of the positives means aliased features no longer get used to learn this object.

Shared Convex Hulls Get a Discount

One case remains: a convex hull whose loss is not high but which overlaps several objects at once. The authors add an anti-aliasing coefficient:

pi=γ⋅CIoU(Ci,Bj)∑m=1MCIoU(Ci,Bm)p_i = \gamma \cdot \frac{\text{CIoU}(C_i, B_j)}{\sum_{m=1}^{M} \text{CIoU}(C_i, B_m)}

The numerator is this convex hull's overlap with object jj, and the denominator is the sum of its overlaps with all the objects it overlaps. Suppose a convex hull has a CIoU of 0.6 with object A and 0.3 with the neighboring object B, and γ=0.75\gamma = 0.75. For A, p=0.75×0.6/0.9=0.5p = 0.75 \times 0.6 / 0.9 = 0.5; for B it is 0.25. If this convex hull touched only A, pp would be the full 0.75.

The more objects share a convex hull, the smaller its weight in each object's loss. The final set loss becomes 1∣Sj∣∑pif(Li+)Li+\frac{1}{|S_j|}\sum p_i f(L^+_i) L^+_i.

The sets, the split and the coefficient are all used only during training. At inference only stage one's convex-hull generation runs, the minimum enclosing rectangle is taken, and the output comes after NMS, at about the same cost as RepPoints.

Discussion

SKU110K-R

MethodmAPAP75AR300
YOLOv3-Rotate49.151.158.2
CenterNet-4point34.319.642.2
CenterNet54.761.162.2
DRN55.963.163.3
CFA57.063.563.9

Source: Table 2 of the paper.

The gain on shelves is 1.1 points, and the numbers in the first four rows are copied straight from the DRN paper's table. AP75 rises by only 0.4, so the boxes fit about as tightly as DRN's; the main difference lies at the other IoU thresholds. The paper does not say which backbone this experiment uses; DRN used Hourglass-104.

DOTA

The paper's main battleground is again aerial DOTA. With single-scale testing, CFA scores 75.05 with ResNet-101 and 76.67 with ResNet-152; DRN scores 70.70 single-scale and 72.95 multi-scale. The authors point out that the biggest gains are in categories with irregular shapes that are often crowded together, such as small vehicles, large vehicles, roundabouts, harbors and swimming pools; swimming pools, for example, go from 68.60 to 80.76.

Watch the conditions when comparing with other methods. Several rows for CSL and Gliding Vertex in the table use multi-scale testing, with CSL at 76.17 multi-scale; CFA reports single-scale only.

Ablations

The ablations are run on the DOTA validation set with a ResNet-50 backbone; the baseline is RepPoints with an added angle branch:

Component addedmAPGain
Baseline (SmoothL1 loc. loss)65.35
CIoU loss instead66.30+0.95
Convex-hull generation68.18+1.88
Convex-hull set split69.70+1.52
Anti-aliasing coefficient70.13+0.43

Source: Table 3 of the paper.

The four components add 4.78 points in total, with the convex hull itself and the set split each contributing more than one and a half. The anti-aliasing coefficient contributes the least, 0.43. As for hyperparameters, a CIoU threshold of 0.2, 6 candidates per level and γ=0.75\gamma = 0.75 are the best values.

Original Figure 7: on the left, an aerial image of a parking lot with cars parked at an angle in several rows; in the middle, the heat map without feature adaptation, where the cars in each row merge into bright bands; on the right, the heat map with feature adaptation, where the bright spots are separate, one for each car.
Original Figure 7, Guo et al., from PDF page 7, scholarly quotation.

This heat map is the reciprocal of the positive convex-hull loss during training, so brighter means lower loss. Without feature adaptation, a whole row of cars merges into one bright band and the model can't tell where one car ends and the next begins; with it, each car gets its own bright spot.

As for speed, ResNet-50 takes 0.080 seconds for a 1024×1024 image on one V100, against 0.075 seconds for the baseline, a small difference.

Code

The GitHub link on the paper's first page returned a 404 in November 2026. The authors' code later appeared under another account (guozonghao96/BeyondBoundingBox), based on MMDetection v1.1.0 and shipping only the DOTA configuration.

Someone asked in the issues for the SKU110K-R training code. The authors replied "You can train the SKU110K-R according to paper to create config files", and for evaluation pointed them to DRN's code (issue #3). Someone else asked about the RepPoints baseline with the added angle branch used in the ablations; that one got no reply (issue #6).

Fortunately, MMRotate, OpenMMLab's rotated-detection toolbox, includes a reimplementation of CFA, which scores 73.45 on DOTA with ResNet-50 trained for 40 epochs. On the DOTA side, at least, there is a better-maintained version to use.

Conclusion

CFA steps outside the "how should the box rotate" line of thinking and describes objects directly with convex hulls enclosed by a set of movable points, so the feature sampling points follow the object's actual shape. The set split and anti-aliasing coefficient in stage two deal with crowded objects competing for features: convex hulls with too high a loss are kicked out of the positives, and convex hulls shared by several objects are down-weighted.

On SKU110K-R it pushes DRN's 55.9 to 57.0; on aerial data the gains are much larger. The size of the gain on shelves is about the same as DRN's improvement over its baseline the year before, around one point.

To reproduce this number on shelf data, you have to write the SKU110K-R configuration yourself, borrow DRN's evaluation tools, and pray that you guess the backbone the paper never names (a form of few-shot learning in its own right).