(self, frames, depths, cond_times=None)
| 621 | return pred_gs |
| 622 | |
| 623 | def forward(self, frames, depths, cond_times=None): |
| 624 | frames = torch.cat([frames[:, 0:1], frames[:, -1:]], dim=1) # [B, 2, C, H, W] |
| 625 | depths = torch.cat([depths[:, 0:1], depths[:, -1:]], dim=1) # [B, 2, C, H, W] |
| 626 | input_views = frames.shape[1] |
| 627 | frames = rearrange(frames, 'b v c h w -> (b v) 1 c h w') |
| 628 | depths = rearrange(depths, 'b v c h w -> (b v) 1 c h w') |
| 629 | encoder_output = self.forward_encoder(frames, depths) # [B*V, 1, N, D] |
| 630 | encoder_output = rearrange(encoder_output, '(b v) 1 n d -> b v n d', v=input_views) |
| 631 | encoder_0 = encoder_output[:, 0:1] # [B, V, N, D] |
| 632 | encoder_1 = encoder_output[:, -1:] |
| 633 | upsampled_encoder_0 = self.gs_predictor.upsampling(encoder_0) |
| 634 | upsampled_encoder_1 = self.gs_predictor.upsampling(encoder_1) |
| 635 | gs_0, _ = self.gs_predictor.predictor(upsampled_encoder_0) |
| 636 | gs_1, _ = self.gs_predictor.predictor(upsampled_encoder_1) |
| 637 | |
| 638 | if self.opt.use_dino: |
| 639 | frames = rearrange(frames, '(b v) 1 c h w -> b v c h w', v=input_views) |
| 640 | depths = rearrange(depths, '(b v) 1 c h w -> b v c h w', v=input_views) |
| 641 | condition_output = self.forward_condition(frames, depths) # [B, V, N, D] |
| 642 | condition_0 = condition_output[:, 0:1] # [B, V, N, D] |
| 643 | condition_1 = condition_output[:, -1:] |
| 644 | else: |
| 645 | condition_0 = encoder_0 |
| 646 | condition_1 = encoder_1 |
| 647 | |
| 648 | decoder_input = torch.cat([encoder_0, encoder_1], dim=2) # [B, V, 2*N, D] |
| 649 | condition_input = torch.cat([condition_1, condition_0], dim=2) # [B, V, 2*N, D] |
| 650 | decoder_output = self.decoder(decoder_input, condition_input) |
| 651 | decoder_output_0 = decoder_output[:, :, :self.decoder.token_len] # [B, V, N, D] |
| 652 | decoder_output_1 = decoder_output[:, :, self.decoder.token_len:] |
| 653 | |
| 654 | upsampled_dynamic_0 = self.upsampling(decoder_output_0) |
| 655 | upsampled_dynamic_1 = self.upsampling(decoder_output_1) |
| 656 | upsampled_0 = torch.cat([self.encoder_proj(upsampled_encoder_0), upsampled_dynamic_0], dim=-1) |
| 657 | upsampled_1 = torch.cat([self.encoder_proj(upsampled_encoder_1), upsampled_dynamic_1], dim=-1) |
| 658 | gs_0_dynamic, gs_0_prior = self.gs_dynamic_predictor(upsampled_0) |
| 659 | gs_1_dynamic, gs_1_prior = self.gs_dynamic_predictor(upsampled_1) |
| 660 | |
| 661 | for key in ["xyz_dynamic", "opacity_dynamic"]: |
| 662 | gs_0[key] = gs_0_dynamic[key] |
| 663 | gs_1[key] = gs_1_dynamic[key] |
| 664 | |
| 665 | gs_0 = self.combine(gs_0) |
| 666 | gs_1 = self.combine(gs_1) |
| 667 | |
| 668 | # concate gs_0 and gs_1 |
| 669 | pred_gs = {} |
| 670 | for key in gs_0.keys(): |
| 671 | pred_gs[key] = torch.cat([gs_0[key], gs_1[key]], dim=1) |
| 672 | |
| 673 | return {'pred_gs': pred_gs, 'gs_0': gs_0, 'gs_1': gs_1} |
| 674 |
nothing calls this directly
no test coverage detected