Spaces:
Runtime error
Runtime error
Update dashboard.py
Browse files- dashboard.py +31 -0
dashboard.py
CHANGED
@@ -4,6 +4,8 @@ from firebase_admin import credentials, firestore
|
|
4 |
import gradio as gr
|
5 |
import io
|
6 |
from PIL import Image
|
|
|
|
|
7 |
|
8 |
# Initialize Firebase if not already initialized
|
9 |
if not firebase_admin._apps:
|
@@ -12,6 +14,7 @@ if not firebase_admin._apps:
|
|
12 |
|
13 |
db = firestore.client()
|
14 |
|
|
|
15 |
def update_dashboard_plot():
|
16 |
logs_ref = db.collection("evo_feedback")
|
17 |
docs = logs_ref.stream()
|
@@ -38,3 +41,31 @@ def update_dashboard_plot():
|
|
38 |
buf.seek(0)
|
39 |
img = Image.open(buf)
|
40 |
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import gradio as gr
|
5 |
import io
|
6 |
from PIL import Image
|
7 |
+
import os
|
8 |
+
import json
|
9 |
|
10 |
# Initialize Firebase if not already initialized
|
11 |
if not firebase_admin._apps:
|
|
|
14 |
|
15 |
db = firestore.client()
|
16 |
|
17 |
+
# β
This stays as-is: Firebase Feedback Summary
|
18 |
def update_dashboard_plot():
|
19 |
logs_ref = db.collection("evo_feedback")
|
20 |
docs = logs_ref.stream()
|
|
|
41 |
buf.seek(0)
|
42 |
img = Image.open(buf)
|
43 |
return img
|
44 |
+
|
45 |
+
# β
NEW: Accuracy Plot from Local Log
|
46 |
+
def evolution_accuracy_plot():
|
47 |
+
try:
|
48 |
+
log_path = "trained_model/evolution_log.json"
|
49 |
+
if not os.path.exists(log_path):
|
50 |
+
fig, ax = plt.subplots()
|
51 |
+
ax.text(0.5, 0.5, "No evolution log found", ha="center", va="center")
|
52 |
+
return fig
|
53 |
+
|
54 |
+
with open(log_path, "r") as f:
|
55 |
+
log_data = json.load(f)
|
56 |
+
|
57 |
+
generations = list(range(1, len(log_data) + 1))
|
58 |
+
accuracies = [entry.get("accuracy", 0) for entry in log_data]
|
59 |
+
|
60 |
+
fig, ax = plt.subplots()
|
61 |
+
ax.plot(generations, accuracies, marker="o", linestyle="-")
|
62 |
+
ax.set_xlabel("Generation")
|
63 |
+
ax.set_ylabel("Accuracy")
|
64 |
+
ax.set_title("EvoTransformer Evolution Accuracy")
|
65 |
+
ax.grid(True)
|
66 |
+
|
67 |
+
return fig
|
68 |
+
except Exception as e:
|
69 |
+
fig, ax = plt.subplots()
|
70 |
+
ax.text(0.5, 0.5, f"Error loading plot: {e}", ha="center")
|
71 |
+
return fig
|