Spaces:
Runtime error
Runtime error
File size: 956 Bytes
19c0acc 6b4886a 7ee6598 19c0acc 3c7cc02 19c0acc 9f23747 19c0acc 7ee6598 46ae19f | 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 29 30 31 32 33 34 35 36 37 38 | import gradio as gr
import torch
import numpy as np
import os
from model import gen_model
import torchvision.transforms as T
# Model
gen,transform_gen=gen_model()
# print(gen)
to_img=T.ToPILImage()
# examples=["examples/input_0.png","examples/input_9.png"]
example_list = [["examples/" + example] for example in os.listdir("examples")]
# Predict Function
def predict(img):
# Apply Transformations
# img=np.array(img)
img=transform_gen(img).unsqueeze(0)
# Predict
gen.eval()
with torch.inference_mode():
y_gen=gen(img)
y_gen=y_gen[0]
y_gen=to_img(y_gen)
return y_gen
# Gradio App
title="Satellite-to-Map GAN"
description="This is a Sattelite Image to Map converter"
demo=gr.Interface(fn=predict,
inputs=gr.Image(type='pil'),
outputs=gr.Image(type='pil'),
title=title ,
examples=example_list,
description=description)
demo.launch(debug=False) |