abidlabs HF Staff commited on
Commit
b18b0ce
·
1 Parent(s): 44ad57a

Create new file

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This demo needs to be run from the repo folder.
2
+ # python demo/fake_gan/run.py
3
+ import os
4
+ import random
5
+ import time
6
+
7
+ import gradio as gr
8
+
9
+
10
+ def fake_gan(count, *args):
11
+ images = [
12
+ (random.choice(
13
+ [
14
+ "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
15
+ "https://images.unsplash.com/photo-1554151228-14d9def656e4?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=386&q=80",
16
+ "https://images.unsplash.com/photo-1542909168-82c3e7fdca5c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8aHVtYW4lMjBmYWNlfGVufDB8fDB8fA%3D%3D&w=1000&q=80",
17
+ "https://images.unsplash.com/photo-1546456073-92b9f0a8d413?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
18
+ "https://images.unsplash.com/photo-1601412436009-d964bd02edbc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=464&q=80",
19
+ ]
20
+ ), f"label {i}")
21
+ for i in range(int(count))
22
+ ]
23
+ return images
24
+
25
+
26
+ cheetah = os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg")
27
+
28
+ demo = gr.Interface(
29
+ fn=fake_gan,
30
+ inputs=[
31
+ gr.Number(label="Generation Count"),
32
+ gr.Image(label="Initial Image (optional)"),
33
+ gr.Slider(0, 50, 25, label="TV_scale (for smoothness)"),
34
+ gr.Slider(0, 50, 25, label="Range_Scale (out of range RBG)"),
35
+ gr.Number(label="Seed"),
36
+ gr.Number(label="Respacing"),
37
+ ],
38
+ outputs=gr.Gallery(label="Generated Images").style(grid=[2]),
39
+ title="FD-GAN",
40
+ description="This is a fake demo of a GAN. In reality, the images are randomly chosen from Unsplash.",
41
+ examples=[
42
+ [2, cheetah, None, 12, None, None],
43
+ [1, cheetah, None, 2, None, None],
44
+ [4, cheetah, None, 42, None, None],
45
+ [5, cheetah, None, 23, None, None],
46
+ [4, cheetah, None, 11, None, None],
47
+ [3, cheetah, None, 1, None, None],
48
+ ],
49
+ )
50
+
51
+ if __name__ == "__main__":
52
+ demo.launch()