MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / forward

Method forward

examples/utils.py:30–50  ·  view source on GitHub ↗

Adjust camera pose based on deltas. Args: camtoworlds: (..., 4, 4) embed_ids: (...,) Returns: updated camtoworlds: (..., 4, 4)

(self, camtoworlds: Tensor, embed_ids: Tensor)

Source from the content-addressed store, hash-verified

28 torch.nn.init.normal_(self.embeds.weight, std=std)
29
30 def forward(self, camtoworlds: Tensor, embed_ids: Tensor) -> Tensor:
31 """Adjust camera pose based on deltas.
32
33 Args:
34 camtoworlds: (..., 4, 4)
35 embed_ids: (...,)
36
37 Returns:
38 updated camtoworlds: (..., 4, 4)
39 """
40 assert camtoworlds.shape[:-2] == embed_ids.shape
41 batch_shape = camtoworlds.shape[:-2]
42 pose_deltas = self.embeds(embed_ids) # (..., 9)
43 dx, drot = pose_deltas[..., :3], pose_deltas[..., 3:]
44 rot = rotation_6d_to_matrix(
45 drot + self.identity.expand(*batch_shape, -1)
46 ) # (..., 3, 3)
47 transform = torch.eye(4, device=pose_deltas.device).repeat((*batch_shape, 1, 1))
48 transform[..., :3, :3] = rot
49 transform[..., :3, 3] = dx
50 return torch.matmul(camtoworlds, transform)
51
52
53class AppearanceOptModule(torch.nn.Module):

Callers

nothing calls this directly

Calls 1

rotation_6d_to_matrixFunction · 0.85

Tested by

no test coverage detected