(
self,
body_model_train: Optional[Union[dict, None]] = None,
body_model_test: Optional[Union[dict, None]] = None,
convention: Optional[str] = 'human_data',
loss_keypoints2d: Optional[Union[dict, None]] = None,
loss_keypoints3d: Optional[Union[dict, None]] = None,
loss_vertex: Optional[Union[dict, None]] = None,
loss_smpl_pose: Optional[Union[dict, None]] = None,
loss_smpl_betas: Optional[Union[dict, None]] = None,
loss_camera: Optional[Union[dict, None]] = None,
loss_cls: Optional[Union[dict,
None]] = dict(type='CrossEntropyLoss',
bg_cls_weight=0.1,
use_sigmoid=False,
loss_weight=1.0,
class_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=5.0),
loss_iou=dict(type='GIoULoss', loss_weight=2.0),
init_cfg: Optional[Union[list, dict, None]] = None,
train_cfg:
Optional[Union[dict, None]] = dict(assigner=dict(
type='HungarianAssigner',
kp3d_cost=dict(
type='Keypoints3DCost', convention='smpl_54', weight=5.0),
kp2d_cost=dict(
type='Keypoints2DCost', convention='smpl_54', weight=5.0),
# cls_cost=dict(type='ClassificationCost', weight=1.),
# reg_cost=dict(type='BBoxL1Cost', weight=5.0),
# iou_cost=dict(
# type='IoUCost', iou_mode='giou', weight=2.0))
)),
test_cfg: Optional[Union[dict, None]] = None)
| 24 | |
| 25 | class DETRLoss(BaseArchitecture, metaclass=ABCMeta): |
| 26 | def __init__( |
| 27 | self, |
| 28 | body_model_train: Optional[Union[dict, None]] = None, |
| 29 | body_model_test: Optional[Union[dict, None]] = None, |
| 30 | convention: Optional[str] = 'human_data', |
| 31 | loss_keypoints2d: Optional[Union[dict, None]] = None, |
| 32 | loss_keypoints3d: Optional[Union[dict, None]] = None, |
| 33 | loss_vertex: Optional[Union[dict, None]] = None, |
| 34 | loss_smpl_pose: Optional[Union[dict, None]] = None, |
| 35 | loss_smpl_betas: Optional[Union[dict, None]] = None, |
| 36 | loss_camera: Optional[Union[dict, None]] = None, |
| 37 | loss_cls: Optional[Union[dict, |
| 38 | None]] = dict(type='CrossEntropyLoss', |
| 39 | bg_cls_weight=0.1, |
| 40 | use_sigmoid=False, |
| 41 | loss_weight=1.0, |
| 42 | class_weight=1.0), |
| 43 | loss_bbox=dict(type='L1Loss', loss_weight=5.0), |
| 44 | loss_iou=dict(type='GIoULoss', loss_weight=2.0), |
| 45 | init_cfg: Optional[Union[list, dict, None]] = None, |
| 46 | train_cfg: |
| 47 | Optional[Union[dict, None]] = dict(assigner=dict( |
| 48 | type='HungarianAssigner', |
| 49 | kp3d_cost=dict( |
| 50 | type='Keypoints3DCost', convention='smpl_54', weight=5.0), |
| 51 | kp2d_cost=dict( |
| 52 | type='Keypoints2DCost', convention='smpl_54', weight=5.0), |
| 53 | # cls_cost=dict(type='ClassificationCost', weight=1.), |
| 54 | # reg_cost=dict(type='BBoxL1Cost', weight=5.0), |
| 55 | # iou_cost=dict( |
| 56 | # type='IoUCost', iou_mode='giou', weight=2.0)) |
| 57 | )), |
| 58 | test_cfg: Optional[Union[dict, None]] = None): |
| 59 | |
| 60 | super(DETRLoss, self).__init__(init_cfg) |
| 61 | if train_cfg: |
| 62 | assert 'assigner' in train_cfg, 'assigner should be provided '\ |
| 63 | 'when train_cfg is set.' |
| 64 | assigner = train_cfg['assigner'] |
| 65 | # TODO: update these |
| 66 | # assert loss_cls['loss_weight'] == assigner['kp3d_cost']['weight'], \ |
| 67 | # 'The classification weight for loss and matcher should be' \ |
| 68 | # 'exactly the same.' |
| 69 | # assert loss_bbox['loss_weight'] == assigner['kp3d_cost'][ |
| 70 | # 'weight'], 'The regression L1 weight for loss and matcher ' \ |
| 71 | # 'should be exactly the same.' |
| 72 | # assert loss_iou['loss_weight'] == assigner['kp3d_cost']['weight'], \ |
| 73 | # 'The regression iou weight for loss and matcher should be' \ |
| 74 | # 'exactly the same.' |
| 75 | self.assigner = build_assigner(assigner) |
| 76 | # DETR sampling=False, so use PseudoSampler |
| 77 | sampler_cfg = dict(type='PseudoSampler') |
| 78 | self.sampler = build_sampler(sampler_cfg, context=self) |
| 79 | |
| 80 | self.train_cfg = train_cfg |
| 81 | self.test_cfg = test_cfg |
| 82 | |
| 83 | # build loss |
nothing calls this directly
no test coverage detected