Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import random
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def fake_gan():
|
6 |
+
base_dir = os.getcwd() # Get the current base directory
|
7 |
+
jpg_files = [file for file in os.listdir(base_dir) if file.lower().endswith((".jpg", ".jpeg"))] # List all files ending with ".jpg" or ".jpeg"
|
8 |
+
images = [(random.choice(jpg_files), os.path.splitext(file)[0]) for file in jpg_files]
|
9 |
+
return images
|
10 |
+
|
11 |
+
with gr.Blocks() as demo:
|
12 |
+
with gr.Column(variant="panel"):
|
13 |
+
with gr.Row(variant="compact"):
|
14 |
+
text = gr.Textbox(
|
15 |
+
label="Gallery",
|
16 |
+
show_label=False,
|
17 |
+
max_lines=1,
|
18 |
+
placeholder="Enter prompt to filter or leave blank and click for random order",
|
19 |
+
).style(
|
20 |
+
container=False,
|
21 |
+
)
|
22 |
+
btn = gr.Button("Generate Gallery").style(full_width=False)
|
23 |
+
|
24 |
+
gallery = gr.Gallery(
|
25 |
+
label="Generated images", show_label=False, elem_id="gallery"
|
26 |
+
).style(grid=[2], height="auto")
|
27 |
+
|
28 |
+
btn.click(fake_gan, None, gallery)
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
demo.launch()
|