kivilaid commited on
Commit
30782d4
·
1 Parent(s): 70ba7a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,6 +1,9 @@
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:
6
  st.session_state.images = []
@@ -16,12 +19,12 @@ def main():
16
  # Image uploader
17
  uploaded_file = st.file_uploader("Take a picture of your sock and upload it here", type=["jpg", "png"])
18
 
19
- # Button to confirm the upload and process the image
20
- if st.button("Upload Next Image"):
21
- if uploaded_file is not None:
22
- # Convert the file to an image
23
- image = Image.open(uploaded_file)
24
- st.session_state.images.append(image)
25
 
26
  # Display images in a grid
27
  cols_per_row = 4
 
1
  import streamlit as st
2
  from PIL import Image
3
 
4
+ # Set the page config to make the app use the full width of the browser
5
+ st.set_page_config(layout="wide")
6
+
7
  # Initialize a session state to keep track of images
8
  if 'images' not in st.session_state:
9
  st.session_state.images = []
 
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