MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / tensor2dict

Method tensor2dict

detrsmpl/models/body_models/smpl.py:144–181  ·  view source on GitHub ↗

Convert full pose tensor to pose dict. Args: full_pose (torch.Tensor): shape should be (..., 165) or (..., 55, 3). All zeros for T-pose. betas (Optional[torch.Tensor], optional): shape should be (..., 10). The batch num should be 1 or

(cls,
                    full_pose: torch.Tensor,
                    betas: Optional[torch.Tensor] = None,
                    transl: Optional[torch.Tensor] = None)

Source from the content-addressed store, hash-verified

142
143 @classmethod
144 def tensor2dict(cls,
145 full_pose: torch.Tensor,
146 betas: Optional[torch.Tensor] = None,
147 transl: Optional[torch.Tensor] = None):
148 """Convert full pose tensor to pose dict.
149
150 Args:
151 full_pose (torch.Tensor): shape should be (..., 165) or
152 (..., 55, 3). All zeros for T-pose.
153 betas (Optional[torch.Tensor], optional): shape should be
154 (..., 10). The batch num should be 1 or corresponds with
155 full_pose.
156 Defaults to None.
157 transl (Optional[torch.Tensor], optional): shape should be
158 (..., 3). The batch num should be 1 or corresponds with
159 full_pose.
160 Defaults to None.
161 Returns:
162 dict: dict of smpl pose containing transl & betas.
163 """
164 full_pose = full_pose.view(-1, (cls.NUM_BODY_JOINTS + 1) * 3)
165 body_pose = full_pose[:, 3:]
166 global_orient = full_pose[:, :3]
167 batch_size = full_pose.shape[0]
168 if betas is not None:
169 # squeeze or unsqueeze betas to 2 dims
170 betas = betas.view(-1, betas.shape[-1])
171 if betas.shape[0] == 1:
172 betas = betas.repeat(batch_size, 1)
173 else:
174 betas = betas
175 transl = transl.view(batch_size, -1) if transl is not None else transl
176 return {
177 'betas': betas,
178 'body_pose': body_pose,
179 'global_orient': global_orient,
180 'transl': transl,
181 }
182
183 @classmethod
184 def dict2tensor(cls, smpl_dict: dict) -> torch.Tensor:

Callers 2

_prepare_meshFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected