Add training code

This commit is contained in:
City
2023-08-15 19:50:45 +02:00
parent ca060b9eca
commit 14c6d8e75e
6 changed files with 342 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import torch
import torch.nn as nn
import numpy as np
class LatentUpscaler(nn.Module):
def __init__(self, fac):
super().__init__()
module_list = [
nn.Conv2d(4, 64, kernel_size=5, padding=2),
nn.ReLU(),
nn.Upsample(scale_factor=fac, mode="nearest"), # bicubic was blurry
nn.ReLU(),
nn.Conv2d(64, 64, kernel_size=7, padding=3),
nn.ReLU(),
nn.Conv2d(64, 64, kernel_size=7, padding=3),
nn.ReLU(),
nn.Conv2d(64, 32, kernel_size=7, padding=3),
nn.ReLU(),
nn.Conv2d(32, 4, kernel_size=5, padding=2),
]
self.sequential = nn.Sequential(*module_list)
def forward(self, x: torch.Tensor) -> torch.Tensor:
return self.sequential(x)