README / app.py
eyeons's picture
Add submission form to leaderboard
0a76ee6
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()