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

慈云数据 2024-04-11 技术支持 51 0

参考

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、问题解决

参考其他博主博文里的

在这里插入图片描述

在这里插入图片描述

微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon