人工智能学习07–pytorch23–目标检测:Deformable-DETR训练自己的数据集

参考

https://blog.csdn.net/qq_44808827/article/details/125326909

https://blog.csdn.net/dystsp/article/details/125949720?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-125949720-blog-125326909.235^v38^pc_relevant_sort_base2&spm=1001.2101.3001.4242.1&utm_relevant_index=3

https://blog.csdn.net/m0_49752107/article/details/129887028

https://www.jianshu.com/p/b364534fd0a7

https://blog.csdn.net/u010826850/article/details/117325848

https://pytorch.org/get-started/previous-versions/

环境准备

1、pytorch
conda create -n deformable_detr python=3.9 pip

2、激活环境
conda activate deformable_detr

3、torch

# CUDA 11.6
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
# CUDA 11.3
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

4、其他的库
pip install -r requirements.txt

5、编译CUDA
cd ./models/ops
sh ./make.sh
#unit test (should see all checking is True)
python test.py (我没运行这一步)

主要是MultiScaleDeformableAttention包,如果中途换了torch版本,需要重新编译cuda,得到一个新的这个包,不然报错。

准备数据集

1、把自己的数据集放在coco文件夹里面

或者改改这里:

2、在main.py文件里面改分类数


deformable-detr 也是需要一个背景类,num_class+1

3、pth预训练文件

r50上coco数据集训练结果文件
要翻墙,或者:
下载链接:https://download.csdn.net/download/u010826850/21980492
好人一生平安

4、根据自己的数据集修改pth

新建一个文件:

5、main.py


改成这样:

7、修改参数

8、问题解决

参考其他博主博文里的

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年9月15日
下一篇 2023年9月15日

相关推荐