debisoft commited on
Commit
cef4ba9
·
1 Parent(s): 1a9ca46

1st commit!

Browse files
Files changed (2) hide show
  1. app.py +27 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from huggan.pytorch.pix2pix.modeling_pix2pix import GeneratorUNet
4
+ from PIL import Image
5
+ from torchvision.utils import save_image
6
+ from torchvision.transforms import Compose, Resize, ToTensor, Normalize
7
+ from diffusers.utils import load_image, make_image_grid
8
+
9
+ transform = Compose(
10
+ [
11
+ Resize((256, 256), Image.BICUBIC),
12
+ ToTensor(),
13
+ Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
14
+ ]
15
+ )
16
+
17
+ def greet(input):
18
+ coord_zxy = int(input)
19
+ image = load_image("https://c.basemaps.cartocdn.com/rastertiles/voyager_labels_under" + coord_zxy)
20
+ pixel_values = transform(image).unsqueeze(0)
21
+ output = generator(pixel_values)
22
+
23
+ return output
24
+
25
+ iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="coord_", value="/18/73237/95677")], outputs=[gr.Image(type="pil", width=256, label="Output Image")])
26
+
27
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ipython
2
+ torch
3
+ torchvision
4
+ diffusers
5
+ git+https://github.com/huggingface/community-events.git