Spaces:
Runtime error
Runtime error
import streamlit as st | |
import os | |
from PIL import Image | |
# Define the path to the folder where images are stored | |
FIRE_SHOT_FOLDER = os.path.join(os.getcwd(), 'FireShot') | |
# Ensure the folder exists | |
if not os.path.exists(FIRE_SHOT_FOLDER): | |
st.error("FireShot folder does not exist!") | |
else: | |
st.success(f"FireShot folder found at {FIRE_SHOT_FOLDER}") | |
# Get list of images from the FireShot folder | |
image_files = [f for f in os.listdir(FIRE_SHOT_FOLDER) if f.endswith(('jpg', 'jpeg', 'png'))] | |
if image_files: | |
# Create a selectbox for the user to select an image | |
selected_image = st.selectbox("Select an image from the FireShot folder", image_files) | |
# Load and display the selected image | |
if selected_image: | |
img_path = os.path.join(FIRE_SHOT_FOLDER, selected_image) | |
img = Image.open(img_path) | |
st.image(img, caption=f"Selected Image: {selected_image}", use_column_width=True) | |
else: | |
st.info("No images found in FireShot folder.") | |