Spaces:
Sleeping
Sleeping
Download s2f/decoder_heads.py from ProgramComputer/Speech2Face: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/ProgramComputer/Speech2Face/resolve/main/s2f/decoder_heads.py
- Command line
-
hf download hf://spaces/ProgramComputer/Speech2Face/s2f/decoder_heads.py
-
curl -L -o decoder_heads.py https://huggingface.co/spaces/ProgramComputer/Speech2Face/resolve/main/s2f/decoder_heads.py
1.18 kB
| 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 | |