YOLOX
YOLOX is an anchor-free, single-stage detector with a decoupled classification-regression head, trained with SimOTA label assignment. LibreYOLO supports it for detection.
- Tasks
- detection
- Sizes
- n, t, s, m, l, x at 416 to 640 px
- Install
pip install libreyolo- Support tier
- Supported, since v. Supporting trainables: kept green in CI, features land opportunistically.
- Licenses
- Code Apache-2.0, weights Apache-2.0. Commercial use
Install
YOLOX needs no extra beyond the base package.
pip install libreyoloPredict
Weights download from Hugging Face on first use and are cached locally.
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreYOLOXs.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreYOLOXs.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=TrueThe returned Results object is the one every family returns, so swapping in a
different detector is a one line change. conf sets the confidence threshold
and iou the NMS threshold applied across the three decoupled prediction
scales. See prediction for sources, streaming and result
handling.
Variants
Six sizes share the same CSP backbone and PAFPN neck. The two smallest, n
and t, run at a smaller fixed input resolution than the other four; the
benchmark table below carries the exact figure for each.
| Checkpoint | Input (px) | mAP 50-95 | Params (M) |
|---|---|---|---|
| LibreYOLOXnano | 416 | 28.8 | 0.91 |
| LibreYOLOXtiny | 416 | 35.1 | 5.06 |
| LibreYOLOXl | 640 | 53.9 | 54.21 |
| LibreYOLOXm | 640 | 50.9 | 25.33 |
| LibreYOLOXs | 640 | 43.0 | 8.97 |
| LibreYOLOXx | 640 | 56.3 | 99.07 |
COCO val2017, 500 images. Measured by the LibreYOLO benchmark harness and published on Vision Analysis, where latency across hardware and runtimes is compared and the full run records live.
Train
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLOXs.pt")model.train(data="my-dataset.yaml", epochs=300, imgsz=640, batch=16, lr0=0.01)libreyolo train model=LibreYOLOXs.pt data=my-dataset.yaml \ epochs=300 imgsz=640 batch=16 lr0=0.01Left alone, the trainer runs 300 epochs at lr0=0.01 with SGD momentum 0.9, a
5-epoch warmup and mosaic and mixup augmentation switched off for the final 15
epochs. train() also accepts a pretrained argument, but the value is never
read inside the method: training always continues from whatever weights the
model was constructed with, so pretrained=False does not reinitialize the
network.
imgsz defaults to a fixed value in the base training config, not to the
loaded checkpoint's native resolution. That affects the n and t
checkpoints specifically: continuing to train either one without setting
imgsz explicitly switches it up to the larger default rather than the
smaller size it was published at.
See training for datasets, augmentation, multi-GPU and loggers.
Validate
val() returns a dictionary of metrics/ keys covering precision, recall,
mAP 50 and mAP 50-95, measured against any dataset in the format you trained on.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLOXs.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreYOLOXs.pt data=my-dataset.yaml# The bundled COCO yaml carries an embedded download script, so it# needs explicit permission unless the dataset is already local.libreyolo val model=LibreYOLOXn.pt data=coco.yaml imgsz=416 \ allow_download_scripts=TrueExport
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX: supported. | Detection to TorchScript: supported. | Detection to ExecuTorch: supported. | Detection to TensorRT: supported. | Detection to OpenVINO: supported. | Detection to Paddle: not supported | Detection to MNN: not supported | Detection to RKNN: not supported | Detection to ncnn: supported. | Detection to TFLite: supported. | Detection to CoreML: supported. | Detection to Core AI: supported. |
An exported artifact loads back through LibreYOLO() on its file suffix, so a
.onnx or .engine file behaves like a checkpoint and returns the same
Results. Running the graph in a bare runtime, with no LibreYOLO installed, is
also supported, but then preprocessing and postprocessing are yours to write.
A CoreML export can bake NMS into the graph with nms=True; YOLOX and YOLOv9
are the only two families that flag currently accepts.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLOXs.pt")model.export(format="onnx", imgsz=640)model.export(format="tensorrt", imgsz=640, half=True)libreyolo export model=LibreYOLOXs.pt format=onnx imgsz=640libreyolo export model=LibreYOLOXs.pt format=tensorrt imgsz=640 half=Truefrom libreyolo import LibreYOLO, SAMPLE_IMAGE # The factory routes on the file suffix, so an exported artifact loads# like any checkpoint and returns the same Results object.model = LibreYOLO("LibreYOLOXs.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)Checkpoints
Every published weight file for this family.
| File | Input (px) | Weights license |
|---|---|---|
| Detection | ||
| LibreYOLOXn.pt | 416 | apache-2.0 |
| LibreYOLOXt.pt | 416 | apache-2.0 |
| LibreYOLOXs.pt | 640 | apache-2.0 |
| LibreYOLOXm.pt | 640 | apache-2.0 |
| LibreYOLOXl.pt | 640 | apache-2.0 |
| LibreYOLOXx.pt | 640 | apache-2.0 |
Every file above exists in the LibreYOLO org today and downloads on first use.
Licensing
Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.
This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.
- Original work
- YOLOX, Megvii
- Upstream license
- Apache-2.0
- Upstream source
- github.com/Megvii-BaseDetection/YOLOX
- LibreYOLO code
- MIT
- Weights
- Apache-2.0, republished at huggingface.co/LibreYOLO
- Interpretation
- Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code, and weights you train yourself on your own data are yours.
Citation
@article{yolox2021,
title={YOLOX: Exceeding YOLO Series in 2021},
author={Ge, Zheng and Liu, Songtao and Wang, Feng and Li, Zeming and Sun, Jian},
journal={arXiv preprint arXiv:2107.08430},
year={2021}
}Copied from the authors' citation block at github.com/Megvii-BaseDetection/YOLOX#cite-yolox.