Skip to content

Commit

Permalink
handle multiple outputs from network being wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jun 3, 2024
1 parent 1ef771e commit 2231ba0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion frame_averaging_pytorch/frame_averaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def forward(

out = self.net(inputs, *args, **kwargs)

# handle if output is a tuple - just follow convention that first output is the one to be frame averaged
# (todo) - handle multiple outputs that need frame averaging

is_multiple_output = isinstance(out, tuple)

if is_multiple_output:
out, *rest = out

# split frames from batch

out = rearrange(out, '(b f) ... -> b f ...', f = num_frames)
Expand All @@ -166,4 +174,8 @@ def forward(
else:
out = rearrange(out, 'b 1 ... -> b ...')

return out
if not is_multiple_output:
return out

return (out, *rest)

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "frame-averaging-pytorch"
version = "0.0.11"
version = "0.0.14"
description = "Frame Averaging"
authors = [
{ name = "Phil Wang", email = "lucidrains@gmail.com" }
Expand Down

0 comments on commit 2231ba0

Please sign in to comment.