YOLOX (tiny / S / M / L / X)
Megvii's YOLOX (tiny, s, m, l, x on COCO): anchor-free one-stage box detector, a CSPDarknet CNN with a decoupled head and NMS. Apache-2.0 code and weights.
experimental Fork of Megvii-BaseDetection/YOLOX@6ddff48 · backends: portable, kernels
- Paper YOLOX: Exceeding YOLO Series in 2021 arXiv · first released 18 Jul 2021
Paper 2021 Added in 0.2.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install "fastforks-core[torchvision]"
from fastforks import detection
model = detection.load("yolox-tiny") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.boxes # also: scores, labels
result.backend # what ran: mode, device, dtype, kernels fastforks bench yolox-tiny Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 800x1344 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed call | fp16 | 9.79 | – | 32 MiB/58 MiB | 0.1 | 0.37 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 5.25 | 1.9× | 22 MiB/56 MiB | 0.2 | 1.24 |
| Kernels | fp16 | 1.79 | 5.5× | 22 MiB/68 MiB | 0.7 | 1.04 |
| Portable + torch.compile | 2.87 | 3.4× | 58 MiB/94 MiB | 13 (build) | – | |
| TensorRT fp16 | fp16 | 0.561 | 17× | 38 MiBenginenot comparable | 24 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-13 | Original | fp32 | 24.7 | 1,501 MiB process | – | 800x1344 |
| Portable | fp16 | 20.1 | 1,492 MiB process | matches | 800x1344 | |
| Portable | fp32 | 20.1 | 1,497 MiB process | matches | 800x1344 | |
| Kernels | fp16 | not implemented | – | 800x1344 | ||
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 source
- Training data
-
- COCO 2017 (train, instance annotations) CC-BY-4.0
Our reading of the licences, not legal advice.
Weights
yolox_tiny.pth 40.8 MB· hosted on GitHubfastforks downloads and checks these files on first use (fastforks download yolox-tiny).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
COCO val2017
every 25th image (200), box mAP
| Run | dtype | box mAP ↑ | Δ box mAP vs fp32 original | images | ms / image |
|---|---|---|---|---|---|
| Original fp32 | fp32 | 38.16 | reference | 200 | – |
| Original fp16 | fp16 | 38.20 | +0.04 | 200 | – |
| Portable fp32 | fp32 | 38.21 | +0.05 | 200 | – |
| Portable | fp16 | 38.29 | +0.13 | 200 | – |
| Kernels | fp16 | 38.29 | +0.13 | 200 | – |
pycocotools COCOeval of the top 100 detections per image. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks db9e79d5, 2026-11-13.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.00037 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 0.51 (absolute error of the output boxes).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.00037 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.2 | 0.11759 |
| GPU default dtypes, p99 |diff| | ≤ 0.51 | 0.26771 |
Recorded for yolox-tiny on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3
Details
YOLOX (Ge et al. 2021, Megvii): anchor-free one-stage detector, all convolutions: a CSPDarknet backbone, a PAFPN neck and a decoupled head that predicts, per cell of the stride 8 / 16 / 32 maps, a box (centre and size), an objectness and a score per class; a cell's score is objectness x its best class; class-wise NMS. COCO checkpoints (80 classes) from the authors. The image is fitted into 640 x 640 (tiny: 416 x 416); vendored from the reference (no yolox dependency). The portable `module()` is the whole network (decoded boxes, scores and labels per cell, before NMS).
- Input / output
- Input: one RGB image. Output: boxes, class labels, scores and instance masks.
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (491 MiB allocated)
- Options
score_threshold=0.050.0 to 1.0· changes the outputmax_detections=100>= 1· changes the outputcuda_graphs=true
- Outputs
boxes,scores,labels- Checkpoint
size=416,depth=0.33,width=0.375- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)fvm_convfused convolutions for image classifiersfvm_extrafused transformer row operations (rotary split, SwiGLU with LayerNorm)fvm_mbfused MBConv blocks (MobileNet and EfficientNet families)fvm_r3further fused classifier blocks
- Apple (MPS)
- fp32, fp16
Limitations
- The image is resized like OpenCV 4's 8-bit INTER_LINEAR (what the reference calls); OpenCV 5 resizes differently by up to two grey levels, so a reference run on OpenCV 5 differs slightly.
- Boxes are not clamped to the image, as upstream: at the right or bottom border they can reach a few pixels into the padding.
- One label per box (the cell's best class), as upstream: a cell does not report a second class.
- Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~45 MiB above portable (peak allocated is not); `cuda_graphs=false` or `release_graphs()` frees it.
Full reference, generated from the repository
Megvii's YOLOX (tiny, s, m, l, x on COCO): anchor-free one-stage box detector, a CSPDarknet CNN with a decoupled head and NMS. Apache-2.0 code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
yolox-tiny | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 9.79 5.25 1.79 2.87 0.561 | 32 / 58 22 / 56 22 / 68 58 / 94 62 / 90 |
yolox-s | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 10.4 5.27 2.43 2.95 1.02 | 67 / 90 46 / 60 40 / 94 74 / 96 86 / 126 |
yolox-m | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 12.4 6.03 3.44 3.70 2.03 | 142 / 160 87 / 112 77 / 184 111 / 132 152 / 194 |
yolox-l | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 15.1 7.66 5.02 6.15 3.10 | 265 / 298 151 / 170 139 / 250 173 / 208 279 / 324 |
yolox-x | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 17.2 11.6 7.56 11.3 5.28 | 450 / 504 246 / 280 230 / 378 265 / 296 432 / 478 |
Details
- Original code: https://github.com/Megvii-BaseDetection/YOLOX at
6ddff4824372 - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/Megvii-BaseDetection/YOLOX/blob/6ddff4824372906469a7fae2dc3206c7aa4bbaee/LICENSE (Apache-2.0); https://github.com/Megvii-BaseDetection/YOLOX/releases/tag/0.1.1rc0 (the weights)
- Training data: COCO 2017 (train, instance annotations) (COCO 2017 train, 300 epochs from scratch (no ImageNet pretraining; Ge et al. 2021, section 2.1))
- Options:
score_threshold= 0.05 (0.0 to 1.0),max_detections= 100 (>= 1),cuda_graphs= True (speed only) - Kernel libraries:
cudnn_hacc,fvm_conv,fvm_extra,fvm_mb,fvm_r3 - Variants:
yolox-tiny,yolox-s,yolox-m,yolox-l,yolox-x - Outputs: boxes, scores, labels; label_set:
coco-80 - Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
yolox-tiny3000x4000 (0.5 GiB peak allocated, 0.5 reserved);yolox-s3000x4000 (0.5 GiB peak allocated, 0.5 reserved);yolox-m3000x4000 (0.5 GiB peak allocated, 0.6 reserved);yolox-l3000x4000 (0.6 GiB peak allocated, 0.6 reserved);yolox-x3000x4000 (0.7 GiB peak allocated, 0.7 reserved) yolox-tiny800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 24 s (ONNX + engine).yolox-s800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 17 s (ONNX + engine).yolox-m800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).yolox-l800x1344, first call: portable + torch.compile 15 s (cold Inductor cache), TensorRT fp16 21 s (ONNX + engine).yolox-x800x1344, first call: portable + torch.compile 16 s (cold Inductor cache), TensorRT fp16 24 s (ONNX + engine).yolox-tinyoriginal 800x1344: torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed callyolox-soriginal 800x1344: torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed callyolox-moriginal 800x1344: torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed callyolox-loriginal 800x1344: torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed callyolox-xoriginal 800x1344: torch.autocast(float16) around the call; Megvii-BaseDetection/YOLOX@6ddff4824372 ValTransform (CPU cv2) + model + postprocess (NMS 0.65), score 0.05 (card default), all in the timed callyolox-tinyload / first call: original 1.55 s / 0.515 s, portable 0.18 s / 1.31 s, kernels 1.58 s / 0.307 syolox-sload / first call: original 0.22 s / 0.03 s, portable 0.15 s / 1.346 s, kernels 1.55 s / 0.303 syolox-mload / first call: original 0.32 s / 0.032 s, portable 0.41 s / 0.232 s, kernels 0.84 s / 0.18 syolox-lload / first call: original 0.65 s / 0.032 s, portable 0.72 s / 1.114 s, kernels 1.05 s / 1.167 syolox-xload / first call: original 0.76 s / 0.083 s, portable 0.92 s / 0.138 s, kernels 1.33 s / 1.136 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
pycocotools COCOeval of the top 100 detections per image. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
yolox-tiny | COCO val2017, every 25th image (200), box mAP | 38.16 | 38.20 | 38.29 | 38.21 | 38.29 | |
yolox-s | COCO val2017, every 25th image (200), box mAP | 44.67 | 44.75 | 44.72 | 44.67 | 44.73 | |
yolox-m | COCO val2017, every 25th image (200), box mAP | 50.34 | 50.28 | 50.39 | 50.29 | 50.38 | |
yolox-l | COCO val2017, every 25th image (200), box mAP | 54.13 | 54.11 | 54.14 | 54.13 | 54.19 | |
yolox-x | COCO val2017, every 25th image (200), box mAP | 54.64 | 54.61 | 54.62 | 54.64 | 54.60 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks db9e79d5, 2026-11-13.
Parity
CPU, float32: max |diff| <= 0.00037 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 0.51 (absolute error of the output boxes).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
yolox-tiny | 0.11759 / 0.26771 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
yolox-s | 0.08776 / 0.33121 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
yolox-m | 0.07866 / 0.20274 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
yolox-l | 0.06254 / 0.1491 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
yolox-x | 0.10749 / 0.33965 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
Limitations
- The image is resized like OpenCV 4's 8-bit INTER_LINEAR (what the reference calls); OpenCV 5 resizes differently by up to two grey levels, so a reference run on OpenCV 5 differs slightly.
- Boxes are not clamped to the image, as upstream: at the right or bottom border they can reach a few pixels into the padding.
- One label per box (the cell's best class), as upstream: a cell does not report a second class.
- Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~45 MiB above portable (peak allocated is not);
cuda_graphs=falseorrelease_graphs()frees it.
Example output
No example rendered for this checkpoint yet.