File size: 1,024 Bytes
bfd7290
 
79772b4
bfd7290
 
 
 
 
 
 
 
 
 
 
 
 
 
79772b4
 
 
bfd7290
 
79772b4
 
 
 
 
bfd7290
79772b4
bfd7290
 
 
9226029
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()