File size: 691 Bytes
bfa41fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b18fcdc
bfa41fe
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import os
import gradio as gr
from PIL import Image

def load_images(source_file):
    images = []
    for file in os.listdir(source_file):
        if file.endswith(".jpg"):
            image_path = os.path.join(source_file, file)
            image = Image.open(image_path)
            thumbnail = image.thumbnail((100, 100))
            images.append(thumbnail)
    return images

def show_thumbnails(source_file):
    images = load_images(source_file)
    return gr.outputs.ImageGroup(images)

iface = gr.Interface(fn=show_thumbnails, inputs="text", outputs="image", title="Image Thumbnails", description="Load all .jpg images in a folder and display their thumbnails.")
iface.launch()