Sazzz02 commited on
Commit
bfd7290
·
verified ·
1 Parent(s): b0091f4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ from detector import detect_cheating
4
+ from utils import plot_cheating_graph, update_score
5
+
6
+ def process_frame(frame):
7
+ frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
8
+ frame, cheating, persons = detect_cheating(frame)
9
+ update_score(cheating)
10
+ status = "Cheating Detected" if cheating else "Clean"
11
+ frame = cv2.putText(frame, f"Status: {status}", (10, 30),
12
+ cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255) if cheating else (0,255,0), 2)
13
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
14
+ graph = plot_cheating_graph()
15
+ return frame, graph
16
+
17
+ iface = gr.Interface(
18
+ fn=process_frame,
19
+ inputs=gr.Image(source="webcam", streaming=True),
20
+ outputs=[gr.Image(label="Live Feed"), gr.Image(label="Cheating Score Graph")],
21
+ live=True,
22
+ title="AI Proctoring System",
23
+ description="Detects cheating based on number of persons and head orientation using YOLOv8."
24
+ )
25
+
26
+ iface.launch()