我计划使用mmpose去训练牛的数据集,使用的py文件是configs/animal_2d_keypoint/topdown_heatmap/animalpose/td-hm_res50_8xb64-210e_animalpose-256x256.py。运行的代码是python tools/train.py configs/animal_2d_keypoint/topdown_heatmap/animalpose/td-hm_res50_8xb64-210e_animalpose-256x256.py,现在已修改mmpose\configs\animal_2d_keypoint\topdown_heatmap\animalpose\td-hm_res50_8xb64-210e_animalpose-256x256.py文件、mmpose\configs\_base_\datasets\animalpose.py文件、mmpose\configs\_base_\default_runtime.py。设置了四个关键点分别是head、nose、back和tail,你从头开始给我一份完整的修改方案,让我训练模型
时间: 2024-02-18 10:03:28 浏览: 117
mmcv-1.3.8编译源码
好的,以下是你可以参考的完整修改方案:
1. 修改 animal_2d_keypoint/topdown_heatmap/animalpose/td-hm_res50_8xb64-210e_animalpose-256x256.py 文件:
```
# 修改默认头文件
_head_ = ['head', 'nose', 'back', 'tail']
# 修改num_joints为4
model = dict(
type='TopDown',
pretrained='torchvision://resnet50',
backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(3, )),
keypoint_head=dict(
type='TopdownHeatmapSimpleHead',
in_channels=2048,
out_channels=4,
loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)),
train_cfg=dict(),
test_cfg=dict(
flip_test=True,
post_process='unbiased',
shift_heatmap=True,
modulate_kernel=11))
# 修改数据集路径和类别数目
data_root = 'data/animalpose/'
data = dict(
samples_per_gpu=64,
workers_per_gpu=2,
train=dict(
type='AnimalPoseDataset',
ann_file=data_root + 'annotations/train.json',
img_prefix=data_root + 'images/',
data_cfg=data_cfg,
pipeline=train_pipeline),
val=dict(
type='AnimalPoseDataset',
ann_file=data_root + 'annotations/val.json',
img_prefix=data_root + 'images/',
data_cfg=data_cfg,
pipeline=test_pipeline),
test=dict(
type='AnimalPoseDataset',
ann_file=data_root + 'annotations/test.json',
img_prefix=data_root + 'images/',
data_cfg=data_cfg,
pipeline=test_pipeline))
# 修改类别数目
classes = ('animal',)
num_joints = 4
```
2. 修改 _base_/datasets/animalpose.py 文件:
```
# 修改默认头文件和关键点数目
_head_ = ['head', 'nose', 'back', 'tail']
num_joints = 4
# 修改数据集类别数目和关键点名称
class_names = ['animal']
keypoint_names = ['head', 'nose', 'back', 'tail']
```
3. 修改 _base_/default_runtime.py 文件:
```
# 修改默认头文件
_head_ = ['head', 'nose', 'back', 'tail']
```
修改完成后,你可以使用以下命令启动训练:
```
python tools/train.py configs/animal_2d_keypoint/topdown_heatmap/animalpose/td-hm_res50_8xb64-210e_animalpose-256x256.py
```
希望这份修改方案对你有帮助。
阅读全文