复现tph-yolov5

Object Detection on Drone-captured Scenarios)

大四寒假,第三篇复现的论文。环境是从autodl租的3090,跑完这个程序大概23小时,费用56元。(不包含调参数的时间)(autodl调参数可以用无GPU模式,一小时一毛)

先阅读github提供的运行步骤:
https://github.com/cv516Buaa/tph-yolov5

Install(安装)

$ git clone https://github.com/cv516Buaa/tph-yolov5
$ cd tph-yolov5
$ pip install -r requirements.txt

Convert labels(转换标签)

VisDrone2YOLO_lable.py transfer VisDrone annotiations to yolo labels.

You should set the path of VisDrone dataset in VisDrone2YOLO_lable.py first.

$ python VisDrone2YOLO_lable.py
(这个语句的意思是把VisDrone数据集的标签形式转换成yolo的标签形式,VisDrone的标签在annotation文件夹中,转换后的文件夹是labels)
这个文件中的地址要进行修改的,分别在train、test、val三个地址对应的目录下都运行一遍,最后分别在train、test、val生成三个labels文件夹,就完成了这一步

Inference

Datasets : VisDrone
Weights (PyTorch v1.10):
yolov5l-xs-1.pt: | Baidu Drive(pw: vibe). | Google Drive |
yolov5l-xs-2.pt: | Baidu Drive(pw: vffz). | Google Drive |
val.py runs inference on VisDrone2019-DET-val, using weights trained with TPH-YOLOv5.

(We provide two weights trained by two different models based on YOLOv5l.)

$ python val.py –weights ./weights/yolov5l-xs-1.pt –img 1996 –data ./data/VisDrone.yaml –augment –save-txt –save-conf –task val –batch-size 8 –verbose –name v5l-xs

或者
$ python val.py –weights ./weights/yolov5l-xs-2.pt –img 1996 –data ./data/VisDrone.yaml –augment –save-txt –save-conf –task val –batch-size 8 –verbose –name v5l-xs

因为她提供了两个模型,都可以测试一下

If you inference dataset with different models, then you can ensemble the result by weighted boxes fusion using wbf.py.

You should set img path and txt path in wbf.py.

$ python wbf.py

train.py allows you to train new model from strach.

$ python train.py –img 1536 –adam –batch 4 –epochs 80 –data ./data/VisDrone.yaml –weights yolov5l.pt –hy data/hyps/hyp.VisDrone.yaml –cfg models/yolov5l-xs-tph.yaml –name v5l-xs-tph

我用的24G显存的3090训练的刚好占用22.4G显存,如果显卡显存太小,可以调batch为2或者1,这样时间可能会翻倍,但是不会出现 cuda out of memery

因为这个程序按照我的3090来运行,用时23小时,中途如果网络断了,那么远程连接的GPU服务器的python就会自动停止,这里我用了nohup来挂起python程序,输出log,语句:
nohup python -u train.py –img 1536 –adam –batch 4 –epochs 80 –data ./data/VisDrone.yaml –weights yolov5l.pt –hy data/hyps/hyp.VisDrone.yaml –cfg models/yolov5l-xs-tph.yaml –name v5l-xs-tph >yolov5.log 2>&1 &

train.py是你的程序 加粗部分是整体,
yolov5.log是你挂起后输出log的文件名
别的暂时不用管

也可以在语句最后加入shutdown运行自动关机功能(我没用),这样省钱,或者你人工盯着log看(我就是这么做的)

最后,目标检测方向,暂时 遥感领域+transformer,欢迎交流

Original: https://blog.csdn.net/weixin_44298961/article/details/122764145
Author: 吃肉不能购
Title: 复现tph-yolov5

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/681442/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球