mmdetection的安装和训练、测试didi数据集的步骤(含结果)

目录

安装pytorch 1.3

安装mmcv

安装mmdet

安装额外的包

安装cocoapi

根据数据集修改文件

将环境持久化

运行didi训练脚本

测试didi数据集

常用ubuntu命令

实验结果图


安装pytorch 1.3

conda create -n open-mmlab python=3.7 -y
conda init bash
conda activate open-mmlab

conda install pytorch=1.3.1 cudatoolkit=9.2 torchvision=0.4.2 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/

安装mmcv

pip install mmcv-full==1.0.5 -f https://download.openmmlab.com/mmcv/dist/cu92/torch1.3.0/index.html

安装mmdet

1、pip install mmdet==2.3.0
#github下载mmdetection的2.3.0版本的源码

安装额外的包

pip install Pillow==6.2.2
pip install cython

安装cocoapi

git+https://github.com/open-mmlab/cocoapi.git  #手动下载离线安装包
python setup.py install

根据数据集修改文件

mmdetection/mmdet/datasets/coco.py #coco修改成自定义数据集类别
mmdetection/mmdet/core/evaluation/class_names.py #coco修改成自定义数据集类别
mmdetection/mmdet/configs/_bash_/models/faster_rcnn_r50_fpn.py #修改类别数,num_classes=12
# 修改方法1:vim ;方法2:cp 到/home/aistdio 可以直接打开
mmdetection/mmdet/datasets/custom.py #注释下面两行
#if self.custom_classes:
#	self.data_infos=self.get_subset_by_classes()

将环境持久化

cp -r open-mmlab/ /home/aistudio/external-libraries #复制
cp -r  /home/aistudio/external-libraries/open-mmlab /opt/conda/env #复制回去
# in ~/.bashrc  或者修改conda env的路径
export CONDA_ENVS_PATH=/home/aistudio/external-libraries/open-mmlab

运行didi训练脚本

python tools/train.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_didi.py
#2、手动下载 https://download.pytorch.org/models/resnet50-19c8e357.pth
#3、复制文件到 cp /home/aistudio/.cache/torch/checkpoints/resnet50-19c8e357.pth

测试didi数据集

python tools/test.py configs/faster_rcnn/faster_rcnn_r50_fpn_soft_nms_1x_didi.py ./work_dirs/faster_rcnn_r50_fpn_soft_nms_1x_didi/latest.pth --format-only --options "jsonfile_prefix=./test_results" --show-dir "./show_result"

# 报错1:ModuleFoundError no module named 'tools'
# 报错1解决方法1:注释掉import tools 和使用的两行,因为if条件没有进去
# 报错1解决方法2:手动将tool文件的函数复制到当前文件中

# 报错2:IndexError:list index out of range 
# 报错2解决:前面的“根据数据集修改文件”

常用ubuntu命令

unzip -oq /home/aistudio/work/mmdetection-2.3.0.zip #解压
cp -r dir1 dir2  # 复制
tar -vcf test.tar test # 压缩
vim filename #编辑:i ;退出编辑:exc ; 保存::wq

实验结果图

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KPer_Yang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值