akhaliq HF staff commited on
Commit
8bc6b47
1 Parent(s): 1b39940

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from PIL import Image
4
+
5
+ os.system("git clone https://github.com/autonomousvision/projected_gan")
6
+
7
+
8
+ os.chdir("projected_gan")
9
+
10
+ os.mkdir("outputs")
11
+
12
+ os.system("gdown --id '1H-MYFZqngF1R0whm4bc3fEoX7VvOWaDl'")
13
+
14
+ def inference(truncation,seeds):
15
+ os.system("python gen_images.py --outdir=./outputs/ --trunc="+str(truncation)+" --seeds="+str(int(seeds))+" --network=network-snapshot-metfaces2.pkl")
16
+ seeds = int(seeds)
17
+ image = Image.open(f"./outputs/seed{seeds:04d}.png")
18
+ return image
19
+
20
+ title = "Projected GAN"
21
+ description = "Gradio demo for Projected GAN. To use it, add seed and truncation, or click one of the examples to load them. Read more at the links below."
22
+
23
+ article = "<p style='text-align: center'><a href='http://www.cvlibs.net/publications/Sauer2021NEURIPS.pdf' target='_blank'>Projected GANs Converge Faster</a> | <a href='https://github.com/autonomousvision/projected_gan'>Github Repo</p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_projected_gan' alt='visitor badge'></center>"
24
+
25
+ gr.Interface(inference,[gr.inputs.Slider(label="truncation",minimum=0, maximum=5, step=0.1, default=0.8),gr.inputs.Slider(label="Seed",minimum=0, maximum=1000, step=1, default=0)],"pil",title=title,description=description,article=article, examples=[
26
+ [0.8,0]
27
+ ]).launch(enable_queue=True,cache_examples=True)