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/

0.3.0发布于 2022-04-22 07:20 UTC10,698star +6 / 7 天2,548fork同步于 2026-11-10 11:29 UTC

怎么上手

由 README 提炼,执行前请确认
git clone [email protected]:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -v -e .
硬件要求按 README 说明

README 未说明最低显存要求;训练与评测命令按 GPU 数量(-d)配置,demo 可通过 --device 选择 cpu 或 gpu;速度基准在 V100 上测得。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

无锚框 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 复现、自定义数据训练与可视化工具文档

容易踩的坑

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

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

4 个版本0.3.0
  1. 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 freeze function 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_trainer method in Exp class #1263

    For pip users

    pip install yolox could 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

  2. 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 yolox could help you to install yolox now.

    Exp design

    YOLOX use Exp as 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.

  3. 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 --cache flag:

    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-x
    

    But for deployment demo, we don't suppor the old weights anymore.

  4. 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 pth instead of tar

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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.
    ModelsizemAPval0.5:0.95mAPtest0.5:0.95Speed V100(ms)Params(M)FLOPs(G)weights
    YOLOX-s64040.540.59.89.026.8github
    YOLOX-m64046.947.212.325.373.8github
    YOLOX-l64049.750.114.554.2155.6github
    YOLOX-x64051.151.517.399.1281.9github
    YOLOX-Darknet5364047.748.011.163.7185.3github
    ModelsizemAPtest0.5:0.95Speed V100(ms)Params(M)FLOPs(G)weights
    YOLOX-s64039.69.89.026.8onedrive/github
    YOLOX-m64046.412.325.373.8onedrive/github
    YOLOX-l64050.014.554.2155.6onedrive/github
    YOLOX-x64051.217.399.1281.9onedrive/github
    YOLOX-Darknet5364047.411.163.7185.3onedrive/github
    Light Models.
    ModelsizemAPval0.5:0.95Params(M)FLOPs(G)weights
    YOLOX-Nano41625.80.911.08github
    YOLOX-Tiny41632.85.066.45github
    ModelsizemAPval0.5:0.95Params(M)FLOPs(G)weights
    YOLOX-Nano41625.30.911.08github
    YOLOX-Tiny41632.85.066.45github

    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
    

    Deployment

    1. MegEngine in C++ and Python
    2. ONNX export and an ONNXRuntime
    3. TensorRT in C++ and Python
    4. ncnn in C++ and Java
    5. OpenVINO in C++ and Python
    6. Accelerate YOLOX inference with nebullvm in Python

    Third-party resources

    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.