echen01
add app templtae
0513aaf
raw
history blame
807 Bytes
import gradio as gr
import utils
from PIL import Image
import torch
import math
from torchvision import transforms
device = "cpu"
years = [str(y) for y in range(1880, 2020, 10)]
orig_models = {}
for year in years:
G, w_avg = utils.load_stylegan2(f"pretrained_models/{year}.pkl", device)
orig_models[year] = { "G": G.eval()}
transform = transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
# Download human-readable labels for ImageNet.
def predict(inp):
#with torch.no_grad():
return inp
gr.Interface(fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Image(type="pil"),
#examples=["lion.jpg", "cheetah.jpg"]
).launch()