mmpose记录-config
以configs\body\2d_kpt_sview_rgb_img\deeppose\coco\res50_coco_256x192_rle.py为列
- learning policy
等待补充~
- model setting
model的设置
# model settings
model = dict(
type='TopDown', # 首先模型确定detector,对应任务的明确。此处表从上至下的2D检测方法,其他的有如"mesh"的3D姿态估计的方法
pretrained='torchvision://resnet50', # 预训练选项,默认为none,自己重头训练
backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(3, )),# 由type定了以后需提供的参数,TopDown中需要给出backbone
neck=dict(type='GlobalAveragePooling'), # neck部分,此处RLE中有一个GAP操作故有'GlobalAveragePooling'
keypoint_head=dict( # 检测头部分,后面的部分同上
type='DeepposeRegressionHead',
in_channels=2048,
num_joints=channel_cfg['num_output_channels'],
loss_keypoint=dict( # 不同于backbone常用预训练参数,检测头一般要训练,所以要设置好参数
type='RLELoss',
use_target_weight=True,
size_average=True,
residual=True),
out_sigma=True),
train_cfg=dict(),
test_cfg=dict(flip_test=True, regression_flip_shift=True))
...
以下部分都在mmpose\models 中的不同目录下可找到
TopDown初始化
#TopDown
class TopDown(BasePose):
"""Top-down pose detectors.
Args:
backbone (dict): Backbone modules to extract feature.
keypoint_head (dict): Keypoint head to process feature.
train_cfg (dict): Config for training. Default: None.
test_cfg (dict): Config for testing. Default: None.
pretrained (str): Path to the pretrained models.
loss_pose (None): Deprecated arguments. Please use
`loss_keypoint` for heads instead.
"""
def __init__(self,
backbone,
neck=None,
keypoint_head=None,
train_cfg=None,
test_cfg=None,
pretrained=None,
loss_pose=None):
...
DeepposeRegressionHead初始化
#DeepposeRegressionHead
class DeepposeRegressionHead(nn.Module):
"""Deeppose regression head with fully connected layers.
"DeepPose: Human Pose Estimation via Deep Neural Networks".
Args:
in_channels (int): Number of input channels
num_joints (int): Number of joints
loss_keypoint (dict): Config for keypoint loss. Default: None.
out_sigma (bool): Predict the sigma (the viriance of the joint
location) together with the joint location. Default: False
"""
def __init__(self,
in_channels,
num_joints,
loss_keypoint=None,
out_sigma=False,
train_cfg=None,
test_cfg=None):
...
RLE初始化
#RLE
class RLELoss(nn.Module):
"""RLE Loss.
`Human Pose Regression With Residual Log-Likelihood Estimation
arXiv: <https://arxiv.org/abs/2107.11291>`_.
Code is modified from `the official implementation
<https://github.com/Jeff-sjtu/res-loglikelihood-regression>`_.
Args:
use_target_weight (bool): Option to use weighted MSE loss.
Different joint types may have different target weights.
size_average (bool): Option to average the loss by the batch_size.
residual (bool): Option to add L1 loss and let the flow
learn the residual error distribution.
q_dis (string): Option for the identity Q(error) distribution,
Options: "laplace" or "gaussian"
"""
def __init__(self,
use_target_weight=False,
size_average=True,
residual=True,
q_dis='laplace'):
super(RLELoss, self).__init__()
self.size_average = size_average
self.use_target_weight = use_target_weight
self.residual = residual
self.q_dis = q_dis
self.flow_model = RealNVP()
适当比较,砥砺前行