Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,17 @@ import os
|
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
|
5 |
-
def
|
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"):
|
@@ -25,7 +31,7 @@ with gr.Blocks() as demo:
|
|
25 |
label="Generated images", show_label=False, elem_id="gallery"
|
26 |
).style(grid=[2], height="auto")
|
27 |
|
28 |
-
btn.click(
|
29 |
|
30 |
if __name__ == "__main__":
|
31 |
demo.launch()
|
|
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
|
5 |
+
def fake_gan_jpg():
|
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 |
+
def fake_gan_png():
|
12 |
+
base_dir = os.getcwd() # Get the current base directory
|
13 |
+
files = [file for file in os.listdir(base_dir) if file.lower().endswith((".png"))] # List all files ending with
|
14 |
+
images = [(random.choice(files), os.path.splitext(file)[0]) for file in files]
|
15 |
+
return images
|
16 |
|
17 |
with gr.Blocks() as demo:
|
18 |
with gr.Column(variant="panel"):
|
|
|
31 |
label="Generated images", show_label=False, elem_id="gallery"
|
32 |
).style(grid=[2], height="auto")
|
33 |
|
34 |
+
btn.click(fake_gan_png, None, gallery)
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
demo.launch()
|