repos
/ ai-art master

ai-art

mirror archived upstream

Art generation with VQGAN + CLIP in Docker, with a simple web UI for anyone with a GPU. A simplified and expanded take on Kevin Costa's work.

aiai-artclipdockerdocker-composegpuhandcodedimagenetpythonpytorchtorchtorchvisionvqganvqgan-clip

514 B · 19 lines · Python Raw History
 1import torch
 2import torch.nn as nn
 3
 4
 5class Upsample(nn.Module):
 6    def __init__(self, in_channels, with_conv):
 7        super().__init__()
 8        self.with_conv = with_conv
 9        if self.with_conv:
10            self.conv = torch.nn.Conv2d(
11                in_channels, in_channels, kernel_size=3, stride=1, padding=1
12            )
13
14    def forward(self, x):
15        x = torch.nn.functional.interpolate(x, scale_factor=2.0, mode="nearest")
16        if self.with_conv:
17            x = self.conv(x)
18        return x