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 pytorch1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
不行
放弃了 不搞cuda。换ubuntu吧。
2.Ubuntu18.04.3 LTS下mmdetection安装
- git clone https://github.com/open-mmlab/mmcv.git
- cd mmcv
- pip install .
- cd …
- git clone https://github.com/open-mmlab/mmdetection.git
- cd mmdetection
- python setup.py develop
- 网络问题无法安装,retry
- Pip出现编码问题(网络问题无法排除)
- 联系了it那边 开了服务器外网
- Conda create –n xxxenv python=3.7
- pip install torch=1.4.0+cu100 torchvision=0.5.0+cu100 –f https://download.pytorch.org/whl/torch_stable.html
- pip install mmcv-full
- 错误代码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.
- g++安装
- 服务器source.list替换后,需要使用apt-get updte更行下本地库,出现问题进行修复
- Gcc,g++升级至7.5.0
- 使用源码安装cd mmcv
- MMCV_WITH_OPS=1 pip install -e .
- cd mmdetection
- pip install -r requirements/build.txt
- pip install -v -e .
- 编码错误类似zsqenv
- 修改txt文件的编码
- pip install -v -e .
- 完成
Mmdetection个人数据集训练 - 个人数据集准备coco格式
- Cd mmdetection
- ln -s yourdatadir/coco ./data
- 修改./mmdetection/configs/base/models/faster_rcnn_r50_fpn.py中的num_classes
- 修改./mmdetection/mmdet/datasets/coco.py 中的类别信息也就是classes
- 修改./mmdetection/mmdet/core/evaluation/class_names.py 中的classes
- 单卡训练python tools/train.py ./configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py
- error:COCO‘ object has no attribute ‘get_cat_ids‘
- Cd mmdetection
- git checkout 206107 – mmdet/datasets/coco.py
- 修改./mmdetection/configs/base/dataset/coco_detection.py
- 修改./mmdetection/configs/base/ schedules/ schedules_1x.py
- python tools/print_config.py /PATH/TO/CONFIG 用于训练前查看自己参数
- 单卡训练python tools/train.py ./configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py
- Done
3.Mmdetection个人数据集测试
- 测试 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
- 错误RuntimeError: unable to stretch file to the right size搞不定自己重新写好了
- python demo/webcam_demo.py ${CONFIG_FILE} ${CHECKPOINT_FILE} [–device ${GPU_ID}] [–camera-id ${CAMERA-ID}] [–score-thr ${SCORE_THR}]
- 无可视化 demo无法使用
- 修改代码 demo/image_demo.py mmdet/apis/inferences.py mmdet/apis/init.py详情见save_img_pyfile
- 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