YOLOX: Exceeding YOLO Series in 2021
- Publication
- Publication venue not yet verified
- First submitted to arXiv
- arXiv:2107.08430
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{objectdetectionyolox2021,
title = {{YOLOX: Exceeding YOLO Series in 2021}},
author = {Zheng Ge and Songtao Liu and Feng Wang and Zeming Li and Jian Sun},
year = {2021},
eprint = {2107.08430},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2107.08430}
}
In the summer of 2021, the YOLO throne belonged to YOLOv5. YOLOv5-L scored 48.2 AP on COCO at 13.7 ms per image on a V100.
Over the same period, academic object detection had already moved through several rounds of new ideas. Methods like FCOS removed anchor boxes; ATSS and OTA rethought which predictions should count as positive samples; DETR did away with NMS altogether. YOLOv4 and YOLOv5, though, were still holding on to anchor boxes and still assigning positive samples with hand-written rules.
Zheng Ge, Songtao Liu, Feng Wang, Zeming Li and Jian Sun at Megvii decided to bring these new ideas into YOLO. Instead of starting from the strongest model, YOLOv5, they went back to YOLOv3. Their reasoning was that v4 and v5 had been tuned so finely around anchor boxes that tearing them out would be more trouble than it was worth, while YOLOv3 was still one of the most widely used detectors in industry, since compute was limited in many real deployments and software support lagged behind.
The result is YOLOX. If you have read this site's multi-object tracking notes, the name should sound familiar. In the long line of trackers since ByteTrack, it is the detector in almost every one.

Defining the problem
The authors list two problems with anchor boxes.
First, a good set of anchor boxes can only be found by clustering the boxes in the training data beforehand. Switch datasets and you have to do it all over again, and the anchors you find carry that dataset's preferences.
Second, every location has to predict several anchor boxes, which makes the detection head more complex and multiplies the number of predictions per image. On edge devices, these predictions have to be moved from the NPU to the CPU for post-processing, and the transfer alone can drag down overall latency.
The other problem is how positive samples are assigned. YOLOv3's rule is rigid. Each object gets exactly one location and one anchor box responsible for it. Research from the previous two years, however, showed that how many positive samples each object gets, and which ones, should depend on how well they predict rather than being fixed in advance.
Solving the problem
Starting from YOLOv3-SPP, the authors added one change at a time and measured each step on the COCO validation set:
| Change | AP | Latency (ms) |
|---|---|---|
| YOLOv3 baseline | 38.5 | 10.5 |
| + decoupled head | 39.6 | 11.6 |
| + strong augmentation | 42.0 | 11.6 |
| + anchor-free | 42.9 | 11.1 |
| + multiple positives | 45.0 | 11.1 |
| + SimOTA | 47.3 | 11.1 |
| + NMS-free (optional) | 46.5 | 13.5 |
Compiled from Table 2 of the paper; COCO val, 640 × 640, V100, FP16, batch 1, latency excluding post-processing.
The baseline already adds general-purpose tricks such as EMA, a cosine learning rate, an IoU loss and an IoU branch, keeps only horizontal flips, color jitter and multi-scale training for data augmentation, and scores 38.5 on COCO val. The point of comparison is the best YOLOv3 implementation of the time, the Ultralytics version, at 44.3.
Splitting the head

Classification and regression fighting over the same features is an old, familiar conflict in object detection. Two-stage detectors and most one-stage detectors had long since given the two jobs separate branches, but YOLO, through every change of backbone and feature pyramid, kept a detection head in which one convolution spits out class, box and objectness all at once.
The YOLOX decoupled head first reduces the channels to 256 with a 1×1 convolution, then splits into two branches with two 3×3 convolutions each, one for classification and one for regression and IoU.

