Spaces:
Build error
Build error
| # interview_demo.py - Streamlit app for interviews | |
| import streamlit as st | |
| import cv2 | |
| import tempfile | |
| import numpy as np | |
| from PIL import Image | |
| def interview_demo_app(): | |
| st.set_page_config(page_title="Live Demo", layout="wide") | |
| st.title("π― Live Demo - AI Attendance System") | |
| st.info(""" | |
| **How to demonstrate:** | |
| 1. Click 'Start Camera' below | |
| 2. Show your face to the camera | |
| 3. See real-time detection and recognition | |
| 4. Watch attendance log update automatically | |
| """) | |
| # Sidebar with status | |
| with st.sidebar: | |
| st.header("π΄ System Status") | |
| st.success("β Camera Ready") | |
| st.success("β Model Loaded") | |
| st.success("β Database Connected") | |
| st.header("π Session Stats") | |
| if 'detections' not in st.session_state: | |
| st.session_state.detections = [] | |
| st.metric("Faces Detected", len(st.session_state.detections)) | |
| # Camera feed | |
| col1, col2 = st.columns([2, 1]) | |
| with col1: | |
| st.subheader("πΉ Live Feed") | |
| camera_placeholder = st.empty() | |
| # Start camera button | |
| if st.button("π Start Camera", use_container_width=True): | |
| cap = cv2.VideoCapture(0) | |
| if not cap.isOpened(): | |
| st.error("β οΈ Could not access camera") | |
| else: | |
| # Process frames | |
| frame_count = 0 | |
| while True: | |
| ret, frame = cap.read() | |
| if not ret: | |
| break | |
| # Your detection code here | |
| # For demo, just show frame with overlay | |
| frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | |
| frame = cv2.putText(frame, "π’ Live Demo", (10, 30), | |
| cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2) | |
| camera_placeholder.image(frame, use_container_width=True) | |
| # Simulate detections | |
| if frame_count % 30 == 0: | |
| st.session_state.detections.append({ | |
| 'time': datetime.now(), | |
| 'name': 'Demo User' | |
| }) | |
| frame_count += 1 | |
| with col2: | |
| st.subheader("π Live Attendance") | |
| attendance_table = st.empty() | |
| # Show attendance log | |
| if st.session_state.detections: | |
| df = pd.DataFrame(st.session_state.detections) | |
| attendance_table.dataframe(df.tail(10)) | |
| else: | |
| st.info("Waiting for detections...") | |
| # Demo controls | |
| col3, col4 = st.columns(2) | |
| with col3: | |
| if st.button("π§Ή Clear Log", use_container_width=True): | |
| st.session_state.detections = [] | |
| st.rerun() | |
| with col4: | |
| if st.button("π₯ Export Demo Data", use_container_width=True): | |
| # Export functionality | |
| st.success("β Demo data exported!") | |
| if __name__ == "__main__": | |
| interview_demo_app() |