Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
#
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import glob
|
@@ -109,15 +108,15 @@ upload_option = st.radio("Select Upload Type", ["Single Image Upload", "Batch Im
|
|
109 |
# Single Image Upload
|
110 |
if upload_option == "Single Image Upload":
|
111 |
st.subheader("Upload a Single Vehicle Image")
|
112 |
-
uploaded_image = st.file_uploader("Choose
|
113 |
|
114 |
if uploaded_image is not None:
|
115 |
# Display the uploaded image
|
116 |
image = PILImage.open(uploaded_image)
|
117 |
-
st.image(image, caption="Uploaded Image",
|
118 |
|
119 |
# Convert the uploaded image to base64
|
120 |
-
image_path = "/tmp/uploaded_image.
|
121 |
with open(image_path, "wb") as f:
|
122 |
f.write(uploaded_image.getbuffer())
|
123 |
|
@@ -130,13 +129,13 @@ if upload_option == "Single Image Upload":
|
|
130 |
|
131 |
# Optionally, display more vehicle images from the folder
|
132 |
img_dir = "/content/images"
|
133 |
-
image_paths = glob.glob(os.path.join(img_dir, "
|
134 |
display_image_grid(image_paths)
|
135 |
|
136 |
# Batch Images Upload
|
137 |
elif upload_option == "Batch Images Upload":
|
138 |
st.sidebar.header("Batch Image Upload")
|
139 |
-
batch_images = st.sidebar.file_uploader("Upload Images", type="jpeg", accept_multiple_files=True)
|
140 |
|
141 |
if batch_images:
|
142 |
batch_input = [{"image_path": f"/tmp/{file.name}"} for file in batch_images]
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import glob
|
|
|
108 |
# Single Image Upload
|
109 |
if upload_option == "Single Image Upload":
|
110 |
st.subheader("Upload a Single Vehicle Image")
|
111 |
+
uploaded_image = st.file_uploader("Choose an Image (JPEG, PNG, GIF, BMP, etc.)", type=["jpeg", "png", "gif", "bmp", "jpg"])
|
112 |
|
113 |
if uploaded_image is not None:
|
114 |
# Display the uploaded image
|
115 |
image = PILImage.open(uploaded_image)
|
116 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
117 |
|
118 |
# Convert the uploaded image to base64
|
119 |
+
image_path = "/tmp/uploaded_image" + os.path.splitext(uploaded_image.name)[1]
|
120 |
with open(image_path, "wb") as f:
|
121 |
f.write(uploaded_image.getbuffer())
|
122 |
|
|
|
129 |
|
130 |
# Optionally, display more vehicle images from the folder
|
131 |
img_dir = "/content/images"
|
132 |
+
image_paths = glob.glob(os.path.join(img_dir, "*.*"))
|
133 |
display_image_grid(image_paths)
|
134 |
|
135 |
# Batch Images Upload
|
136 |
elif upload_option == "Batch Images Upload":
|
137 |
st.sidebar.header("Batch Image Upload")
|
138 |
+
batch_images = st.sidebar.file_uploader("Upload Images (JPEG, PNG, GIF, BMP, etc.)", type=["jpeg", "png", "gif", "bmp", "jpg"], accept_multiple_files=True)
|
139 |
|
140 |
if batch_images:
|
141 |
batch_input = [{"image_path": f"/tmp/{file.name}"} for file in batch_images]
|