awacke1 commited on
Commit
8d8c934
β€’
1 Parent(s): 469c939

Create app.py

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