showimg / app.py
ovi054's picture
Update app.py
71da07d verified
import gradio as gr
import os
# Path to the folder containing images
image_folder = "images"
# Get the list of image files from the folder and prepare the image list
# Get the list of image files from the folder and prepare the image list
# image_list = [
# (os.path.join(image_folder, filename), os.path.splitext(filename)[0])
# for filename in sorted(os.listdir(image_folder))
# if filename.endswith(('.png', '.jpg', '.jpeg', 'webp')) and filename.startswith('_Google')
# ]
# # Add other images if needed (not starting with _Google)
# image_list = [
# (os.path.join(image_folder, filename), os.path.splitext(filename)[0])
# for filename in sorted(os.listdir(image_folder))
# if filename.endswith(('.png', '.jpg', '.jpeg', 'webp')) and not filename.startswith('_Google')
# ]
# Add other images if needed (not starting with _Google)
image_list = [
os.path.join(image_folder, filename) # Only include the image path
for filename in sorted(os.listdir(image_folder))
if filename.endswith(('.png', '.jpg', '.jpeg', 'webp')) and not filename.startswith('_Google')
]
with gr.Blocks() as demo:
gr.Gallery(value=image_list, columns=14, show_label=False, height=340) # Show the label as the filename
demo.launch()