YOLOX-部署与测试

YOLOX-部署与测试

YOLOX系列:
YOLOX-入门2-训练-【Reproduce our results on COCO】

我找的YOLOX的GitHub地址:
https://github.com/Megvii-BaseDetection/YOLOX

选择部署的平台:【极链AI云平台】
优势:价格便宜,按实际使用时间扣费,适合学生进行科研探索;使用灵活,即用即停;选择较多,可以选择不同的Pytorch、Python、CUDA版本。
官网:https://cloud.videojj.com
最近好像很多活动,比较优惠,适合学生党,冲鸭!!!!!!!!!!

我这次在【极链AI云平台】上选择的是GeForce RTX 3090机器。

环境配置:
Pytorch 1.8.0, Python 3.8, CUDA 11.1.1

我自己的安装步骤:

cd root
git clone https://github.com/Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -U pip && pip3 install -r requirements.txt
pip3 install -v -e .

# 如果想要训练模型的话一定得装这个apex
# 成功装完apex的话,用pip list查看是能看到的
cd ..
export CUDA_HOME=/usr/local/cuda
git clone https://github.com/NVIDIA/apex
cd apex
pip3 install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

cd ..
# pip3 install cython 这个已存在,运不运行都OK
pip3 install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"

安装以上语句都成功后,在benchmark table下载预训练模型。
我这次随便选了个YOLOX-m。下载下来之后是yolox_m.pth.tar的文件。
不用解压。
直接用FileZilla等工具,上传。
我上传到了/root/YOLOX的路径下。

在这里插入图片描述

-------------------------------更新-------------------------------------
这个可能官方更新了,后来再下载的时候,就直接是pth文件了。
也能用,记得修改【模型的名称】+【模型的路径】,要统一,就好。
在这里插入图片描述
运行语句:

cd YOLOX
python tools/demo.py image -n yolox-m -c /root/YOLOX/yolox_m.pth --path assets/dog.jpg --conf 0.3 --nms 0.65 --tsize 640 --save_result

运行成功后,在/root/YOLOX/YOLOX_outputs/yolox_m/vis_res路径下会输出运行结果图片,图片放在最后了。

注意:
由于本次实验中下载的是YOLOX-m的预训练权重文件。
所以在以上python tools/demo.py语句中:

  1. 修改了-n 后为模型名称:yolox-m。
  2. 修改了-c后为权重文件路径:/root/YOLOX/yolox_m.pth.tar。
  3. 修改了–path后为images or video的路径(此语句中assets/dog.jpg是YOLOX代码中自带的,可以修改成自己想要测试的图的路径)。
  4. 加上–save_result:来保存图片/视频的推断结果
  5. 另外:–conf CONF: test conf
  6. 另外:–nms NMS: test nms threshold
  7. 另外:–tsize TSIZE: test img size

注意:
如果是要测试视频的话,demo.py后的image要改成video。
如下:

python tools/demo.py video -n yolox-m -c /root/YOLOX/yolox_m.pth.tar --path assets/video1.mp4 --conf 0.3 --nms 0.65 --tsize 640 --save_result

demo.py的具体使用方法如下。

root@60f7db4b25e927f40ad75054:~/YOLOX# python tools/demo.py --help
usage: YOLOX Demo! [-h] [-expn EXPERIMENT_NAME] [-n NAME] [--path PATH] [--camid CAMID] [--save_result] [-f EXP_FILE] [-c CKPT]
                   [--conf CONF] [--nms NMS] [--tsize TSIZE] [--fp16] [--fuse] [--trt]
                   demo

positional arguments:
  demo                  demo type, eg. image, video and webcam

optional arguments:
  -h, --help            show this help message and exit
  -expn EXPERIMENT_NAME, --experiment-name EXPERIMENT_NAME
  -n NAME, --name NAME  model name
  --path PATH           path to images or video
  --camid CAMID         webcam demo camera id
  --save_result         whether to save the inference result of image/video
  -f EXP_FILE, --exp_file EXP_FILE
                        pls input your expriment description file
  -c CKPT, --ckpt CKPT  ckpt for eval
  --conf CONF           test conf
  --nms NMS             test nms threshold
  --tsize TSIZE         test img size
  --fp16                Adopting mix precision evaluating.
  --fuse                Fuse conv and bn for testing.
  --trt                 Using TensorRT model for testing.

原图与输出结果图

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
猫咪这张图其实很细节。
在这里插入图片描述

  • 7
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 17
    评论
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值