MMdetection(个人学习记录)

1.安装

官方说是不正式支持windows的
网上有说torch1.2.0,python3.6 windows10成功的案例
test1:
win10,python3.6,torch 1.5.1,cuda10.2
https://blog.csdn.net/david_lee13/article/details/102940221
1.vs2017安装 https://visualstudio.microsoft.com/downloads.
2. 在pip install .的时候出现了无法定位191于动态链接库 尝试降低torch的办法。
在这里插入图片描述
没用
test2:
win10,python3.6,torch1.2.0,cuda10.2
1.使用cuda10.0的pytorch尝试安装torch1.2.0 ,cuda重装过程太久。
2.conda install pytorch 1.2.0
conda install pytorch
1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
不行
放弃了 不搞cuda。换ubuntu吧。

2.Ubuntu18.04.3 LTS下mmdetection安装

  1. git clone https://github.com/open-mmlab/mmcv.git
  2. cd mmcv
  3. pip install .
  4. cd …
  5. git clone https://github.com/open-mmlab/mmdetection.git
  6. cd mmdetection
  7. python setup.py develop
  8. 网络问题无法安装,retry
  9. Pip出现编码问题(网络问题无法排除)
  10. 联系了it那边 开了服务器外网
  11. Conda create –n xxxenv python=3.7
  12. pip install torch=1.4.0+cu100 torchvision=0.5.0+cu100 –f https://download.pytorch.org/whl/torch_stable.html
  13. pip install mmcv-full
  14. 错误代码daily_bug_pip_install_mmcv-full.txt(daily_bug_xxxenv_pip_install_-e.txt该bug为xxxenv中出的编码错误)
ERROR: Command errored out with exit status 1: /root/anaconda3/envs/xxxenv/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vtg_hbz6/mmcv-full/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vtg_hbz6/mmcv-full/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vemagcan/install-record.txt --single-version-externally-managed --compile --install-headers /root/anaconda3/envs/xxxenv/include/python3.7m/mmcv-full Check the logs for full command output.
  1. g++安装
  2. 服务器source.list替换后,需要使用apt-get updte更行下本地库,出现问题进行修复
  3. Gcc,g++升级至7.5.0
  4. 使用源码安装cd mmcv
  5. MMCV_WITH_OPS=1 pip install -e .
  6. cd mmdetection
  7. pip install -r requirements/build.txt
  8. pip install -v -e .
  9. 编码错误类似zsqenv
  10. 修改txt文件的编码
  11. pip install -v -e .
  12. 完成
    Mmdetection个人数据集训练
  13. 个人数据集准备coco格式
  14. Cd mmdetection
  15. ln -s yourdatadir/coco ./data
  16. 修改./mmdetection/configs/base/models/faster_rcnn_r50_fpn.py中的num_classes
  17. 修改./mmdetection/mmdet/datasets/coco.py 中的类别信息也就是classes
  18. 修改./mmdetection/mmdet/core/evaluation/class_names.py 中的classes
  19. 单卡训练python tools/train.py ./configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py
  20. error:COCO‘ object has no attribute ‘get_cat_ids‘
  21. Cd mmdetection
  22. git checkout 206107 – mmdet/datasets/coco.py
  23. 修改./mmdetection/configs/base/dataset/coco_detection.py
  24. 修改./mmdetection/configs/base/ schedules/ schedules_1x.py
  25. python tools/print_config.py /PATH/TO/CONFIG 用于训练前查看自己参数
  26. 单卡训练python tools/train.py ./configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py
  27. Done

3.Mmdetection个人数据集测试

  1. 测试 python tools/test.py ./configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.py work_dirs/cascade_rcnn_r101_fpn_1x_coco/latest.pth --show-dir test
  2. 错误RuntimeError: unable to stretch file to the right size搞不定自己重新写好了
  3. python demo/webcam_demo.py ${CONFIG_FILE} ${CHECKPOINT_FILE} [–device ${GPU_ID}] [–camera-id ${CAMERA-ID}] [–score-thr ${SCORE_THR}]
  4. 无可视化 demo无法使用
  5. 修改代码 demo/image_demo.py mmdet/apis/inferences.py mmdet/apis/init.py详情见save_img_pyfile
  6. python demo/image_demo.py your_pic_dir your_config your_pth –path your_outfile_dir 单张预测储存
    7.对每一种类别的ap值进行展示 ,修改mmdet/datasets/coco.py中的eval函数 将classwise改成True.
    8.测试python tools/test.py configs/detectors/detectors_cascade_rcnn_r50_1x_coco.py work_dirs2/detectors_cascade_mean_std_2x/epoch_8.pth --eval bbox

4.Mmdetection 不同方法进行训练

方法一:数据集增强ablu
修改./mmdetection/configs/base/dataset/coco_detection.py
注意bbox_param的format 要写pascal_voc,因为坐标在coco.py的地方已经改成xyxy了。
指定gpu 在python train指令最后加入 –gpu-ids 0/1/2/3,前面加CUDA_VISIBLE_DEVICES=1
方法二:图像多尺度训练
修改./mmdetection/configs/base/dataset/coco_detection.py 中train_pipeline的img_scale。例如img_scal =[(1333,800),(1444,900),(2048,2048)]
Batchsize改成1,
多GPU训练 ./tools/dist_train.sh configs/detectors/detectors_cascade_rcnn_r50_1x_coco.py 4 --work-dir work_dirs/detetors_multiscale
方法三:使用ohem
修改mmdet/models/roi_heads/cascade_roi_head.py
/tools/dist_train.sh configs/detectors/detectors_cascade_rcnn_r50_ohem_1x_coco.py 2 --work-dir work_dirs2/detectors-multiscale_ohem/
方法四:修改anchor
xxx/mmdetection/configs/base/models/cascade_rcnn_r50_fpn_anchor.py
python tools/train.py configs/detectors/detectors_cascade_rcnn_r50_1x_coco_anchor.py --work-dir work_dirs2/detectors_default_anchor
参考:https://github.com/open-mmlab/mmdetection
推荐:https://github.com/hhaAndroid/mmdetection-mini

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值