Once split, the head converges much faster and ends with a somewhat higher AP, at the cost of 1.1 ms more latency (10.5 to 11.6). The authors ran one more experiment, turning YOLO into an end-to-end version without NMS. With the coupled head, that change loses 4.2 AP (38.5 to 34.3); with the decoupled head, only 0.8 (39.6 to 38.8).
Strong data augmentation
Next come Mosaic and MixUp. Mosaic, introduced by Ultralytics in their YOLOv3 implementation, stitches four images into one; MixUp overlays two images. Both are switched off for the last 15 epochs, so the model sees normal images again in its final rounds. This step adds 2.4 AP.
With augmentation this strong, the authors found that ImageNet pretraining no longer helped, so every model from here on is trained from scratch.
Dropping the anchors
Removing the anchors is straightforward. Each location used to predict 3 anchor boxes; now it predicts 1 box, given as two offsets relative to the top-left corner of the grid cell plus the box's height and width. An object's center point is its positive sample, and which feature pyramid level is responsible for the object is decided by its size, as in FCOS.
Parameters and computation both go down, latency drops from 11.6 to 11.1 ms, and AP still gains 0.9.
More positive samples
With only the center location as a positive sample, the neighboring locations that also predict well are treated as negatives and go to waste. The authors count the whole 3 × 3 area around the center as positives, which FCOS calls center sampling. This step adds 2.1, and 45.0 already beats the Ultralytics YOLOv3's 44.3.
SimOTA
The last step is label assignment. The authors' own earlier work, OTA, treats "which prediction is responsible for which object" as an optimal transport problem and solves it globally. It works well, but solving it with the Sinkhorn-Knopp algorithm adds 25% to training time, too heavy a burden for 300 epochs of training.
SimOTA simplifies it into three steps:
- For each object–prediction pair, compute a cost equal to the classification loss plus times the regression loss.
- Each object only considers predictions within a fixed region around its own center.
- Each object takes the lowest-cost predictions as its positive samples, with depending on the object.
For how is chosen, the paper sends readers to OTA; the answer is in these lines of the official code.
cost = (
pair_wise_cls_loss
+ 3.0 * pair_wise_ious_loss # -log(IoU)
+ float(1e6) * (~geometry_relation) # ruled out if outside the center region
)
n_candidate_k = min(10, pair_wise_ious.size(1))
topk_ious, _ = torch.topk(pair_wise_ious, n_candidate_k, dim=1)
dynamic_ks = torch.clamp(topk_ious.sum(1).int(), min=1)
for gt_idx in range(num_gt):
_, pos_idx = torch.topk(cost[gt_idx], k=dynamic_ks[gt_idx], largest=False)
matching_matrix[gt_idx][pos_idx] = 1
Excerpt from the official code yolox/models/yolo_head.py (get_assignments, simota_matching); the comments were added and the layout slightly adjusted for this note.
In the official code, is 3. is the sum of the object's top 10 IoUs with the candidate predictions (the ones inside any object's center region), truncated to an integer, with a minimum of 1.
For example, a large object whose top 10 IoUs are 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2 and three more of 0.1 sums to 3.8, so it gets 3 positive samples. A very small object that no prediction boxes accurately has top IoUs of only 0.3, 0.2 and 0.1; they add up to less than 1, and it still gets the guaranteed minimum of 1. The more accurately an object is boxed, the more positive samples it gets.
If one prediction is picked by several objects, it stays only with the object that has the lowest cost. In the current official code, the center region extends 1.5 strides around the object's center.
This step adds another 2.3, reaching 47.3, 3.0 above the Ultralytics YOLOv3.
Without NMS
Following another end-to-end detection paper, the authors also added two convolution layers and switched to one-to-one label assignment, so that YOLOX could run without NMS. AP dropped by 0.8 and latency rose from 11.1 to 13.5 ms, so it was left out of the final version and kept only as an option.
That comparison is a bit unfair to the NMS-free version, though. The note under the table states that latency and FPS exclude post-processing, and NMS time is exactly what the other rows get to leave out.
Discussion
Swapping in the YOLOv5 backbone
DarkNet53 was only the starting point. For a fair comparison, the authors took YOLOv5's backbone (a modified CSPNet), SiLU activation and PAN neck exactly as they were, and followed YOLOv5's scaling rules to build four sizes, S, M, L and X:
| Size | YOLOv5 | YOLOX | YOLOv5 latency | YOLOX latency |
|---|---|---|---|---|
| S | 36.7 | 39.6 | 8.7 | 9.8 |
| M | 44.5 | 46.4 | 11.1 | 12.3 |
| L | 48.2 | 50.0 | 13.7 | 14.5 |
| X | 50.4 | 51.2 | 16.0 | 17.3 |
Compiled from Table 3 of the paper; COCO AP and latency (ms), 640 × 640, V100, FP16, batch 1.
The smaller the model, the more YOLOX wins by, with 2.9 more at S and only 0.8 more at X. Latency goes up by around 1 ms at every size, and that comes from the decoupled head.
Small models
Shrunk further, YOLOX-Tiny scores 32.8 with 416 × 416 inputs, against 21.7 for YOLOv4-Tiny. YOLOX-Nano, built for mobile devices, switches to depthwise convolutions; with only 0.91M parameters and 1.08 GFLOPs, it reaches 25.3 AP, 1.8 above NanoDet's 23.5.
Augmentation strength also has to follow model size. Removing MixUp from YOLOX-Nano and narrowing Mosaic's scale range from 0.1–2.0 to 0.5–1.5 raises its AP from 24.0 to 25.3. YOLOX-L is the opposite. Adding MixUp gains it 0.9, for 49.5. The authors' MixUp first rescales each of the two images at random before overlaying them, and it does about as well as Copy-Paste (49.4), which needs instance mask annotations.
How to compare speed
As is customary, the paper also includes a big table comparing many detectors, but the authors themselves warn that the speeds in it were measured by different groups on different software and hardware, so they can't really be compared directly. The curves in Fig. 1 are the ones measured on the same V100 with the same code base.
The authors also admit that Transformer-based detectors had already pushed COCO to around 60 AP and that they had not yet tried the larger YOLO variants; all of that was left for later.
Separately, YOLOX-L with TensorRT took first place in the Streaming Perception Challenge at the CVPR 2021 Workshop on Autonomous Driving. The challenge scores accuracy and latency together, and frames that go by while the model is still running inference are scored too. The authors found that for a 30 FPS stream, a large model whose inference time stays under 33 ms is the best trade-off.
What came after
The YOLOX code was released under Apache-2.0 with deployment versions for ONNX, TensorRT, NCNN and OpenVINO, and it has more than ten thousand stars on GitHub. The last official release, 0.3.0, dates from April 2022, and updates have been rare since.
Its influence lives mainly in other people's code. ByteTrack, from October 2021, used YOLOX as its detector, and later multi-object tracking papers mostly reused the same YOLOX weights for a fair comparison. YOLOv6 adopted the decoupled head and the anchor-free design. Turning off Mosaic for the last few epochs is still in Ultralytics' default settings today (close_mosaic: 10).
YOLOX tried the road without NMS but didn't keep going down it. It took YOLOv10, three years later and with a different training scheme, to actually get NMS out of YOLO.
Conclusion
YOLOX did not invent any new component. The decoupled head, anchor-free detection and center sampling were all available off the shelf, and SimOTA is the authors' simplification of their own OTA. What this paper does is pour two years of research into YOLOv3 one piece at a time, measuring at every step how many points it adds and how many milliseconds it costs.
That step-by-step table is more useful as a reference than the final 50.0 AP. If you want to try a decoupled head or a dynamic number of positive samples on your own detector, add them in its order and you will have a fair idea of which steps are worth it and which aren't.
The title reads "Exceeding YOLO Series in 2021". At least it was honest enough to include the year.