File size: 1,077 Bytes
8f708a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import random
import gradio as gr

def fake_gan():
    base_dir = os.getcwd()  # Get the current base directory
    jpg_files = [file for file in os.listdir(base_dir) if file.lower().endswith((".jpg", ".jpeg"))]  # List all files ending with ".jpg" or ".jpeg"
    images = [(random.choice(jpg_files), os.path.splitext(file)[0]) for file in jpg_files]
    return images

with gr.Blocks() as demo:
    with gr.Column(variant="panel"):
        with gr.Row(variant="compact"):
            text = gr.Textbox(
                label="Gallery",
                show_label=False,
                max_lines=1,
                placeholder="Enter prompt to filter or leave blank and click for random order",
            ).style(
                container=False,
            )
            btn = gr.Button("Generate Gallery").style(full_width=False)

        gallery = gr.Gallery(
            label="Generated images", show_label=False, elem_id="gallery"
        ).style(grid=[2], height="auto")

    btn.click(fake_gan, None, gallery)

if __name__ == "__main__":
    demo.launch()