|
2 年之前 | |
---|---|---|
.. | ||
_base_ | 2 年之前 | |
README.md | 2 年之前 | |
yolox_l_300e_coco.yml | 2 年之前 | |
yolox_m_300e_coco.yml | 2 年之前 | |
yolox_nano_300e_coco.yml | 2 年之前 | |
yolox_s_300e_coco.yml | 2 年之前 | |
yolox_tiny_300e_coco.yml | 2 年之前 | |
yolox_x_300e_coco.yml | 2 年之前 | |
yoloxv2_tiny_300e_coco.yml | 2 年之前 |
网络网络 | 输入尺寸 | 图片数/GPU | 学习率策略 | 模型推理耗时(ms) | mAPval 0.5:0.95 | mAPval 0.5 | 下载链接 | 配置文件 |
---|---|---|---|---|---|---|---|---|
YOLOX-nano | 416 | 8 | 300e | 2.3 | 26.1 | 42.0 | 下载链接 | 配置文件 |
YOLOX-tiny | 416 | 8 | 300e | 2.8 | 32.9 | 50.4 | 下载链接 | 配置文件 |
YOLOX-s | 640 | 8 | 300e | 3.0 | 40.4 | 59.6 | 下载链接 | 配置文件 |
YOLOX-m | 640 | 8 | 300e | 5.8 | 46.9 | 65.7 | 下载链接 | 配置文件 |
YOLOX-l | 640 | 8 | 300e | 9.3 | 50.1 | 68.8 | 下载链接 | 配置文件 |
YOLOX-x | 640 | 8 | 300e | 16.6 | 51.8 | 70.6 | 下载链接 | 配置文件 |
注意:
nms_top_k
修改为1000
,将keep_top_k
修改为100
,将score_threshold
修改为0.01
,mAP会下降约0.1~0.2%;score_threshold
修改为0.25
,将nms_threshold
修改为0.45
,但mAP会下降较多;--run_benchmark=True
, 你首先需要安装以下依赖pip install pynvml psutil GPUtil
。执行以下指令使用混合精度训练YOLOX
python -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/yolox/yolox_s_300e_coco.yml --amp --eval
注意:
--amp
表示开启混合精度训练以避免显存溢出,--eval
表示边训边验证。执行以下命令在单个GPU上评估COCO val2017数据集
CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams
使用以下命令在单张GPU上预测图片,使用--infer_img
推理单张图片以及使用--infer_dir
推理文件中的所有图片。
# 推理单张图片
CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams --infer_img=demo/000000014439_640x640.jpg
# 推理文件中的所有图片
CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams --infer_dir=demo
YOLOX在GPU上推理部署或benchmark测速等需要通过tools/export_model.py
导出模型。
当你使用Paddle Inference但不使用TensorRT时,运行以下的命令导出模型
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams
当你使用Paddle Inference且使用TensorRT时,需要指定-o trt=True
来导出模型。
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams trt=True
如果你想将YOLOX模型导出为ONNX格式,参考 PaddleDetection模型导出为ONNX格式教程,运行以下命令:
# 导出推理模型
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml --output_dir=output_inference -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams
# 安装paddle2onnx
pip install paddle2onnx
# 转换成onnx格式
paddle2onnx --model_dir output_inference/yolox_s_300e_coco --model_filename model.pdmodel --params_filename model.pdiparams --opset_version 11 --save_file yolox_s_300e_coco.onnx
注意: ONNX模型目前只支持batch_size=1
YOLOX可以使用以下方式进行部署:
运行以下命令导出模型
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams trt=True
注意:
deploy/python/infer.py
使用上述导出后的Paddle Inference模型用于推理和benchnark测速,如果设置了--run_benchmark=True
, 首先需要安装以下依赖pip install pynvml psutil GPUtil
。
# Python部署推理单张图片
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_file=demo/000000014439_640x640.jpg --device=gpu
# 推理文件夹下的所有图片
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_dir=demo/ --device=gpu
deploy/cpp/build/main
使用上述导出后的Paddle Inference模型用于C++推理部署, 首先按照docs编译安装环境。
# C++部署推理单张图片
./deploy/cpp/build/main --model_dir=output_inference/yolox_s_300e_coco/ --image_file=demo/000000014439_640x640.jpg --run_mode=paddle --device=GPU --threshold=0.5 --output_dir=cpp_infer_output/yolox_s_300e_coco
为了公平起见,在模型库中的速度测试结果均为不包含数据预处理和模型输出后处理(NMS)的数据(与YOLOv4(AlexyAB)测试方法一致),需要在导出模型时指定-o exclude_nms=True
。测速需设置--run_benchmark=True
, 首先需要安装以下依赖pip install pynvml psutil GPUtil
。
使用Paddle Inference但不使用TensorRT进行测速,执行以下命令:
# 导出模型
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams exclude_nms=True
# 速度测试,使用run_benchmark=True
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_file=demo/000000014439_640x640.jpg --run_mode=paddle --device=gpu --run_benchmark=True
使用Paddle Inference且使用TensorRT进行测速,执行以下命令:
# 导出模型,使用trt=True
python tools/export_model.py -c configs/yolox/yolox_s_300e_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/yolox_s_300e_coco.pdparams exclude_nms=True trt=True
# 速度测试,使用run_benchmark=True
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_file=demo/000000014439_640x640.jpg --device=gpu --run_benchmark=True
# tensorRT-FP32测速
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_file=demo/000000014439_640x640.jpg --device=gpu --run_benchmark=True --trt_max_shape=640 --trt_min_shape=640 --trt_opt_shape=640 --run_mode=trt_fp32
# tensorRT-FP16测速
python deploy/python/infer.py --model_dir=output_inference/yolox_s_300e_coco --image_file=demo/000000014439_640x640.jpg --device=gpu --run_benchmark=True --trt_max_shape=640 --trt_min_shape=640 --trt_opt_shape=640 --run_mode=trt_fp16
注意:
-o exclude_nms=True
仅作为测速时用,这样导出的模型其推理部署预测的结果不是最终检出框的结果。 @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}
}
网络网络 | 输入尺寸 | 图片数/GPU | 学习率策略 | 模型推理耗时(ms) | mAPval 0.5:0.95 | mAPval 0.5 | 下载链接 | 配置文件 |
---|---|---|---|---|---|---|---|---|
YOLOXv2-tiny | 416 | 8 | 300e | 1.9 | 32.4 | 50.2 | 下载链接 | 配置文件 |