Spaces:
Sleeping
Sleeping
File size: 2,756 Bytes
f1e1ac2 |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import json
import os
import gradio as gr
import pandas as pd
from assets.constant import DELIMITER
from assets.content import KEYPOINT_TEXT
from assets.path import SEASON
def build_question(season):
dir = os.path.join("results", SEASON[season], "details")
rows = []
for model in os.listdir(dir):
acc_result = json.load(open(os.path.join(dir, model, "acc_result.json"), encoding="utf-8"))
rows.append(
[model, round(acc_result['acc'], 4), round(acc_result['human_acc'], 4), round(acc_result['wrong_value'], 4),
acc_result['hit'],acc_result['wrong_hit'], acc_result['wrong_total'], acc_result['total']])
return pd.DataFrame(rows, columns=["Model", "Acc", "Human Acc", "Wrong Value", "Hit", "Wrong Hit", "Wrong Total",
"Total"]).sort_values("Acc", ascending=False)
def build_keypoint(season):
dir = os.path.join("results", SEASON[season], "details")
rows, columns, final_columns = [], [], []
for model in os.listdir(dir):
category_result = json.load(open(os.path.join(dir, model, "category_result-all.json"), encoding="utf-8"))
if not columns:
columns = sorted([k for k in category_result if not k.count(DELIMITER)],
key=lambda x: category_result[x]['all'], reverse=True)
final_columns = [f"{c}:{category_result.get(c).get('all')}" for c in columns]
rows.append([model] + [round(category_result.get(c).get("acc"), 4) for c in columns])
return pd.DataFrame(rows, columns=["Model"] + final_columns).sort_values(final_columns[0], ascending=False)
def build_difficulty(season):
dir = os.path.join("results", SEASON[season], "details")
rows, columns, final_columns = [], [], []
for model in os.listdir(dir):
difficulty_result = json.load(open(os.path.join(dir, model, "difficulty_result.json"), encoding="utf-8"))
if not columns:
columns = sorted(difficulty_result, reverse=True)
final_columns = [f"{c}:{difficulty_result.get(c).get('all')}" for c in columns]
rows.append([model] + [round(difficulty_result.get(c).get("acc"), 4) for c in columns])
return pd.DataFrame(rows, columns=["Model"] + final_columns).sort_values(final_columns[0], ascending=False)
def create_result(top_components):
with gr.Tab("Question Level"):
question_df = gr.DataFrame(build_question("latest"), label="Acc Result")
with gr.Tab("Keypoint Level"):
gr.Markdown(KEYPOINT_TEXT)
keypoint_df = gr.DataFrame(build_keypoint("latest"), label="Keypoint Level1 Result")
with gr.Tab("Difficulty Level"):
difficulty_df = gr.DataFrame(build_difficulty("latest"), label="Difficulty Result")
|