in models/encoders.py [0:0]
def __init__(self, latent_dim: int = 128, n_vertices: int = 6172, mean: th.Tensor = None, stddev: th.Tensor = None,
model_name: str = 'expression_encoder'):
"""
:param latent_dim: size of the latent expression embedding before quantization through Gumbel softmax
:param n_vertices: number of face mesh vertices
:param mean: mean position of each vertex
:param stddev: standard deviation of each vertex position
:param model_name: name of the model, used to load and save the model
"""
super().__init__(model_name)
self.n_vertices = n_vertices
shape = (1, 1, n_vertices, 3)
self.register_buffer("mean", th.zeros(shape) if mean is None else mean.view(shape))
self.register_buffer("stddev", th.ones(shape) if stddev is None else stddev.view(shape))
self.layers = th.nn.ModuleList([
th.nn.Linear(self.n_vertices * 3, 256),
th.nn.Linear(256, 128),
])
self.lstm = th.nn.LSTM(input_size=128, hidden_size=128, num_layers=1, batch_first=True)
self.code = th.nn.Linear(128, latent_dim)