Spaces:
Runtime error
Runtime error
File size: 1,074 Bytes
ed25af4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from PIL import Image
import torch
# Load models
model_celeba = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="celeba_distill")
model_facev1 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1")
model_facev2 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v2")
model_paprika = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="paprika")
face2paint = torch.hub.load("bryandlee/animegan2-pytorch:main", "face2paint", size=512)
def generate_cartoon(input_img):
img = Image.open(input_img.name).convert("RGB")
out_celeba = face2paint(model_celeba, img)
out_facev1 = face2paint(model_facev1, img)
out_facev2 = face2paint(model_facev2, img)
out_paprika = face2paint(model_paprika, img)
return out_celeba, out_facev1, out_facev2, out_paprika
iface = gr.Interface(
fn=generate_cartoon,
inputs="file",
outputs=["image", "image", "image", "image"],
live=True
)
iface.launch()
|