Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,38 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from PIL import Image
|
3 |
-
import numpy as np
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
10 |
if uploaded_file is not None:
|
11 |
-
# Open the image
|
12 |
img = Image.open(uploaded_file)
|
13 |
-
st.image(img, caption="Uploaded Image
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
else:
|
20 |
-
# Simulate tree detection using random number
|
21 |
-
trees = np.random.randint(0, 100)
|
22 |
-
st.success(f"Number of Trees: {trees}")
|
23 |
|
24 |
-
#
|
25 |
-
if
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
1 |
import streamlit as st
|
2 |
+
import os
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
+
# Define the path to the folder
|
6 |
+
FIRE_SHOT_FOLDER = os.path.join(os.getcwd(), 'FireShot')
|
7 |
|
8 |
+
# Ensure the folder exists
|
9 |
+
if not os.path.exists(FIRE_SHOT_FOLDER):
|
10 |
+
st.error("FireShot folder does not exist!")
|
11 |
+
else:
|
12 |
+
st.success(f"FireShot folder found at {FIRE_SHOT_FOLDER}")
|
13 |
|
14 |
+
# Display a file uploader
|
15 |
+
uploaded_file = st.file_uploader("Browse images from FireShot", type=["jpg", "png", "jpeg"])
|
16 |
+
|
17 |
+
# If the user uploads a file, save it in the FireShot folder
|
18 |
if uploaded_file is not None:
|
|
|
19 |
img = Image.open(uploaded_file)
|
20 |
+
st.image(img, caption="Uploaded Image", use_column_width=True)
|
21 |
|
22 |
+
# Save the image to FireShot folder
|
23 |
+
file_path = os.path.join(FIRE_SHOT_FOLDER, uploaded_file.name)
|
24 |
+
img.save(file_path)
|
25 |
+
st.success(f"Image saved to {file_path}")
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
# Optionally, display all images from the FireShot folder
|
28 |
+
if st.button("Show all images in FireShot folder"):
|
29 |
+
image_files = [f for f in os.listdir(FIRE_SHOT_FOLDER) if f.endswith(('jpg', 'jpeg', 'png'))]
|
30 |
+
|
31 |
+
if image_files:
|
32 |
+
for image_file in image_files:
|
33 |
+
img_path = os.path.join(FIRE_SHOT_FOLDER, image_file)
|
34 |
+
img = Image.open(img_path)
|
35 |
+
st.image(img, caption=image_file, use_column_width=True)
|
36 |
+
else:
|
37 |
+
st.info("No images found in FireShot folder.")
|
38 |
|