Closed LjIA26 closed 1 year ago
Hi @LjIA26, thanks for using MMPose. Do all instances in your dataset have the same number of keypoints?
Hello, Yes! all of them have 100 keypoints.
The reported error indicates that some instances have 17 keypoints while others have 100 keypoints. Could you provide more details about the config file you're using so we can help find where the problem is?
The base model I am using as based uses 17 keypoints for the coco dataset. My custom dataset has 100 keypoints, all of the images have 100 keypoints, which sometimes they are zero.
_base_ = [
'./_base_/default_runtime.py',
'./_base_/datasets/plants4.py'
]
**_runtime_**
train_cfg = dict(max_epochs=5, val_interval=2)
**_optimizer_**
optim_wrapper = dict(optimizer=dict(
type='Adam',
lr=5e-4,
))
**_learning policy_**
param_scheduler = [
dict(
type='LinearLR', begin=0, end=500, start_factor=0.001,
by_epoch=False), # warm-up
dict(
type='MultiStepLR',
begin=0,
end=210,
milestones=[170, 200],
gamma=0.1,
by_epoch=True)
]
**automatically scaling LR based on the actual training batch size**
auto_scale_lr = dict(base_batch_size=512)
**hooks**
default_hooks = dict(checkpoint=dict(save_best='coco/AP', rule='greater'))
** codec settings**
codec = dict(
type='MSRAHeatmap', input_size=(192, 256), heatmap_size=(48, 64), sigma=2)
**model settings**
model = dict(
type='TopdownPoseEstimator',
data_preprocessor=dict(
type='PoseDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
bgr_to_rgb=True),
backbone=dict(
type='HRNet',
in_channels=3,
extra=dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, )),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(32, 64)),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(32, 64, 128)),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(32, 64, 128, 256))),
init_cfg=None,
),
head=dict(
type='HeatmapHead',
in_channels=32,
out_channels=100,
deconv_out_channels=None,
loss=dict(type='KeypointMSELoss', use_target_weight=True),
decoder=codec),
test_cfg=dict(
flip_test=True,
flip_mode='heatmap',
shift_heatmap=True,
))
** base dataset settings**
dataset_type = 'CocoDataset'
data_mode = 'topdown'
data_root = 'data/plants/'
__** pipelines**__
train_pipeline = [
dict(type='LoadImage', file_client_args={{_base_.file_client_args}}),
dict(type='GetBBoxCenterScale'),
dict(type='RandomFlip', direction='horizontal'),
dict(type='RandomHalfBody'),
dict(type='RandomBBoxTransform'),
dict(type='TopdownAffine', input_size=codec['input_size']),
dict(type='GenerateTarget', target_type='heatmap', encoder=codec),
dict(type='PackPoseInputs')
]
val_pipeline = [
dict(type='LoadImage', file_client_args={{_base_.file_client_args}}),
dict(type='GetBBoxCenterScale'),
dict(type='TopdownAffine', input_size=codec['input_size']),
dict(type='PackPoseInputs')
]
**data loaders**
train_dataloader = dict(
batch_size=64,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_mode=data_mode,
ann_file='annotations/converted-batch3.json',
data_prefix=dict(img='images/'),
pipeline=train_pipeline,
))
val_dataloader = dict(
batch_size=32,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False, round_up=False),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_mode=data_mode,
ann_file='annotations/converted-test-14.json',
# bbox_file='data/plants/person_detection_results/'
# 'test-bbox.json',
data_prefix=dict(img='validation/'),
test_mode=True,
pipeline=val_pipeline,
))
test_dataloader = val_dataloader
** evaluators**
val_evaluator = dict(
type='CocoMetric',
ann_file=data_root + 'annotations/converted-test-14.json')
test_evaluator = val_evaluator
Edited previous comment to improve readability
I believe the issue is that CocoDataset
utilizes the meta information of the COCO dataset, in which instances have 17 keypoints, and thus it adopts the flip_index
defined for COCO. When an instance is flipped horizontally, only 17 keypoints in the same order as flip_index
will remain.
In MMPose 1.0, CocoDataset
will use dataset information defined in configs/_base_/datasets/coco.py
by default. If you want to use another dataset meta information file such as configs/_base_/datasets/plants4.py
, you need to specify it like:
train_dataloader = dict(
batch_size=64,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_mode=data_mode,
metainfo=dict(from_file='configs/_base_/datasets/plants4.py'),
ann_file='annotations/converted-batch3.json',
data_prefix=dict(img='images/'),
pipeline=train_pipeline,
))
val_dataloader = dict(
batch_size=32,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False, round_up=False),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_mode=data_mode,
ann_file='annotations/converted-test-14.json',
metainfo=dict(from_file='configs/_base_/datasets/plants4.py'),
# bbox_file='data/plants/person_detection_results/'
# 'test-bbox.json',
data_prefix=dict(img='validation/'),
test_mode=True,
pipeline=val_pipeline,
))
test_dataloader = val_dataloader
Thank you for pointing out this problem. We will refine the documents to ensure that the instructions are more explicit.
Thank you! One more question. It is not printing the train accuracy data, only the validation result. How do I turn that on?
It is not printing the train accuracy data, only the validation result
Does the program prints training loss? If not, you can try to reduce the log interval by setting
default_hooks = dict(
logger=dict(type='LoggerHook', interval=1),
checkpoint=dict(save_best='coco/AP', rule='greater')
)
in your config.
That worked, thank you. Training is slower btw and for some reason, every epoch is now divided in 4 subepochs, and they are all printed like 1 [1/4], 1 [2/4], 1 [3/4], 1 [4/4].... and then to the next epoch. It didn't do that last version. Why is it different now?
4 means you have 4 iterations in each epoch.
logger=dict(type='LoggerHook', interval=1)
, interval=1 means print the log every iteration. By default, the number is larger than 4, so you can't see the prints.
Thanks for your error report and we appreciate it a lot. If you feel we have helped you, give us a STAR! :satisfied:
Checklist
Describe the bug
I switched to the new version of mmpose, from 0.28 to 1.0, and used the same steps to create a config file and datasets as the previous version, making sure I follow the new configuration. However, I get the following error.
Reproduction
Environment
$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)Error traceback
If applicable, paste the error traceback here.
Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!