medusa.recon.flame.mica.encoders#

Encoders specific to MICA.

For the associated license, see license.md.

Module Contents#

class medusa.recon.flame.mica.encoders.MicaEncoder(device=DEVICE)[source]#

A FLAME-based encoder for MICA models.

Parameters:

device (str) – Name for the device to use

forward(imgs)[source]#

Predicts FLAME shape components for a batch of images.

Parameters:

imgs (torch.tensor) – A batch of images of shape (N, C, H, W)

Returns:

shape_code – A batch of shape codes of shape (N, 300)

Return type:

torch.tensor

medusa.recon.flame.mica.encoders.conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1)[source]#

3x3 convolution with padding.

medusa.recon.flame.mica.encoders.conv1x1(in_planes, out_planes, stride=1)[source]#

1x1 convolution.

class medusa.recon.flame.mica.encoders.IBasicBlock(inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1)[source]#

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

expansion = 1#
forward(x)[source]#
class medusa.recon.flame.mica.encoders.IResNet(block, layers, dropout=0, num_features=512, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, fp16=False)[source]#

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

fc_scale#
forward(x)[source]#
class medusa.recon.flame.mica.encoders.Arcface(pretrained_path=None, **kwargs)[source]#

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

freezer(layers)[source]#
forward(x)[source]#
medusa.recon.flame.mica.encoders.kaiming_leaky_init(m)[source]#
class medusa.recon.flame.mica.encoders.MappingNetwork(z_dim=512, map_hidden_dim=300, map_output_dim=300)[source]#

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

forward(z)[source]#