CoolFace
Apppublic

asengupta07/EngagementTracker

sourceHugging Faceupdated 3y agoView on Hugging Face
2likes
app.py46 linesDownload Raw Back to root
1import streamlit as st2import numpy as np3from PIL import Image4import io5from helper import predict6 7st.title('Student Engagement Detector')8st.write('Detecting student engagement in an online classroom setting using a deep learning CNN model.')9img = st.file_uploader('Upload an Image:', type=['jpg', 'png', 'jpeg'])10st.write('Here are some sample images to try out the model:')11col1, col2, col3 = st.columns(3)12with col1:13    eg1 = st.image('images/example1.jpg', caption='Example 1', use_column_width=True)14    if st.button('Try Example 1'):15        img = open('images/example1.jpg', 'rb')16    eg4 = st.image('images/example4thumb.jpg', caption='Example 4', use_column_width=True)17    if st.button('Try Example 4'):18        img = open('images/example4.jpg', 'rb')19with col2:20    eg2 = st.image('images/example2thumb.jpg', caption='Example 2', use_column_width=True)21    if st.button('Try Example 2'):22        img = open('images/example2.jpg', 'rb')23    eg5 = st.image('images/example5thumb.jpg', caption='Example 5', use_column_width=True)24    if st.button('Try Example 5'):25        img = open('images/example5.jpg', 'rb')26with col3:27    eg3 = st.image('images/example3.jpg', caption='Example 3', use_column_width=True)28    if st.button('Try Example 3'):29        img = open('images/example3.jpg', 'rb')30    eg6 = st.image('images/example6thumb.jpg', caption='Example 6', use_column_width=True)31    if st.button('Try Example 6'):32        img = open('images/example6.jpg', 'rb')33 34if img is not None:35        st.write('')36        image_np = np.frombuffer(img.read(), np.uint8)37        image_bytes = image_np.tobytes()38        image_file = io.BytesIO(image_bytes)39        img = Image.open(image_file)40        img = np.array(img)41        st.subheader('Result:')42        st.image(img, caption='Uploaded Image', use_column_width=True)43        eng, conf = predict(img)44        st.subheader('Classification Report')45        st.write(f'Prediction: {eng}')46        st.write(f'Confidence: {conf*100:.2f}%')