# 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()