Spaces:
Runtime error
Runtime error
import gradio as gr | |
from huggan.pytorch.pix2pix.modeling_pix2pix import GeneratorUNet | |
from PIL import Image | |
from torchvision.utils import save_image | |
from torchvision.transforms import Compose, Resize, ToTensor, Normalize, ToPILImage | |
from diffusers.utils import load_image, make_image_grid | |
transform = Compose( | |
[ | |
Resize((256, 256), Image.BICUBIC), | |
ToTensor(), | |
Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)), | |
] | |
) | |
transform2 = Compose( | |
[ | |
#Resize((256, 256), Image.BICUBIC), | |
ToPILImage(), | |
#Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)), | |
] | |
) | |
generator = GeneratorUNet.from_pretrained("debisoft/gimp-pred-men-gan-test-a") | |
def greet(input): | |
coord_zxy = input | |
image = load_image("https://c.basemaps.cartocdn.com/rastertiles/voyager_labels_under" + coord_zxy + ".png") | |
pixel_values = transform(image).unsqueeze(0) | |
output = generator(pixel_values) | |
return transform2(output[0]) | |
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="coord_zxy", value="/18/73237/95677")], outputs=[gr.Image(type="pil", width=256, label="Output Image")]) | |
iface.queue(api_open=True); | |
iface.launch() | |