当前位置:网站首页>Configure MMdetection environment and train
Configure MMdetection environment and train
2022-07-30 07:08:00 【Amber Bright】
配置MMdetection环境(以VFNet为例)
It is recommended to use the official website method first,链接放在下面了!
https://github.com/open-mmlab/mmdetection/blob/master/docs/get_started.md
1、先创建一个conda环境并激活它
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
2、安装PyTorch 和 torchvision,
根据cuda和pytorch版本安装(我的版本是cuda11.0和torch1.7.0)
conda install pytorch torchvision -c pytorch
conda install pytorch cudatoolkit=11.0 torchvision -c pytorch
3、安装mmcv-full
根据cuda和pytorch版本安装(我的版本是cuda11.0和torch1.7.0).mmcvIf the version configuration is incorrect, the model cannot be trained normally,Be sure to use the correct version.
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
4、安装pycocotools
Although the official website does not require installation,But I am getting error missingpycocotools.
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
或者https://github.com/philferriere/cocoapi下载源码,并进行解压.切换到 cocoapi\PythonAPI目录.运行:
python setup.py build_ext install
然后cdto your own path,安装mmdetection
5、mmdetection安装和编译
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e. # or "python setup.py develop".
到这里为止,环境的配置就完成了.Start preparing the dataset
6、使用自己的coco格式数据集
All officially provided code is used by defaultcoco格式的数据集,I also use it herecoco格式的数据集.Various types of data transfercocoSee format script:
https://github.com/spytensor/prepare_detection_dataset
mmdetection
├── mmdet
├── tools
├── configs
├── data
│ ├── coco
│ │ ├── annotations
│ │ ├── train2017
│ │ ├── val2017
│ │ ├── test2017
7、Some parameters need to be changed before training
1)定义数据种类,The place that needs to be modified is heremmdetection/mmdet/datasets/coco.py.把CLASSES的那个tuple改为自己数据集对应的种类tuple即可.
CLASSES = ('liner', 'bulk carrier', 'container ship', 'other ship')
2)接着在mmdetection/mmdet/core/evaluation/class_names.py修改coco_classes数据集类别,This is related to the backtestThe category name displayed in the resulting graph when
3)修改configs/vfnet/vfnet_x101_64x4d_fpn_mstrain_2x_coco.py中的model字典中的num_classes、data字典中的img_scale和optimizer中的lr(学习率).例如:
num_classes=4,#类别数
optimizer = dict(type='SGD', lr=0.0025, momentum=0.9, weight_decay=0.0001)
当gpu数量为8时,lr=0.02;当gpu数量为4时,lr=0.01;我只要一个gpu,所以设置lr=0.0025
训练完之后work_dirs文件夹中会保存下训练过程中的log日志文件、每个epoch的pth文件(这个文件将会用于后面的test测试)
8、开始训练
单个GPU(Not distributed):
#Train the model from the start
python tools/train.py configs/vfnet/vfnet_x101_64x4d_fpn_mstrain_2x_coco.py
#Continue training from the breakpoint weights file
python tools/train.py configs/vfnet/vfnet_x101_64x4d_fpn_mstrain_2x_coco.py --resume-from="work_dirs/yy.pth"
resume_from和load_from之间的区别: resume_from加载模型权重和优化器状态,并且epoch也从指定的检查点继承.它通常用于恢复意外中断的训练过程. load_from仅加载模型权重,训练时期从0开始.通常用于微调.
9、测试
(1)If you just want to see the effect and don't do quantitative indicator analysis,Can run the previous onedemo.py文件,But change itcheckpoint_file的地址路径,Use what we ran out of the previous stepwork_dirs下的pth文件.例如checkpoint_file = 'work_dirs/epoch_100.pth
(2)使用testcommand to perform a test to evaluate some parameters
python tools/test.py configs/vfnet/vfnet_x101_64x4d_fpn_mstrain_2x_coco.py work_dirs/latest.pth --out ./result/result_100.pkl --eval bbox
Put a picture of the result of my training(The dataset used is its own,single class 2万多张)
VFNet X-101-64x4d (mAP 91.7%)
10、报错和解决
1)修改config里面的num_calss之后报错:
重新编译
python setup.py install
要是还不行,先卸载mmdet,再重新编译
pip uninstall mmdet
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop".
Modifications will be added later!
边栏推荐
- Using PyQt5 to add an interface to YoloV5 (1)
- Flink-stream/batch/OLAP integrated to get Flink engine
- 无人机生态环境监测、图像处理与GIS数据分析
- 八、Kotlin基础学习:1、数据类;2、单例;3、伴生对象;4、密封类;
- "MySQL Advanced Chapter" four, the storage structure of the index
- Flink-流/批/OLAP一体得到Flink引擎
- MySQL index optimization and failure scenarios
- 为什么会出现梯度爆炸和梯度消失现象?怎么缓解这种现象的发生?
- MYSQL一站式学习,看完即学完
- 十七、Kotlin进阶学习:1、守护线程;2、线程和协程之间的效率对比;3、取消协程;
猜你喜欢
Reasons and solutions for Invalid bound statement (not found)
二叉树(一):深度优先遍历与广度优先遍历
Twenty-two, Kotlin advanced learning: simply learn RecyclerView to achieve list display;
Trust anchor for certification path not found.异常解决方法。
Flink-流/批/OLAP一体得到Flink引擎
边境的悍匪—机器学习实战:第六章 决策树
CLUE模型构建方法、模型验证及土地利用变化情景预测
TDengine cluster construction
Self-augmented Unpaired Image Dehazing via Density and Depth Decomposition程序运行记录
卷积神经网络(CNN)之卷积操作、池化操作、激活函数
随机推荐
MySQL - Multi-table query and case detailed explanation
Biome-BGC 生态系统模型与应用
AAcell五号文档室——跨平台文件传输的小室一间一间的
mysql删除表中重复数据,(只保留一行)
shardingsphere 分库分表及配置示例
GraphQL(一)基础介绍及应用示例
mysql is not an internal or external command, nor is it a runnable program or batch file to resolve
基于全球模式比较计划CMIP6与区域气候-化学耦合模式 WRF-Chem 的未来大气污染变化模拟
XMLBean的基础运用
nodejs PM2监控及报警邮件发送(二)
GraphQL (1) Basic introduction and application examples
边境的悍匪—机器学习实战:第八章 降维
Servlet basic principles and application of common API methods
目标检测中的知识蒸馏方法
Knowledge distillation method of target detection
Detailed explanation of regular expression syntax and practical examples
Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型
正则表达式语法详解及实用实例
Flink CDC implements Postgres to MySQL streaming processing transmission case
Arthas command parsing (watch/tt/sc)