运行 demo 前需先从 benchmark 表格手动下载预训练权重并用 -c 指定路径;训练前需自行准备 COCO 数据集并软链到 ./datasets/COCO;使用 --cache 把图片缓存进内存需要较大系统内存。

YOLOX
Megvii-BaseDetectionApache-2.0长期未更新高性能无锚框 YOLO 目标检测器,精度超过 YOLOv3~v5,支持 MegEngine、ONNX、TensorRT、ncnn 和 OpenVINO 多后端部署。
YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5 with MegEngine, ONNX, TensorRT, ncnn, and OpenVINO supported. Documentation: https://yolox.readthedocs.io/
git clone [email protected]:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -v -e .README 未说明最低显存要求;训练与评测命令按 GPU 数量(-d)配置,demo 可通过 --device 选择 cpu 或 gpu;速度基准在 V100 上测得。
无锚框 YOLO 检测器,兼顾科研与工业部署,精度超过 YOLOv3~v5
高性能无锚框 YOLO 目标检测器,精度超过 YOLOv3~v5,支持 MegEngine、ONNX、TensorRT、ncnn 和 OpenVINO 多后端部署。
核心能力
- 采用无锚框(anchor-free)设计,简化检测头与训练流程
- 提供 Nano 到 X 多档模型,覆盖 0.91M 到 99.1M 参数
- 支持 MegEngine、ONNX、TensorRT、ncnn、OpenVINO 多后端部署
- 支持多机多卡训练与 FP16 混合精度训练
- 提供 COCO 复现、自定义数据训练与可视化工具文档
容易踩的坑
- 0.3.0YOLOX 0.3.0最新正式版2022-04-22 · 2022-04-22 07:20 UTC
YOLOX 0.3.0 version
Updates notes
【2022/04/22】
Features
- support loading YOLOX model through
torch.hub#1189 - support just-in-time compile op #1241
- support wandb logger #1144
- support
freezefunction for torch module #1156 - support showing YOLOX demo in a live window #1138
- support custom dataset for evaluator #1131
- add option for decode output in export_onnx #1113
- add HuggingFace web demo, click link here #1184
- add pre-commit #1263
- add
get_trainermethod in Exp class #1263
For pip users
pip install yoloxcould help you to install yolox for most platform. For windows users, yolox will compile self-defined operator in YOLOX package just-in-time. Otherwise, yolox will compile operator during installation automatically.Thanks
Contributors (sort by timestamp of commit) @woowonjin @robin-maillot @wico-silva @AaronNZH @nemonameless @ArMaxik @joakimeriksson @shenyi0220 @manangoel99 @wep21 @futabato @AK391 @DoubleChuang @Ar-Ray-code @PieroMacaluso @Joe0120 @Yulv-git
- support loading YOLOX model through
- 0.2.02022-01-18 · 2022-01-18 07:05 UTC
查看更新说明
0.2.0
Updates notes
【2022/01/18】
Features
- Saved 30% memory useage in COCO training. #1066
- Log per class AP & AP during evaluation. #1026 #1052
- Users could install yolox from pip now! Supports on more platform is coming. #1020 #1079
- Optimize dynamic matching in label assignment. #861
For pip users
pip install yoloxcould help you to install yolox now.Exp design
YOLOX use
Expas a controller. With Exp object, users could do everything they want. e.g. If you want to get something used in yolox tiny.from yolox.exp import get_exp exp = get_exp(exp_name="yolox-tiny") # yolox-tiny could be replaced by yolox-nano/s/m and so on model = exp.get_model() # now you get yolox-tiny model dataloader = exp.get_data_loader(batch_size=8, is_distributed=False) optimizer = exp.get_optimizer(batch_size=2)Training with pip installed yolox
Since pip will auto install yolox in its own way, users may use a environment variable named
YOLOX_DATADIR. Check more details from our docs here. - 0.1.1rc00.1.1 pre releasepre-release2021-08-18 · 2021-08-18 12:41 UTC
查看更新说明
0.1.1pre
Updates notes
【2021/08/19】
Features
- Support image caching for faster training, which requires large system RAM.
- Remove the dependence of apex and support torch amp training.
- Optimize the preprocessing for faster training
- Replace the older distort augmentation with new HSV aug for faster training and better performance.
2X Faster training
We optimize the data preprocess and support image caching with
--cacheflag:python tools/train.py -n yolox-s -d 8 -b 64 --fp16 -o [--cache] yolox-m yolox-l yolox-x- -d: number of gpu devices
- -b: total batch size, the recommended number for -b is num-gpu * 8
- --fp16: mixed precision training
- --cache: caching imgs into RAM to accelarate training, which need large system RAM.
Higher performance
New models achive ~1% higher performance! See Model_Zoo for more details.
Support torch amp
We now support torch.cuda.amp training and Apex is not used anymore.
Breaking changes
We remove the normalization operation like -mean/std. This will make the old weights incompatible.
If you still want to use old weights, you can add `--legacy' in demo and eval:
python tools/demo.py image -n yolox-s -c /path/to/your/yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu] [--legacy]and
python tools/eval.py -n yolox-s -c yolox_s.pth -b 64 -d 8 --conf 0.001 [--fp16] [--fuse] [--legacy] yolox-m yolox-l yolox-xBut for deployment demo, we don't suppor the old weights anymore.
- 0.1.0YOLOX 0.1.0 version2021-08-18 · 2021-08-18 03:55 UTC
查看更新说明
0.1.0 release
Features
- YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5.
- Support deployment of MegEngine, ONNX, TensorRT, openvino and ncnn.
- Document website
Bug fixes
- fix memory leak issues during training. (e.g. #103)
Breaking change
- Suffix of saved checkpoints become
pthinstead oftar
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Introduction
YOLOX is an anchor-free version of YOLO, with a simpler design but better performance! It aims to bridge the gap between research and industrial communities. For more details, please refer to our report on Arxiv.
This repo is an implementation of PyTorch version YOLOX, there is also a MegEngine implementation.
Updates!!
- 【2023/02/28】 We support assignment visualization tool, see doc here.
- 【2022/04/14】 We support jit compile op.
- 【2021/08/19】 We optimize the training process with 2x faster training and ~1% higher performance! See notes for more details.
- 【2021/08/05】 We release MegEngine version YOLOX.
- 【2021/07/28】 We fix the fatal error of memory leak
- 【2021/07/26】 We now support MegEngine deployment.
- 【2021/07/20】 We have released our technical report on Arxiv.
Benchmark
Standard Models.
| Model | size | mAPval0.5:0.95 | mAPtest0.5:0.95 | Speed V100(ms) | Params(M) | FLOPs(G) | weights |
|---|---|---|---|---|---|---|---|
| YOLOX-s | 640 | 40.5 | 40.5 | 9.8 | 9.0 | 26.8 | github |
| YOLOX-m | 640 | 46.9 | 47.2 | 12.3 | 25.3 | 73.8 | github |
| YOLOX-l | 640 | 49.7 | 50.1 | 14.5 | 54.2 | 155.6 | github |
| YOLOX-x | 640 | 51.1 | 51.5 | 17.3 | 99.1 | 281.9 | github |
| YOLOX-Darknet53 | 640 | 47.7 | 48.0 | 11.1 | 63.7 | 185.3 | github |
| Model | size | mAPtest0.5:0.95 | Speed V100(ms) | Params(M) | FLOPs(G) | weights |
|---|---|---|---|---|---|---|
| YOLOX-s | 640 | 39.6 | 9.8 | 9.0 | 26.8 | onedrive/github |
| YOLOX-m | 640 | 46.4 | 12.3 | 25.3 | 73.8 | onedrive/github |
| YOLOX-l | 640 | 50.0 | 14.5 | 54.2 | 155.6 | onedrive/github |
| YOLOX-x | 640 | 51.2 | 17.3 | 99.1 | 281.9 | onedrive/github |
| YOLOX-Darknet53 | 640 | 47.4 | 11.1 | 63.7 | 185.3 | onedrive/github |
Light Models.
| Model | size | mAPval0.5:0.95 | Params(M) | FLOPs(G) | weights |
|---|---|---|---|---|---|
| YOLOX-Nano | 416 | 25.8 | 0.91 | 1.08 | github |
| YOLOX-Tiny | 416 | 32.8 | 5.06 | 6.45 | github |
| Model | size | mAPval0.5:0.95 | Params(M) | FLOPs(G) | weights |
|---|---|---|---|---|---|
| YOLOX-Nano | 416 | 25.3 | 0.91 | 1.08 | github |
| YOLOX-Tiny | 416 | 32.8 | 5.06 | 6.45 | github |
Quick Start
Step1. Install YOLOX from source.
git clone [email protected]:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -v -e . # or python3 setup.py develop
Step1. Download a pretrained model from the benchmark table.
Step2. Use either -n or -f to specify your detector's config. For example:
python tools/demo.py image -n yolox-s -c /path/to/your/yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]
or
python tools/demo.py image -f exps/default/yolox_s.py -c /path/to/your/yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]
Demo for video:
python tools/demo.py video -n yolox-s -c /path/to/your/yolox_s.pth --path /path/to/your/video --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]
Step1. Prepare COCO dataset
cd <YOLOX_HOME>
ln -s /path/to/your/COCO ./datasets/COCO
Step2. Reproduce our results on COCO by specifying -n:
python -m yolox.tools.train -n yolox-s -d 8 -b 64 --fp16 -o [--cache]
yolox-m
yolox-l
yolox-x
- -d: number of gpu devices
- -b: total batch size, the recommended number for -b is num-gpu * 8
- --fp16: mixed precision training
- --cache: caching imgs into RAM to accelarate training, which need large system RAM.
When using -f, the above commands are equivalent to:
python -m yolox.tools.train -f exps/default/yolox_s.py -d 8 -b 64 --fp16 -o [--cache]
exps/default/yolox_m.py
exps/default/yolox_l.py
exps/default/yolox_x.py
Multi Machine Training
We also support multi-nodes training. Just add the following args:
- --num_machines: num of your total training nodes
- --machine_rank: specify the rank of each node
Suppose you want to train YOLOX on 2 machines, and your master machines's IP is 123.123.123.123, use port 12312 and TCP.
On master machine, run
python tools/train.py -n yolox-s -b 128 --dist-url tcp://123.123.123.123:12312 --num_machines 2 --machine_rank 0
On the second machine, run
python tools/train.py -n yolox-s -b 128 --dist-url tcp://123.123.123.123:12312 --num_machines 2 --machine_rank 1
Logging to Weights & Biases
To log metrics, predictions and model checkpoints to W&B use the command line argument --logger wandb and use the prefix "wandb-" to specify arguments for initializing the wandb run.
python tools/train.py -n yolox-s -d 8 -b 64 --fp16 -o [--cache] --logger wandb wandb-project <project name>
yolox-m
yolox-l
yolox-x
An example wandb dashboard is available here
Others
See more information with the following command:
python -m yolox.tools.train --help
We support batch testing for fast evaluation:
python -m yolox.tools.eval -n yolox-s -c yolox_s.pth -b 64 -d 8 --conf 0.001 [--fp16] [--fuse]
yolox-m
yolox-l
yolox-x
- --fuse: fuse conv and bn
- -d: number of GPUs used for evaluation. DEFAULT: All GPUs available will be used.
- -b: total batch size across on all GPUs
To reproduce speed test, we use the following command:
python -m yolox.tools.eval -n yolox-s -c yolox_s.pth -b 1 -d 1 --conf 0.001 --fp16 --fuse
yolox-m
yolox-l
yolox-x
- Training on custom data
- Caching for custom data
- Manipulating training image size
- Assignment visualization
- Freezing model
Deployment
- MegEngine in C++ and Python
- ONNX export and an ONNXRuntime
- TensorRT in C++ and Python
- ncnn in C++ and Java
- OpenVINO in C++ and Python
- Accelerate YOLOX inference with nebullvm in Python
Third-party resources
- YOLOX for streaming perception: StreamYOLO (CVPR 2022 Oral)
- The YOLOX-s and YOLOX-nano are Integrated into ModelScope. Try out the Online Demo at YOLOX-s and YOLOX-Nano respectively 🚀.
- Integrated into Huggingface Spaces 🤗 using Gradio. Try out the Web Demo:
- The ncnn android app with video support: ncnn-android-yolox from FeiGeChuanShu
- YOLOX with Tengine support: Tengine from BUG1989
- YOLOX + ROS2 Foxy: YOLOX-ROS from Ar-Ray
- YOLOX Deploy DeepStream: YOLOX-deepstream from nanmi
- YOLOX MNN/TNN/ONNXRuntime: YOLOX-MNN、YOLOX-TNN and YOLOX-ONNXRuntime C++ from DefTruth
- Converting darknet or yolov5 datasets to COCO format for YOLOX: YOLO2COCO from Daniel
Cite YOLOX
If you use YOLOX in your research, please cite our work by using the following BibTeX entry:
@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}
}
In memory of Dr. Jian Sun
Without the guidance of Dr. Jian Sun, YOLOX would not have been released and open sourced to the community. The passing away of Dr. Sun is a huge loss to the Computer Vision field. We add this section here to express our remembrance and condolences to our captain Dr. Sun. It is hoped that every AI practitioner in the world will stick to the belief of "continuous innovation to expand cognitive boundaries, and extraordinary technology to achieve product value" and move forward all the way.