diff --git a/mmpose/models/heads/regression_heads/temporal_regression_head.py b/mmpose/models/heads/regression_heads/temporal_regression_head.py index 61e585103f..902be8099e 100644 --- a/mmpose/models/heads/regression_heads/temporal_regression_head.py +++ b/mmpose/models/heads/regression_heads/temporal_regression_head.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. from typing import Optional, Sequence, Tuple, Union -import numpy as np import torch from torch import Tensor, nn -from mmpose.evaluation.functional import keypoint_pck_accuracy +from mmpose.evaluation.functional import keypoint_mpjpe from mmpose.registry import KEYPOINT_CODECS, MODELS from mmpose.utils.tensor_utils import to_numpy from mmpose.utils.typing import (ConfigType, OptConfigType, OptSampleList, @@ -133,14 +132,13 @@ def loss(self, losses.update(loss_pose3d=loss) # calculate accuracy - _, avg_acc, _ = keypoint_pck_accuracy( + mpjpe_err = keypoint_mpjpe( pred=to_numpy(pred_outputs), gt=to_numpy(lifting_target_label), - mask=to_numpy(lifting_target_weight) > 0, - thr=0.05, - norm_factor=np.ones((pred_outputs.size(0), 3), dtype=np.float32)) + mask=to_numpy(lifting_target_weight) > 0) - mpjpe_pose = torch.tensor(avg_acc, device=lifting_target_label.device) + mpjpe_pose = torch.tensor( + mpjpe_err, device=lifting_target_label.device) losses.update(mpjpe=mpjpe_pose) return losses diff --git a/mmpose/models/heads/regression_heads/trajectory_regression_head.py b/mmpose/models/heads/regression_heads/trajectory_regression_head.py index a1608aaae7..b4d02f2ce3 100644 --- a/mmpose/models/heads/regression_heads/trajectory_regression_head.py +++ b/mmpose/models/heads/regression_heads/trajectory_regression_head.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. from typing import Optional, Sequence, Tuple, Union -import numpy as np import torch from torch import Tensor, nn -from mmpose.evaluation.functional import keypoint_pck_accuracy +from mmpose.evaluation.functional import keypoint_mpjpe from mmpose.registry import KEYPOINT_CODECS, MODELS from mmpose.utils.tensor_utils import to_numpy from mmpose.utils.typing import (ConfigType, OptConfigType, OptSampleList, @@ -132,14 +131,13 @@ def loss(self, losses.update(loss_traj=loss) # calculate accuracy - _, avg_acc, _ = keypoint_pck_accuracy( + mpjpe_err = keypoint_mpjpe( pred=to_numpy(pred_outputs), gt=to_numpy(lifting_target_label), - mask=to_numpy(trajectory_weights) > 0, - thr=0.05, - norm_factor=np.ones((pred_outputs.size(0), 3), dtype=np.float32)) + mask=to_numpy(trajectory_weights) > 0) - mpjpe_traj = torch.tensor(avg_acc, device=lifting_target_label.device) + mpjpe_traj = torch.tensor( + mpjpe_err, device=lifting_target_label.device) losses.update(mpjpe_traj=mpjpe_traj) return losses diff --git a/mmpose/models/utils/rtmcc_block.py b/mmpose/models/utils/rtmcc_block.py index bd4929454c..fea4edcb3a 100644 --- a/mmpose/models/utils/rtmcc_block.py +++ b/mmpose/models/utils/rtmcc_block.py @@ -198,13 +198,15 @@ def __init__(self, nn.init.xavier_uniform_(self.uv.weight) - if act_fn == 'SiLU': + if act_fn == 'SiLU' or act_fn == nn.SiLU: assert digit_version(TORCH_VERSION) >= digit_version('1.7.0'), \ 'SiLU activation requires PyTorch version >= 1.7' self.act_fn = nn.SiLU(True) - else: + elif act_fn == 'ReLU' or act_fn == nn.ReLU: self.act_fn = nn.ReLU(True) + else: + raise NotImplementedError if in_token_dims == out_token_dims: self.shortcut = True