Update app.py
Browse files
app.py
CHANGED
|
@@ -10,21 +10,23 @@ if 'images' not in st.session_state:
|
|
| 10 |
|
| 11 |
# Function to reset images
|
| 12 |
def reset_images():
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Main app function
|
| 16 |
def main():
|
| 17 |
st.title("Sock Image Uploader")
|
| 18 |
|
| 19 |
# Image uploader
|
| 20 |
-
uploaded_file = st.file_uploader("Take a picture of your sock and upload it here", type=["jpg", "png"])
|
| 21 |
|
| 22 |
# If a file is uploaded, process and display it immediately
|
| 23 |
if uploaded_file is not None:
|
| 24 |
# Convert the file to an image
|
| 25 |
image = Image.open(uploaded_file)
|
| 26 |
st.session_state.images.append(image)
|
| 27 |
-
uploaded_file = None # Reset the uploader for the next file
|
| 28 |
|
| 29 |
# Display images in a grid
|
| 30 |
cols_per_row = 4
|
|
|
|
| 10 |
|
| 11 |
# Function to reset images
|
| 12 |
def reset_images():
|
| 13 |
+
# Clear the images list
|
| 14 |
+
st.session_state.images.clear()
|
| 15 |
+
# Reset the file uploader widget
|
| 16 |
+
st.session_state.file_uploader = None
|
| 17 |
|
| 18 |
# Main app function
|
| 19 |
def main():
|
| 20 |
st.title("Sock Image Uploader")
|
| 21 |
|
| 22 |
# Image uploader
|
| 23 |
+
uploaded_file = st.file_uploader("Take a picture of your sock and upload it here", type=["jpg", "png"], key="file_uploader")
|
| 24 |
|
| 25 |
# If a file is uploaded, process and display it immediately
|
| 26 |
if uploaded_file is not None:
|
| 27 |
# Convert the file to an image
|
| 28 |
image = Image.open(uploaded_file)
|
| 29 |
st.session_state.images.append(image)
|
|
|
|
| 30 |
|
| 31 |
# Display images in a grid
|
| 32 |
cols_per_row = 4
|