File size: 984 Bytes
b29fd2d
7d9cce6
b29fd2d
7d9cce6
 
 
b29fd2d
 
 
 
 
7d9cce6
b29fd2d
 
7d9cce6
b29fd2d
 
7d9cce6
b29fd2d
 
 
 
 
 
7d9cce6
 
b29fd2d
 
7d9cce6
 
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
import pandas as pd

from .dataset import get_leaderboard_df, save_leaderboard_df
from .evaluation import evaluate_model


def submit_model(model_name: str, model_url: str):
    if not model_name.strip():
        raise ValueError("Model name cannot be empty.")
    if not model_url.strip():
        raise ValueError("Model URL cannot be empty.")

    # 現在のリーダーボードを取得
    df = get_leaderboard_df()

    # 新規評価
    score = evaluate_model(model_url)

    # 新規行追加
    new_entry = {"Model Name": model_name.strip(), "Score (relative_error_loss)": score}
    df = pd.concat([df, pd.DataFrame([new_entry])], ignore_index=True)

    # スコアが小さいほど良いと仮定し、昇順ソート&Rank再計算
    df = df.sort_values(by="Score (relative_error_loss)", ascending=True).reset_index(drop=True)
    df["Rank"] = range(1, len(df) + 1)

    # データセットをHugging Face Hubに反映
    save_leaderboard_df(df)

    return df