Spaces:
Sleeping
Sleeping
File size: 1,183 Bytes
5a5e72e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from __future__ import annotations
from torch import nn
DECODER_FEATURE_DIM = 4096
def _make_decoder_heads(
*,
landmark_count: int,
bounded_geometry: bool,
) -> tuple[nn.Linear, nn.Sequential, nn.Linear, nn.Sequential]:
fc3 = nn.Linear(DECODER_FEATURE_DIM, 1000)
geometry_head = nn.Sequential(
nn.Linear(1000, 800),
nn.ReLU(),
nn.Linear(800, 600),
nn.ReLU(),
nn.Linear(600, 400),
nn.ReLU(),
nn.Linear(400, 200),
nn.ReLU(),
nn.Linear(200, landmark_count * 2),
*([nn.Tanh()] if bounded_geometry else []),
)
texture_fc = nn.Linear(1000, 14 * 14 * 256)
texture_decoder = nn.Sequential(
nn.ConvTranspose2d(256, 128, 5, stride=2, padding=2, output_padding=1),
nn.ReLU(),
nn.ConvTranspose2d(128, 64, 5, stride=2, padding=2, output_padding=1),
nn.ReLU(),
nn.ConvTranspose2d(64, 32, 5, stride=2, padding=2, output_padding=1),
nn.ReLU(),
nn.ConvTranspose2d(32, 32, 5, stride=2, padding=2, output_padding=1),
nn.ReLU(),
nn.Conv2d(32, 3, 1),
)
return fc3, geometry_head, texture_fc, texture_decoder
|