Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
import pandas as pd
|
5 |
+
from glob import glob
|
6 |
+
|
7 |
+
eval_results_dir = "eval_results/" # Directory containing evaluation results
|
8 |
+
|
9 |
+
def load_results():
|
10 |
+
records = []
|
11 |
+
|
12 |
+
# Recursively find all JSON files in the eval_results directory
|
13 |
+
json_files = glob(os.path.join(eval_results_dir, "**", "*.json"), recursive=True)
|
14 |
+
|
15 |
+
for file_path in json_files:
|
16 |
+
try:
|
17 |
+
with open(file_path, "r") as f:
|
18 |
+
data = json.load(f)
|
19 |
+
model_name = data["config_general"].get("model_name", "Unknown")
|
20 |
+
results = data.get("results", {})
|
21 |
+
|
22 |
+
# Extract relevant evaluation metrics
|
23 |
+
for task, task_data in results.items():
|
24 |
+
if "extractive_match" in task_data:
|
25 |
+
records.append({
|
26 |
+
"Model": model_name,
|
27 |
+
"Task": task,
|
28 |
+
"Extractive Match": task_data["extractive_match"],
|
29 |
+
"Std Err": task_data["extractive_match_stderr"]
|
30 |
+
})
|
31 |
+
except Exception as e:
|
32 |
+
print(f"Error reading {file_path}: {e}")
|
33 |
+
|
34 |
+
# Convert to DataFrame
|
35 |
+
df = pd.DataFrame(records)
|
36 |
+
return df.sort_values(by=["Task", "Extractive Match"], ascending=[True, False])
|
37 |
+
|
38 |
+
def leaderboard():
|
39 |
+
df = load_results()
|
40 |
+
return df
|
41 |
+
|
42 |
+
with gr.Blocks() as demo:
|
43 |
+
gr.Markdown("# π Evaluation Leaderboard")
|
44 |
+
gr.Markdown("This leaderboard displays evaluation results from JSON files in `eval_results/`.")
|
45 |
+
|
46 |
+
results_table = gr.Dataframe(leaderboard)
|
47 |
+
refresh_button = gr.Button("π Refresh")
|
48 |
+
refresh_button.click(leaderboard, outputs=[results_table])
|
49 |
+
|
50 |
+
demo.launch()
|