Spaces:
Runtime error
Runtime error
File size: 723 Bytes
14f2897 |
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 |
import matplotlib.pyplot as plt
import numpy as np
from io import BytesIO
import base64
cheating_scores = []
def plot_cheating_graph():
fig, ax = plt.subplots()
ax.plot(cheating_scores, color='red', label='Cheating Score')
ax.set_xlabel("Time")
ax.set_ylabel("Cheating Probability")
ax.set_title("Live Cheating Detection Graph")
ax.legend()
buf = BytesIO()
plt.savefig(buf, format='png')
buf.seek(0)
encoded = base64.b64encode(buf.read()).decode('utf-8')
plt.close(fig)
return f"data:image/png;base64,{encoded}"
def update_score(cheating):
score = 1 if cheating else 0
cheating_scores.append(score)
if len(cheating_scores) > 50:
cheating_scores.pop(0)
|