File size: 1,808 Bytes
fe7b1e9
 
0a76ee6
fe7b1e9
d34911b
fe7b1e9
0a76ee6
 
 
 
 
 
fe7b1e9
0a76ee6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe7b1e9
0a76ee6
 
d34911b
 
0a76ee6
 
d34911b
 
0a76ee6
d34911b
0a76ee6
 
 
 
 
 
 
d34911b
0a76ee6
 
 
 
 
fe7b1e9
 
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
import gradio as gr
import pandas as pd
import os

CSV_PATH = "results.csv"

# CSV๊ฐ€ ์—†์œผ๋ฉด ๋นˆ ํ…Œ์ด๋ธ” ์ƒ์„ฑ
if not os.path.exists(CSV_PATH):
    df_init = pd.DataFrame(columns=[
        "Model Name", "Accuracy", "F1 Score", "Inference Time (s)", "Hugging Face Link"
    ])
    df_init.to_csv(CSV_PATH, index=False)

# ์ œ์ถœ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
def submit_result(model, acc, f1, time, link):
    try:
        df = pd.read_csv(CSV_PATH)
        new_row = {
            "Model Name": model.strip(),
            "Accuracy": float(acc),
            "F1 Score": float(f1),
            "Inference Time (s)": float(time),
            "Hugging Face Link": link.strip()
        }
        updated_df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
        updated_df.to_csv(CSV_PATH, index=False)
        return "โœ… Submitted!", updated_df
    except Exception as e:
        return f"โŒ Error: {str(e)}", pd.read_csv(CSV_PATH)

# Gradio ์•ฑ
with gr.Blocks() as demo:
    gr.Markdown("# ๐Ÿ“Š Model Leaderboard + Submission")

    with gr.Row():
        model = gr.Textbox(label="Model Name")
        acc = gr.Textbox(label="Accuracy (e.g. 0.89)")
        f1 = gr.Textbox(label="F1 Score (e.g. 0.87)")
        time = gr.Textbox(label="Inference Time (s)")
        link = gr.Textbox(label="Hugging Face Link")

    submit_btn = gr.Button("Submit Result")
    status = gr.Textbox(label="Submission Status", interactive=False)
    table = gr.Dataframe(
        value=pd.read_csv(CSV_PATH),
        headers=["Model Name", "Accuracy", "F1 Score", "Inference Time (s)", "Hugging Face Link"],
        interactive=False,
        label="Current Leaderboard"
    )

    submit_btn.click(
        fn=submit_result,
        inputs=[model, acc, f1, time, link],
        outputs=[status, table]
    )

demo.launch()