eyeons commited on
Commit
0a76ee6
·
1 Parent(s): d34911b

Add submission form to leaderboard

Browse files
Files changed (1) hide show
  1. app.py +42 -20
app.py CHANGED
@@ -1,35 +1,57 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
 
4
  CSV_PATH = "results.csv"
5
 
6
- # 기존 데이터 불러오기
7
- df = pd.read_csv(CSV_PATH)
8
-
9
- def submit(model, acc, f1, time, link):
10
- new_row = {
11
- "Model Name": model,
12
- "Accuracy": float(acc),
13
- "F1 Score": float(f1),
14
- "Inference Time (s)": float(time),
15
- "Hugging Face Link": link
16
- }
17
- # 기존 + 새로운 데이터
18
- updated = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
19
- updated.to_csv(CSV_PATH, index=False)
20
- return updated
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  with gr.Blocks() as demo:
23
- gr.Markdown("# 📊 Model Leaderboard")
 
24
  with gr.Row():
25
  model = gr.Textbox(label="Model Name")
26
- acc = gr.Textbox(label="Accuracy")
27
- f1 = gr.Textbox(label="F1 Score")
28
  time = gr.Textbox(label="Inference Time (s)")
29
  link = gr.Textbox(label="Hugging Face Link")
 
30
  submit_btn = gr.Button("Submit Result")
31
- output_df = gr.Dataframe(value=df, headers=list(df.columns), interactive=False)
 
 
 
 
 
 
32
 
33
- submit_btn.click(fn=submit, inputs=[model, acc, f1, time, link], outputs=output_df)
 
 
 
 
34
 
35
  demo.launch()
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import os
4
 
5
  CSV_PATH = "results.csv"
6
 
7
+ # CSV가 없으면 빈 테이블 생성
8
+ if not os.path.exists(CSV_PATH):
9
+ df_init = pd.DataFrame(columns=[
10
+ "Model Name", "Accuracy", "F1 Score", "Inference Time (s)", "Hugging Face Link"
11
+ ])
12
+ df_init.to_csv(CSV_PATH, index=False)
 
 
 
 
 
 
 
 
 
13
 
14
+ # 제출 처리 함수
15
+ def submit_result(model, acc, f1, time, link):
16
+ try:
17
+ df = pd.read_csv(CSV_PATH)
18
+ new_row = {
19
+ "Model Name": model.strip(),
20
+ "Accuracy": float(acc),
21
+ "F1 Score": float(f1),
22
+ "Inference Time (s)": float(time),
23
+ "Hugging Face Link": link.strip()
24
+ }
25
+ updated_df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
26
+ updated_df.to_csv(CSV_PATH, index=False)
27
+ return "✅ Submitted!", updated_df
28
+ except Exception as e:
29
+ return f"❌ Error: {str(e)}", pd.read_csv(CSV_PATH)
30
+
31
+ # Gradio 앱
32
  with gr.Blocks() as demo:
33
+ gr.Markdown("# 📊 Model Leaderboard + Submission")
34
+
35
  with gr.Row():
36
  model = gr.Textbox(label="Model Name")
37
+ acc = gr.Textbox(label="Accuracy (e.g. 0.89)")
38
+ f1 = gr.Textbox(label="F1 Score (e.g. 0.87)")
39
  time = gr.Textbox(label="Inference Time (s)")
40
  link = gr.Textbox(label="Hugging Face Link")
41
+
42
  submit_btn = gr.Button("Submit Result")
43
+ status = gr.Textbox(label="Submission Status", interactive=False)
44
+ table = gr.Dataframe(
45
+ value=pd.read_csv(CSV_PATH),
46
+ headers=["Model Name", "Accuracy", "F1 Score", "Inference Time (s)", "Hugging Face Link"],
47
+ interactive=False,
48
+ label="Current Leaderboard"
49
+ )
50
 
51
+ submit_btn.click(
52
+ fn=submit_result,
53
+ inputs=[model, acc, f1, time, link],
54
+ outputs=[status, table]
55
+ )
56
 
57
  demo.launch()