Spaces:
Runtime error
Runtime error
import torch | |
from torch import nn | |
from nota_wav2lip.models.base import Wav2LipBase | |
from nota_wav2lip.models.conv import Conv2d, Conv2dTranspose | |
class Wav2Lip(Wav2LipBase): | |
def __init__(self): | |
super().__init__() | |
self.face_encoder_blocks = nn.ModuleList([ | |
nn.Sequential(Conv2d(6, 16, kernel_size=7, stride=1, padding=3)), # 96,96 | |
nn.Sequential(Conv2d(16, 32, kernel_size=3, stride=2, padding=1), # 48,48 | |
Conv2d(32, 32, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(32, 32, kernel_size=3, stride=1, padding=1, residual=True)), | |
nn.Sequential(Conv2d(32, 64, kernel_size=3, stride=2, padding=1), # 24,24 | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True)), | |
nn.Sequential(Conv2d(64, 128, kernel_size=3, stride=2, padding=1), # 12,12 | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True)), | |
nn.Sequential(Conv2d(128, 256, kernel_size=3, stride=2, padding=1), # 6,6 | |
Conv2d(256, 256, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(256, 256, kernel_size=3, stride=1, padding=1, residual=True)), | |
nn.Sequential(Conv2d(256, 512, kernel_size=3, stride=2, padding=1), # 3,3 | |
Conv2d(512, 512, kernel_size=3, stride=1, padding=1, residual=True),), | |
nn.Sequential(Conv2d(512, 512, kernel_size=3, stride=1, padding=0), # 1, 1 | |
Conv2d(512, 512, kernel_size=1, stride=1, padding=0)),]) | |
self.audio_encoder = nn.Sequential( | |
Conv2d(1, 32, kernel_size=3, stride=1, padding=1), | |
Conv2d(32, 32, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(32, 32, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(32, 64, kernel_size=3, stride=(3, 1), padding=1), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(64, 128, kernel_size=3, stride=3, padding=1), | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(128, 256, kernel_size=3, stride=(3, 2), padding=1), | |
Conv2d(256, 256, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(256, 512, kernel_size=3, stride=1, padding=0), | |
Conv2d(512, 512, kernel_size=1, stride=1, padding=0),) | |
self.face_decoder_blocks = nn.ModuleList([ | |
nn.Sequential(Conv2d(512, 512, kernel_size=1, stride=1, padding=0),), | |
nn.Sequential(Conv2dTranspose(1024, 512, kernel_size=3, stride=1, padding=0), # 3,3 | |
Conv2d(512, 512, kernel_size=3, stride=1, padding=1, residual=True),), | |
nn.Sequential(Conv2dTranspose(1024, 512, kernel_size=3, stride=2, padding=1, output_padding=1), | |
Conv2d(512, 512, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(512, 512, kernel_size=3, stride=1, padding=1, residual=True),), # 6, 6 | |
nn.Sequential(Conv2dTranspose(768, 384, kernel_size=3, stride=2, padding=1, output_padding=1), | |
Conv2d(384, 384, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(384, 384, kernel_size=3, stride=1, padding=1, residual=True),), # 12, 12 | |
nn.Sequential(Conv2dTranspose(512, 256, kernel_size=3, stride=2, padding=1, output_padding=1), | |
Conv2d(256, 256, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(256, 256, kernel_size=3, stride=1, padding=1, residual=True),), # 24, 24 | |
nn.Sequential(Conv2dTranspose(320, 128, kernel_size=3, stride=2, padding=1, output_padding=1), | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(128, 128, kernel_size=3, stride=1, padding=1, residual=True),), # 48, 48 | |
nn.Sequential(Conv2dTranspose(160, 64, kernel_size=3, stride=2, padding=1, output_padding=1), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True), | |
Conv2d(64, 64, kernel_size=3, stride=1, padding=1, residual=True),),]) # 96,96 | |
self.output_block = nn.Sequential(Conv2d(80, 32, kernel_size=3, stride=1, padding=1), | |
nn.Conv2d(32, 3, kernel_size=1, stride=1, padding=0), | |
nn.Sigmoid()) | |