Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,7 @@ import streamlit as st
|
|
2 |
import os
|
3 |
from PIL import Image
|
4 |
|
5 |
-
|
6 |
-
# Define the path to the folder
|
7 |
FIRE_SHOT_FOLDER = os.path.join(os.getcwd(), 'FireShot')
|
8 |
|
9 |
# Ensure the folder exists
|
@@ -12,32 +11,18 @@ if not os.path.exists(FIRE_SHOT_FOLDER):
|
|
12 |
else:
|
13 |
st.success(f"FireShot folder found at {FIRE_SHOT_FOLDER}")
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
# If the user uploads a file, save it in the FireShot folder
|
19 |
-
if uploaded_file is not None:
|
20 |
-
|
21 |
-
img = Image.open(uploaded_file)
|
22 |
-
st.image(img, caption="Uploaded Image", use_column_width=True)
|
23 |
-
|
24 |
-
# Save the image to FireShot folder
|
25 |
-
file_path = os.path.join(FIRE_SHOT_FOLDER, uploaded_file.name)
|
26 |
-
img.save(file_path)
|
27 |
-
st.success(f"Image saved to {file_path}")
|
28 |
|
|
|
|
|
|
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
# Optionally, display all images from the FireShot folder
|
34 |
-
if st.button("Show all images in FireShot folder"):
|
35 |
-
image_files = [f for f in os.listdir(FIRE_SHOT_FOLDER) if f.endswith(('jpg', 'jpeg', 'png'))]
|
36 |
-
|
37 |
-
if image_files:
|
38 |
-
for image_file in image_files:
|
39 |
-
img_path = os.path.join(FIRE_SHOT_FOLDER, image_file)
|
40 |
-
img = Image.open(img_path)
|
41 |
-
st.image(img, caption=image_file, use_column_width=True)
|
42 |
-
else:
|
43 |
-
st.info("No images found in FireShot folder.")
|
|
|
2 |
import os
|
3 |
from PIL import Image
|
4 |
|
5 |
+
# Define the path to the folder where images are stored
|
|
|
6 |
FIRE_SHOT_FOLDER = os.path.join(os.getcwd(), 'FireShot')
|
7 |
|
8 |
# Ensure the folder exists
|
|
|
11 |
else:
|
12 |
st.success(f"FireShot folder found at {FIRE_SHOT_FOLDER}")
|
13 |
|
14 |
+
# Get list of images from the FireShot folder
|
15 |
+
image_files = [f for f in os.listdir(FIRE_SHOT_FOLDER) if f.endswith(('jpg', 'jpeg', 'png'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
if image_files:
|
18 |
+
# Create a selectbox for the user to select an image
|
19 |
+
selected_image = st.selectbox("Select an image from the FireShot folder", image_files)
|
20 |
|
21 |
+
# Load and display the selected image
|
22 |
+
if selected_image:
|
23 |
+
img_path = os.path.join(FIRE_SHOT_FOLDER, selected_image)
|
24 |
+
img = Image.open(img_path)
|
25 |
+
st.image(img, caption=f"Selected Image: {selected_image}", use_column_width=True)
|
26 |
|
27 |
+
else:
|
28 |
+
st.info("No images found in FireShot folder.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|