| import streamlit as st | |
| import numpy as np | |
| from PIL import Image | |
| # Dummy model function (replace this with your own) | |
| def model(input_image): | |
| # Example: convert to grayscale and return message | |
| return input_image, 'you are sleepy' | |
| st.title("π· Webcam Image Processor") | |
| # Webcam input using Streamlit's native method | |
| img_file_buffer = st.camera_input("Take a picture") | |
| if img_file_buffer is not None: | |
| # Convert captured image to PIL Image | |
| input_image = Image.open(img_file_buffer) | |
| st.subheader("π Input Image") | |
| st.image(input_image, caption="Captured Image", use_column_width=True) | |
| # Run through model | |
| output_image, result_text = model(input_image) | |
| print('processed') | |
| st.subheader("π§ Model Output") | |
| st.image(output_image, caption="Processed Output", use_column_width=True) | |
| st.success(result_text) |