Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
-
import io
|
| 4 |
|
| 5 |
# Initialize a session state to keep track of images
|
| 6 |
if 'images' not in st.session_state:
|
|
@@ -15,7 +14,7 @@ def main():
|
|
| 15 |
st.title("Sock Image Uploader")
|
| 16 |
|
| 17 |
# Image uploader
|
| 18 |
-
uploaded_file = st.file_uploader("Take a picture of your sock and upload it here", type=["jpg", "png"])
|
| 19 |
|
| 20 |
# If a file is uploaded, process and display it
|
| 21 |
if uploaded_file is not None:
|
|
@@ -23,9 +22,12 @@ def main():
|
|
| 23 |
image = Image.open(uploaded_file)
|
| 24 |
st.session_state.images.append(image)
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Reset button
|
| 31 |
if st.button('Reset and Start Over'):
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
|
|
|
| 3 |
|
| 4 |
# Initialize a session state to keep track of images
|
| 5 |
if 'images' not in st.session_state:
|
|
|
|
| 14 |
st.title("Sock Image Uploader")
|
| 15 |
|
| 16 |
# Image uploader
|
| 17 |
+
uploaded_file = st.file_uploader("Take a picture of your sock and upload it here", type=["jpg", "png"], key="file_uploader")
|
| 18 |
|
| 19 |
# If a file is uploaded, process and display it
|
| 20 |
if uploaded_file is not None:
|
|
|
|
| 22 |
image = Image.open(uploaded_file)
|
| 23 |
st.session_state.images.append(image)
|
| 24 |
|
| 25 |
+
# Clear the file uploader for the next upload
|
| 26 |
+
st.session_state.file_uploader = None
|
| 27 |
+
|
| 28 |
+
# Display images
|
| 29 |
+
for idx, img in enumerate(st.session_state.images, start=1):
|
| 30 |
+
st.image(img, caption=f"Image {idx}", use_column_width=True)
|
| 31 |
|
| 32 |
# Reset button
|
| 33 |
if st.button('Reset and Start Over'):
|