|
import torch |
|
from torch import nn |
|
import gradio as gr |
|
|
|
|
|
class Generator(nn.Module): |
|
|
|
|
|
def __init__(self, nc=4, nz=100, ngf=64): |
|
super(Generator, self).__init__() |
|
self.network = nn.Sequential( |
|
nn.ConvTranspose2d(nz, ngf * 4, 3, 1, 0, bias=False), |
|
nn.BatchNorm2d(ngf * 4), |
|
nn.ReLU(True), |
|
nn.ConvTranspose2d(ngf * 4, ngf * 2, 3, 2, 1, bias=False), |
|
nn.BatchNorm2d(ngf * 2), |
|
nn.ReLU(True), |
|
nn.ConvTranspose2d(ngf * 2, ngf, 4, 2, 0, bias=False), |
|
nn.BatchNorm2d(ngf), |
|
nn.ReLU(True), |
|
nn.ConvTranspose2d(ngf, nc, 4, 2, 1, bias=False), |
|
nn.Tanh(), |
|
) |
|
|
|
def forward(self, input): |
|
output = self.network(input) |
|
return output |
|
|
|
|
|
def path(action, body, hair, top, bottom): |
|
|
|
|
|
if body == "human": body = '0' |
|
elif body == "alien": body = '1' |
|
|
|
|
|
|
|
name = action + str(body) + str(hair) + str(top) + str(bottom) |
|
return name |
|
|
|
|
|
gr.Interface( |
|
path, |
|
inputs=[ |
|
gr.Radio(choices=["shoot", "slash", "spellcard", "thrust", "walk"], value="shoot"), |
|
gr.Radio(choices=["human", "alien"], value="human"), |
|
gr.Radio(choices=["green", "yellow", "rose", "red", "wine"], value="green"), |
|
gr.Radio(choices=["brown", "blue", "white"], value="brown"), |
|
gr.Radio(choices=["while", "golden", "red", "silver"], value="white"), |
|
], |
|
outputs="image", |
|
live=False, |
|
).launch() |
|
|