AIProctoringSys / app.py
Sazzz02's picture
Update app.py
9226029 verified
import gradio as gr
import cv2
import numpy as np
from detector import detect_cheating
from utils import plot_cheating_graph, update_score
def process_frame(frame):
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
frame, cheating, persons = detect_cheating(frame)
update_score(cheating)
status = "Cheating Detected" if cheating else "Clean"
frame = cv2.putText(frame, f"Status: {status}", (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255) if cheating else (0,255,0), 2)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
graph = plot_cheating_graph()
return frame, graph
# Updated input to use live webcam
webcam = gr.Camera(type="image", label="Live Webcam")
iface = gr.Interface(
fn=process_frame,
inputs=webcam,
outputs=[
gr.Image(label="Processed Frame"),
gr.Image(label="Cheating Score Graph")
],
title="AI Proctoring System",
description="Real-time cheating detection system using webcam input and YOLOv8."
)
iface.launch()