DeepActionPotential/DrowSeeAi
0
1import streamlit as st
2from PIL import Image
3
4def upload_image():
5 """
6 Display a Streamlit file uploader. If an image is uploaded, show a preview and return it.
7
8 Returns:
9 PIL.Image.Image or None: The uploaded image as a PIL Image (RGB), or None if nothing uploaded.
10 """
11 st.title("๐๏ธ Drowsiness Detection App")
12 st.write("Upload a face image and the model will predict whether the person is drowsy (1) or not (0).")
13
14 uploaded_file = st.file_uploader(
15 label="Choose an image file (JPG/PNG)",
16 type=["jpg", "jpeg", "png"]
17 )
18
19 if uploaded_file is not None:
20 # Convert the uploaded file to a PIL image
21 image = Image.open(uploaded_file).convert("RGB")
22 st.image(image, caption="Uploaded Image", use_column_width=True)
23 return image
24
25 return None
26 