Models · Object detection

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

Checkpoint

Paper 2021 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 1.79 ms 800x1344, fp16
vs the faster original 5.5× original fp16: 9.79 ms
Peak memory 22 MiB original: 32 MiB
Accuracy vs original fp32 +0.13 kernels box mAP, COCO val2017 (38.16 original)

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)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32not 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 callfp16 9.79–32 MiB/58 MiB0.10.37
Portable fp32fp32not measured ––––
Portablefp16 5.251.9×22 MiB/56 MiB0.21.24
Kernelsfp16 1.795.5×22 MiB/68 MiB0.71.04
Portable + torch.compile 2.873.4×58 MiB/94 MiB13 (build)–
TensorRT fp16fp16 0.56117×38 MiBenginenot comparable24 (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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-13Originalfp3224.7 1,501 MiB process–800x1344
Portablefp1620.1 1,492 MiB processmatches800x1344
Portablefp3220.1 1,497 MiB processmatches800x1344
Kernelsfp16not 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

Our reading of the licences, not legal advice.

Weights

yolox_tiny.pth 40.8 MB· hosted on GitHub

fastforks 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

Rundtypebox mAP ↑Δ box mAP vs fp32 originalimagesms / image
Original fp32fp3238.16 reference 200 –
Original fp16fp1638.20 +0.04 200 –
Portable fp32fp3238.21 +0.05 200 –
Portablefp1638.29 +0.13 200 –
Kernelsfp1638.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).

CheckToleranceMeasured
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 output
  • max_detections=100>= 1· changes the output
  • cuda_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 classifiers
  • fvm_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.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
yolox-tinysynthetic (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-ssynthetic (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-msynthetic (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-lsynthetic (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-xsynthetic (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-tiny 3000x4000 (0.5 GiB peak allocated, 0.5 reserved); yolox-s 3000x4000 (0.5 GiB peak allocated, 0.5 reserved); yolox-m 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); yolox-l 3000x4000 (0.6 GiB peak allocated, 0.6 reserved); yolox-x 3000x4000 (0.7 GiB peak allocated, 0.7 reserved)
  • yolox-tiny 800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 24 s (ONNX + engine).
  • yolox-s 800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 17 s (ONNX + engine).
  • yolox-m 800x1344, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).
  • yolox-l 800x1344, first call: portable + torch.compile 15 s (cold Inductor cache), TensorRT fp16 21 s (ONNX + engine).
  • yolox-x 800x1344, first call: portable + torch.compile 16 s (cold Inductor cache), TensorRT fp16 24 s (ONNX + engine).
  • yolox-tiny original 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 call
  • yolox-s original 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 call
  • yolox-m original 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 call
  • yolox-l original 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 call
  • yolox-x original 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 call
  • yolox-tiny load / first call: original 1.55 s / 0.515 s, portable 0.18 s / 1.31 s, kernels 1.58 s / 0.307 s
  • yolox-s load / first call: original 0.22 s / 0.03 s, portable 0.15 s / 1.346 s, kernels 1.55 s / 0.303 s
  • yolox-m load / first call: original 0.32 s / 0.032 s, portable 0.41 s / 0.232 s, kernels 0.84 s / 0.18 s
  • yolox-l load / first call: original 0.65 s / 0.032 s, portable 0.72 s / 1.114 s, kernels 1.05 s / 1.167 s
  • yolox-x load / 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.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
yolox-tinyCOCO val2017, every 25th image (200), box mAP38.1638.2038.2938.2138.29
yolox-sCOCO val2017, every 25th image (200), box mAP44.6744.7544.7244.6744.73
yolox-mCOCO val2017, every 25th image (200), box mAP50.3450.2850.3950.2950.38
yolox-lCOCO val2017, every 25th image (200), box mAP54.1354.1154.1454.1354.19
yolox-xCOCO val2017, every 25th image (200), box mAP54.6454.6154.6254.6454.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).

variantkernels error vs original, mean / p99GPU, torchkernels used
yolox-tiny0.11759 / 0.26771RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
yolox-s0.08776 / 0.33121RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
yolox-m0.07866 / 0.20274RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
yolox-l0.06254 / 0.1491RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
yolox-x0.10749 / 0.33965RTX 5060 Ti, torch 2.14.1+cu130cudnn_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=false or release_graphs() frees it.

Example output

No example rendered for this checkpoint yet.