Amram commited on
Commit
289a719
·
1 Parent(s): 6a31e38

Create fake_gun.py

Browse files
Files changed (1) hide show
  1. fake_gun.py +44 -0
fake_gun.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This demo needs to be run from the repo folder.
2
+ # python demo/fake_gan/run.py
3
+ import random
4
+
5
+ import gradio as gr
6
+
7
+
8
+ def fake_gan():
9
+ images = [
10
+ (random.choice(
11
+ [
12
+ "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
13
+ "https://images.unsplash.com/photo-1554151228-14d9def656e4?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=386&q=80",
14
+ "https://images.unsplash.com/photo-1542909168-82c3e7fdca5c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8aHVtYW4lMjBmYWNlfGVufDB8fDB8fA%3D%3D&w=1000&q=80",
15
+ "https://images.unsplash.com/photo-1546456073-92b9f0a8d413?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
16
+ "https://images.unsplash.com/photo-1601412436009-d964bd02edbc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=464&q=80",
17
+ ]
18
+ ), f"label {i}" if i != 0 else "label" * 50)
19
+ for i in range(3)
20
+ ]
21
+ return images
22
+
23
+
24
+ with gr.Blocks() as demo:
25
+ with gr.Column(variant="panel"):
26
+ with gr.Row(variant="compact"):
27
+ text = gr.Textbox(
28
+ label="Enter your prompt",
29
+ show_label=False,
30
+ max_lines=1,
31
+ placeholder="Enter your prompt",
32
+ ).style(
33
+ container=False,
34
+ )
35
+ btn = gr.Button("Generate image").style(full_width=False)
36
+
37
+ gallery = gr.Gallery(
38
+ label="Generated images", show_label=False, elem_id="gallery"
39
+ ).style(columns=[2], rows=[2], object_fit="contain", height="auto")
40
+
41
+ btn.click(fake_gan, None, gallery)
42
+
43
+ if __name__ == "__main__":
44
+ demo.launch()