divya55 commited on
Commit
71aa51e
Β·
verified Β·
1 Parent(s): 258d915

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +12 -9
src/streamlit_app.py CHANGED
@@ -1,17 +1,20 @@
1
  import streamlit as st
 
2
  import numpy as np
3
  import cv2
4
 
5
- st.title("πŸ“· Test Image Upload")
6
 
7
- uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
8
 
9
- if uploaded_file is not None:
10
- # Convert uploaded file to OpenCV image directly from memory
11
- file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
12
- img = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
13
 
14
- # Show the image
15
- st.image(img, channels="BGR", caption="Uploaded Image", use_container_width=True)
 
 
16
 
17
- st.success("Upload successful βœ…")
 
 
 
1
  import streamlit as st
2
+ from PIL import Image
3
  import numpy as np
4
  import cv2
5
 
6
+ st.title("Upload & View Image")
7
 
8
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
9
 
10
+ # This prints info to Streamlit console
11
+ st.write("Uploaded file:", uploaded_file)
 
 
12
 
13
+ if uploaded_file is not None:
14
+ # Make sure to open the uploaded file
15
+ image = Image.open(uploaded_file)
16
+ st.image(image, caption="Original Image", use_column_width=True)
17
 
18
+ st.success("Image loaded successfully!")
19
+ else:
20
+ st.info("Please upload an image.")