MCPcopy Create free account
hub / github.com/deepbrainai-research/float / forward

Method forward

models/float/styledecoder.py:487–526  ·  view source on GitHub ↗
(self, wa, alpha, feats)

Source from the content-addressed store, hash-verified

485 self.n_latent = self.log_size * 2 - 2
486
487 def forward(self, wa, alpha, feats):
488 bs = wa.shape[0]
489
490 if alpha is not None:
491 if len(alpha) > 1:
492 directions_target = self.direction(alpha[0]) # target
493 directions_source = self.direction(alpha[1]) # source
494 directions_start = self.direction(alpha[2]) # start
495 latent = wa + (directions_target - directions_start) + directions_source
496 else:
497 directions = self.direction(alpha[0])
498 latent = wa + directions # wa + directions
499 else:
500 latent = wa
501
502 inject_index = self.n_latent
503 latent = latent.unsqueeze(1).repeat(1, inject_index, 1)
504
505 out = self.input(latent)
506 out = self.conv1(out, latent[:, 0])
507
508 i = 1
509 for conv1, conv2, to_rgb, to_flow, feat in zip(self.convs[::2], self.convs[1::2], self.to_rgbs,
510 self.to_flows, feats):
511 out = conv1(out, latent[:, i])
512 out = conv2(out, latent[:, i + 1])
513 if out.size(2) == 8:
514 out_warp, out, skip_flow, _ = to_flow(out, latent[:, i + 2], feat)
515 skip = to_rgb(out_warp)
516 elif out.size(2) == 64:
517 out_warp, out, skip_flow, flow = to_flow(out, latent[:, i + 2], feat, skip_flow)
518 skip = to_rgb(out_warp, skip)
519 else:
520 out_warp, out, skip_flow, _ = to_flow(out, latent[:, i + 2], feat, skip_flow)
521 skip = to_rgb(out_warp, skip)
522 i += 2
523
524 img = skip
525
526 return img, flow
527
528 def synthesis(self, wa, feats):
529 bs = wa.shape[0]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected