debisoft commited on
Commit
bcaa8e5
1 Parent(s): 6588d8d

1st upload

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, ToPILImage
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
+ transform2 = Compose(
18
+ [
19
+ #Resize((256, 256), Image.BICUBIC),
20
+ ToPILImage(),
21
+ #Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
22
+ ]
23
+ )
24
+
25
+ generator = GeneratorUNet.from_pretrained("debisoft/gimp-pred-men-gan-test-b")
26
+
27
+ def greet(input):
28
+ coord_zxy = input
29
+ image = load_image("https://c.basemaps.cartocdn.com/rastertiles/voyager_labels_under" + coord_zxy + ".png")
30
+ pixel_values = transform(image).unsqueeze(0)
31
+ output = generator(pixel_values)
32
+
33
+ return transform2(output[0])
34
+
35
+ 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")])
36
+ iface.queue(api_open=True);
37
+ 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