Spaces:
Running
Running
Upload 131 files
Browse files- app.py +394 -332
- src/__pycache__/about.cpython-39.pyc +0 -0
- src/__pycache__/language.cpython-39.pyc +0 -0
- src/__pycache__/populate.cpython-39.pyc +0 -0
- src/display/__pycache__/filters.cpython-39.pyc +0 -0
- src/display/__pycache__/utils.cpython-39.pyc +0 -0
- src/display/filters.py +70 -70
- src/language.py +104 -0
- src/leaderboard/__pycache__/read_evals.cpython-39.pyc +0 -0
app.py
CHANGED
|
@@ -1,332 +1,394 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import gradio as gr
|
| 3 |
-
import pandas as pd
|
| 4 |
-
from src.populate import get_leaderboard_df, get_filtered_leaderboard
|
| 5 |
-
from src.display.filters import get_model_type_choices, get_strategy_choices, get_metric_categories
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
os.
|
| 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 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
if
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
def
|
| 165 |
-
"""
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
}
|
| 238 |
-
|
| 239 |
-
/*
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
.
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from src.populate import get_leaderboard_df, get_filtered_leaderboard
|
| 5 |
+
from src.display.filters import get_model_type_choices, get_strategy_choices, get_metric_categories
|
| 6 |
+
from src.language import lang
|
| 7 |
+
import logging
|
| 8 |
+
import traceback
|
| 9 |
+
|
| 10 |
+
# 配置路径
|
| 11 |
+
RESULTS_PATH = os.path.join(os.path.dirname(__file__), "results")
|
| 12 |
+
|
| 13 |
+
# 确保结果目录存在
|
| 14 |
+
os.makedirs(RESULTS_PATH, exist_ok=True)
|
| 15 |
+
|
| 16 |
+
# 配置日志
|
| 17 |
+
logging.basicConfig(
|
| 18 |
+
level=logging.INFO,
|
| 19 |
+
format="%(asctime)s - %(levelname)s - %(message)s"
|
| 20 |
+
)
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
# 配置路径
|
| 24 |
+
RESULTS_PATH = os.path.join(os.path.dirname(__file__), "results")
|
| 25 |
+
|
| 26 |
+
# 确保结果目录存在
|
| 27 |
+
os.makedirs(RESULTS_PATH, exist_ok=True)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def get_category_columns(df, category):
|
| 32 |
+
"""获取特定类别的指标列,根据类别应用不同的命名规则"""
|
| 33 |
+
if df.empty:
|
| 34 |
+
return [], {}
|
| 35 |
+
|
| 36 |
+
category_name = category["name"]
|
| 37 |
+
prefixes = category["prefix"]
|
| 38 |
+
if not isinstance(prefixes, list):
|
| 39 |
+
prefixes = [prefixes]
|
| 40 |
+
|
| 41 |
+
# 确保model_name和model_type在前面
|
| 42 |
+
columns = []
|
| 43 |
+
if 'model_name' in df.columns:
|
| 44 |
+
columns.append('model_name')
|
| 45 |
+
if 'model_type' in df.columns and 'model_type' not in columns:
|
| 46 |
+
columns.append('model_type')
|
| 47 |
+
|
| 48 |
+
# 收集并处理指标列
|
| 49 |
+
metric_columns = []
|
| 50 |
+
for col in df.columns:
|
| 51 |
+
for p in prefixes:
|
| 52 |
+
if col.startswith(f"MAE_{p}") or col.startswith(f"MSE_{p}"):
|
| 53 |
+
# 不同类别使用不同的重命名规则
|
| 54 |
+
if category_name == "平稳性/非平稳性":
|
| 55 |
+
# 平稳性保留原始名称
|
| 56 |
+
simplified_col = col
|
| 57 |
+
elif category_name == "方差特性":
|
| 58 |
+
# 方差特性:保留homo/hetero区分(小写简化)
|
| 59 |
+
if "Homo-Scedasticity" in p:
|
| 60 |
+
simplified_col = col.replace(p, "Homo_", 1)
|
| 61 |
+
elif "Hetero-Scedasticity" in p:
|
| 62 |
+
simplified_col = col.replace(p, "Hetero_", 1)
|
| 63 |
+
else:
|
| 64 |
+
simplified_col = col # 兜底
|
| 65 |
+
elif category_name == "季节数":
|
| 66 |
+
|
| 67 |
+
# 方差特性:保留homo/hetero区分(小写简化)
|
| 68 |
+
if "Seasonality_Count" in p:
|
| 69 |
+
|
| 70 |
+
simplified_col = col.replace(p, "Count", 1)
|
| 71 |
+
else:
|
| 72 |
+
simplified_col = col # 兜底
|
| 73 |
+
else:
|
| 74 |
+
# 其他类别(除平稳性和方差特性外)移除大类前缀
|
| 75 |
+
simplified_col = col.replace(p, "", 1)
|
| 76 |
+
metric_columns.append((col, simplified_col))
|
| 77 |
+
break # 避免重复处理
|
| 78 |
+
|
| 79 |
+
# 去重并保持顺序
|
| 80 |
+
seen = set()
|
| 81 |
+
unique_metrics = []
|
| 82 |
+
for col, simplified in metric_columns:
|
| 83 |
+
if col not in seen:
|
| 84 |
+
seen.add(col)
|
| 85 |
+
unique_metrics.append((col, simplified))
|
| 86 |
+
|
| 87 |
+
# 过滤存在的列
|
| 88 |
+
existing_columns = [col for col in columns + [col for col, _ in unique_metrics] if col in df.columns]
|
| 89 |
+
|
| 90 |
+
# 创建重命名字典
|
| 91 |
+
rename_dict = {col: simplified for col, simplified in unique_metrics if col in existing_columns}
|
| 92 |
+
|
| 93 |
+
return existing_columns, rename_dict
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def refresh_leaderboard():
|
| 97 |
+
"""刷新排行榜数据,添加详细日志和错误捕获"""
|
| 98 |
+
logger.info("开始刷新排行榜数据")
|
| 99 |
+
try:
|
| 100 |
+
if not os.path.exists(RESULTS_PATH):
|
| 101 |
+
error_msg = f"❌ 结果目录不存在: {RESULTS_PATH}"
|
| 102 |
+
logger.error(error_msg)
|
| 103 |
+
outputs = []
|
| 104 |
+
categories = get_metric_categories()
|
| 105 |
+
for _ in categories:
|
| 106 |
+
outputs.append(gr.Dataframe(value=pd.DataFrame(), visible=True))
|
| 107 |
+
outputs.append(gr.Markdown(value=error_msg, visible=True))
|
| 108 |
+
return outputs
|
| 109 |
+
|
| 110 |
+
if not os.path.isdir(RESULTS_PATH):
|
| 111 |
+
error_msg = f"❌ {RESULTS_PATH} 不是一个目录"
|
| 112 |
+
logger.error(error_msg)
|
| 113 |
+
outputs = []
|
| 114 |
+
categories = get_metric_categories()
|
| 115 |
+
for _ in categories:
|
| 116 |
+
outputs.append(gr.Dataframe(value=pd.DataFrame(), visible=True))
|
| 117 |
+
outputs.append(gr.Markdown(value=error_msg, visible=True))
|
| 118 |
+
return outputs
|
| 119 |
+
|
| 120 |
+
# 加载数据并打印日志
|
| 121 |
+
df = get_leaderboard_df(RESULTS_PATH)
|
| 122 |
+
logger.info(f"成功加载数据,共 {len(df)} 条记录")
|
| 123 |
+
|
| 124 |
+
categories = get_metric_categories()
|
| 125 |
+
outputs = []
|
| 126 |
+
|
| 127 |
+
for category in categories:
|
| 128 |
+
if df.empty:
|
| 129 |
+
outputs.append(gr.Dataframe(value=pd.DataFrame(), visible=True))
|
| 130 |
+
else:
|
| 131 |
+
category_cols, rename_dict = get_category_columns(df, category)
|
| 132 |
+
logger.info(f"类别 {category['name']} 的列: {category_cols}")
|
| 133 |
+
|
| 134 |
+
display_df = df[category_cols].copy()
|
| 135 |
+
display_df = display_df.rename(columns=rename_dict)
|
| 136 |
+
|
| 137 |
+
if 'model_name' in display_df.columns:
|
| 138 |
+
display_df['model_name'] = display_df['model_name'].str.slice(0, 25) + \
|
| 139 |
+
(display_df['model_name'].str.len() > 25).map({True: '...', False: ''})
|
| 140 |
+
|
| 141 |
+
outputs.append(gr.Dataframe(value=display_df, visible=True))
|
| 142 |
+
|
| 143 |
+
if df.empty:
|
| 144 |
+
model_folders = [f for f in os.listdir(RESULTS_PATH) if os.path.isdir(os.path.join(RESULTS_PATH, f))]
|
| 145 |
+
error_msg = "⚠️ 找到模型文件夹,但无法加载数据" if model_folders else f"⚠️ 未在 {RESULTS_PATH} 中找到模型"
|
| 146 |
+
logger.warning(error_msg)
|
| 147 |
+
outputs.append(gr.Markdown(value=error_msg, visible=True))
|
| 148 |
+
else:
|
| 149 |
+
outputs.append(gr.Markdown(value="", visible=False))
|
| 150 |
+
|
| 151 |
+
logger.info("刷新排行榜完成")
|
| 152 |
+
return outputs
|
| 153 |
+
|
| 154 |
+
except Exception as e:
|
| 155 |
+
error_msg = f"刷新数据失败: {str(e)}\n{traceback.format_exc()}"
|
| 156 |
+
logger.error(error_msg)
|
| 157 |
+
# 返回错误状态
|
| 158 |
+
categories = get_metric_categories()
|
| 159 |
+
outputs = [gr.Dataframe(value=pd.DataFrame(), visible=True) for _ in categories]
|
| 160 |
+
outputs.append(gr.Markdown(value=f"❌ 刷新失败: {str(e)}", visible=True))
|
| 161 |
+
return outputs
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def apply_filters(model_type, strategies, filter_mode):
|
| 165 |
+
"""应用筛选条件,添加详细日志和错误捕获"""
|
| 166 |
+
logger.info(f"开始应用筛选: 模型类型={model_type}, 策略={strategies}, 模式={filter_mode}")
|
| 167 |
+
try:
|
| 168 |
+
filtered_df = get_filtered_leaderboard(
|
| 169 |
+
RESULTS_PATH,
|
| 170 |
+
model_type=model_type,
|
| 171 |
+
strategies=strategies,
|
| 172 |
+
filter_mode=filter_mode
|
| 173 |
+
)
|
| 174 |
+
logger.info(f"筛选完成,得到 {len(filtered_df)} 条记录")
|
| 175 |
+
|
| 176 |
+
categories = get_metric_categories()
|
| 177 |
+
outputs = []
|
| 178 |
+
|
| 179 |
+
for category in categories:
|
| 180 |
+
if filtered_df.empty:
|
| 181 |
+
outputs.append(gr.Dataframe(value=pd.DataFrame(), visible=True))
|
| 182 |
+
else:
|
| 183 |
+
category_cols, rename_dict = get_category_columns(filtered_df, category)
|
| 184 |
+
logger.info(f"筛选后类别 {category['name']} 的列: {category_cols}")
|
| 185 |
+
|
| 186 |
+
display_df = filtered_df[category_cols].copy()
|
| 187 |
+
display_df = display_df.rename(columns=rename_dict)
|
| 188 |
+
|
| 189 |
+
if 'model_name' in display_df.columns:
|
| 190 |
+
display_df['model_name'] = display_df['model_name'].str.slice(0, 25) + \
|
| 191 |
+
(display_df['model_name'].str.len() > 25).map({True: '...', False: ''})
|
| 192 |
+
|
| 193 |
+
outputs.append(gr.Dataframe(value=display_df, visible=True))
|
| 194 |
+
|
| 195 |
+
empty_msg = "⚠️ 没有找到符合筛选条件的模型。" if filtered_df.empty else ""
|
| 196 |
+
outputs.append(gr.Markdown(value=empty_msg, visible=filtered_df.empty))
|
| 197 |
+
logger.info("筛选应用完成")
|
| 198 |
+
return outputs
|
| 199 |
+
|
| 200 |
+
except Exception as e:
|
| 201 |
+
error_msg = f"筛选失败: {str(e)}\n{traceback.format_exc()}"
|
| 202 |
+
logger.error(error_msg)
|
| 203 |
+
# 返回错误状态
|
| 204 |
+
categories = get_metric_categories()
|
| 205 |
+
outputs = [gr.Dataframe(value=pd.DataFrame(), visible=True) for _ in categories]
|
| 206 |
+
outputs.append(gr.Markdown(value=f"❌ 筛选失败: {str(e)}", visible=True))
|
| 207 |
+
return outputs
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def create_interface():
|
| 212 |
+
"""创建Gradio界面,单表格固定model_name列(兼容旧版本Gradio)"""
|
| 213 |
+
try:
|
| 214 |
+
model_type_choices = get_model_type_choices()
|
| 215 |
+
except Exception as e:
|
| 216 |
+
model_type_choices = ["All"]
|
| 217 |
+
print(f"获取模型类型选项时出错: {str(e)}")
|
| 218 |
+
|
| 219 |
+
try:
|
| 220 |
+
strategy_choices = get_strategy_choices(RESULTS_PATH)
|
| 221 |
+
except Exception as e:
|
| 222 |
+
strategy_choices = []
|
| 223 |
+
print(f"获取策略选项时出错: {str(e)}")
|
| 224 |
+
|
| 225 |
+
categories = get_metric_categories()
|
| 226 |
+
|
| 227 |
+
with gr.Blocks(title="Aries 模型评估排行榜") as demo:
|
| 228 |
+
# 添加CSS确保model_name列固定
|
| 229 |
+
gr.HTML("""
|
| 230 |
+
<style>
|
| 231 |
+
/* 表格容器基础设置 */
|
| 232 |
+
.fixed-column-table {
|
| 233 |
+
overflow: visible !important; /* 原先是auto,改为visible禁用滚动条 */
|
| 234 |
+
position: relative !important;
|
| 235 |
+
max-height: 90vh !important;
|
| 236 |
+
height: auto !important;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/* 单元格内边距优化 */
|
| 240 |
+
.fixed-column-table td,
|
| 241 |
+
.fixed-column-table th {
|
| 242 |
+
padding: 0.2rem 0.3rem !important;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
/* 基础模式(浅色)样式 */
|
| 246 |
+
.fixed-column-table table th:first-child,
|
| 247 |
+
.fixed-column-table table td:first-child {
|
| 248 |
+
position: sticky !important;
|
| 249 |
+
left: 0 !important;
|
| 250 |
+
z-index: 2 !important;
|
| 251 |
+
background-color: white !important;
|
| 252 |
+
color: #333 !important; /* 文本色 */
|
| 253 |
+
min-width: 150px !important;
|
| 254 |
+
max-width: 150px !important;
|
| 255 |
+
font-weight: bold !important;
|
| 256 |
+
box-shadow: 1px 0 2px rgba(0,0,0,0.1) !important;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
.fixed-column-table table thead th {
|
| 260 |
+
position: sticky !important;
|
| 261 |
+
top: 0 !important;
|
| 262 |
+
z-index: 1 !important;
|
| 263 |
+
background-color: white !important;
|
| 264 |
+
color: #333 !important; /* 文本色 */
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.fixed-column-table table thead th:first-child {
|
| 268 |
+
z-index: 3 !important;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/* 第二列宽度设置 */
|
| 272 |
+
.fixed-column-table table th:nth-child(2),
|
| 273 |
+
.fixed-column-table table td:nth-child(2) {
|
| 274 |
+
min-width: 215px !important;
|
| 275 |
+
max-width: 215px !important;
|
| 276 |
+
white-space: nowrap !important;
|
| 277 |
+
overflow: hidden !important;
|
| 278 |
+
text-overflow: ellipsis !important;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/* 禁用内部滚动 */
|
| 282 |
+
.fixed-column-table .dataframe-container {
|
| 283 |
+
overflow: visible !important;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* 深色模式适配 */
|
| 287 |
+
@media (prefers-color-scheme: dark) {
|
| 288 |
+
.fixed-column-table table th:first-child,
|
| 289 |
+
.fixed-column-table table td:first-child {
|
| 290 |
+
background-color: #333 !important;
|
| 291 |
+
color: #fff !important;
|
| 292 |
+
box-shadow: 1px 0 2px rgba(0,0,0,0.3) !important;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.fixed-column-table table thead th {
|
| 296 |
+
background-color: #333 !important;
|
| 297 |
+
color: #fff !important;
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
</style>
|
| 301 |
+
""")
|
| 302 |
+
|
| 303 |
+
gr.Markdown(f"# {lang.get('title')}")
|
| 304 |
+
# 添加语言切换按钮
|
| 305 |
+
with gr.Row():
|
| 306 |
+
lang_btn = gr.Button(f"切换至英文" if lang.current_lang == "zh" else f"Switch to Chinese")
|
| 307 |
+
|
| 308 |
+
with gr.Tabs():
|
| 309 |
+
with gr.Tab(lang.get("model_leaderboard")):
|
| 310 |
+
with gr.Row():
|
| 311 |
+
with gr.Column(scale=1):
|
| 312 |
+
gr.Markdown(f"### {lang.get('filter_conditions')}")
|
| 313 |
+
|
| 314 |
+
model_type = gr.Dropdown(
|
| 315 |
+
choices=model_type_choices,
|
| 316 |
+
label=lang.get("model_type"),
|
| 317 |
+
value="All"
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
strategies = gr.CheckboxGroup(
|
| 321 |
+
choices=strategy_choices,
|
| 322 |
+
label=lang.get("strategies"),
|
| 323 |
+
value=[]
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
filter_mode = gr.Radio(
|
| 327 |
+
choices=[lang.get("intersection"), lang.get("union")],
|
| 328 |
+
label=lang.get("filter_mode"),
|
| 329 |
+
value=lang.get("intersection")
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
with gr.Row():
|
| 333 |
+
refresh_btn = gr.Button(lang.get("refresh"))
|
| 334 |
+
apply_btn = gr.Button(lang.get("apply_filters")) # 这个是正确的按钮变量名
|
| 335 |
+
|
| 336 |
+
with gr.Column(scale=3):
|
| 337 |
+
empty_state = gr.Markdown(visible=False) # 对应错误信息显示组件
|
| 338 |
+
|
| 339 |
+
with gr.Tabs() as category_tabs:
|
| 340 |
+
category_dataframes = [] # 保存所有数据表格组件
|
| 341 |
+
for category in categories:
|
| 342 |
+
with gr.Tab(category["name"]):
|
| 343 |
+
df_component = gr.Dataframe(
|
| 344 |
+
interactive=False,
|
| 345 |
+
wrap=True,
|
| 346 |
+
label=category["description"],
|
| 347 |
+
elem_classes="fixed-column-table"
|
| 348 |
+
)
|
| 349 |
+
category_dataframes.append(df_component)
|
| 350 |
+
|
| 351 |
+
with gr.Tab("关于"):
|
| 352 |
+
gr.Markdown("""
|
| 353 |
+
## 关于 Aries 模型评估排行榜
|
| 354 |
+
该排行榜展示了各种模型在标准基准测试中的表现,包含所有评估指标。
|
| 355 |
+
""")
|
| 356 |
+
|
| 357 |
+
# 设置事件处理 - 修正为正确的apply_btn
|
| 358 |
+
apply_btn.click( # 这里之前错写为filter_btn
|
| 359 |
+
fn=apply_filters,
|
| 360 |
+
inputs=[model_type, strategies, filter_mode],
|
| 361 |
+
outputs=category_dataframes + [empty_state]
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
refresh_btn.click(
|
| 365 |
+
fn=refresh_leaderboard,
|
| 366 |
+
outputs=category_dataframes + [empty_state]
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
demo.load(
|
| 370 |
+
fn=refresh_leaderboard,
|
| 371 |
+
outputs=category_dataframes + [empty_state]
|
| 372 |
+
)
|
| 373 |
+
|
| 374 |
+
def toggle_language():
|
| 375 |
+
new_lang = lang.switch_language()
|
| 376 |
+
btn_text = "切换至英文" if new_lang == "en" else "Switch to Chinese"
|
| 377 |
+
# 刷新界面 - 使用正确的组件列表
|
| 378 |
+
return [btn_text] + refresh_leaderboard()
|
| 379 |
+
|
| 380 |
+
lang_btn.click(
|
| 381 |
+
fn=toggle_language,
|
| 382 |
+
inputs=[],
|
| 383 |
+
outputs=[lang_btn] + category_dataframes + [empty_state] # 确保变量名一致
|
| 384 |
+
)
|
| 385 |
+
|
| 386 |
+
return demo
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
if __name__ == "__main__":
|
| 390 |
+
print(f"正在启动Aries模型评估排行榜,结果目录: {RESULTS_PATH}")
|
| 391 |
+
demo = create_interface()
|
| 392 |
+
demo.launch()
|
| 393 |
+
|
| 394 |
+
|
src/__pycache__/about.cpython-39.pyc
CHANGED
|
Binary files a/src/__pycache__/about.cpython-39.pyc and b/src/__pycache__/about.cpython-39.pyc differ
|
|
|
src/__pycache__/language.cpython-39.pyc
ADDED
|
Binary file (4.05 kB). View file
|
|
|
src/__pycache__/populate.cpython-39.pyc
CHANGED
|
Binary files a/src/__pycache__/populate.cpython-39.pyc and b/src/__pycache__/populate.cpython-39.pyc differ
|
|
|
src/display/__pycache__/filters.cpython-39.pyc
CHANGED
|
Binary files a/src/display/__pycache__/filters.cpython-39.pyc and b/src/display/__pycache__/filters.cpython-39.pyc differ
|
|
|
src/display/__pycache__/utils.cpython-39.pyc
CHANGED
|
Binary files a/src/display/__pycache__/utils.cpython-39.pyc and b/src/display/__pycache__/utils.cpython-39.pyc differ
|
|
|
src/display/filters.py
CHANGED
|
@@ -1,70 +1,70 @@
|
|
| 1 |
-
from src.display.utils import ModelType
|
| 2 |
-
from src.leaderboard.read_evals import get_all_strategies
|
| 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 |
-
"name": "
|
| 41 |
-
"prefix": "Seasonality_Strength_",
|
| 42 |
-
"description": "
|
| 43 |
-
},
|
| 44 |
-
{
|
| 45 |
-
"name": "
|
| 46 |
-
"prefix": "Seasonality_Count_",
|
| 47 |
-
"description": "
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
"name": "
|
| 51 |
-
"prefix": "Volatility_",
|
| 52 |
-
"description": "
|
| 53 |
-
},
|
| 54 |
-
{
|
| 55 |
-
"name": "
|
| 56 |
-
"prefix": "Memory_",
|
| 57 |
-
"description": "
|
| 58 |
-
},
|
| 59 |
-
{
|
| 60 |
-
"name": "
|
| 61 |
-
"prefix": ["Homo-Scedasticity_", "Hetero-Scedasticity_"],
|
| 62 |
-
"description": "
|
| 63 |
-
},
|
| 64 |
-
{
|
| 65 |
-
"name": "
|
| 66 |
-
"prefix": "Anomaly_",
|
| 67 |
-
"description": "
|
| 68 |
-
}
|
| 69 |
-
]
|
| 70 |
-
|
|
|
|
| 1 |
+
from src.display.utils import ModelType
|
| 2 |
+
from src.leaderboard.read_evals import get_all_strategies
|
| 3 |
+
from src.language import lang
|
| 4 |
+
|
| 5 |
+
def get_model_type_choices():
|
| 6 |
+
"""获取模型类型筛选选项,与ModelType枚举兼容"""
|
| 7 |
+
# 生成带符号的模型类型选项
|
| 8 |
+
type_choices = [mt.to_str() for mt in ModelType if mt != ModelType.Unknown]
|
| 9 |
+
# 在开头添加"All"选项
|
| 10 |
+
return ["All"] + type_choices
|
| 11 |
+
|
| 12 |
+
def get_strategy_choices(results_path):
|
| 13 |
+
"""获取策略筛选选项"""
|
| 14 |
+
return get_all_strategies(results_path)
|
| 15 |
+
|
| 16 |
+
def get_metric_categories():
|
| 17 |
+
"""
|
| 18 |
+
获取指标类别分组,按照要求调整:
|
| 19 |
+
- 平稳性和非平稳性合并为一类
|
| 20 |
+
- 同方差和异方差合并为一类
|
| 21 |
+
- 季节特性拆分为季节强度和季节数
|
| 22 |
+
"""
|
| 23 |
+
return [
|
| 24 |
+
{
|
| 25 |
+
"name": lang.get("regular_metrics"),
|
| 26 |
+
"prefix": "Regular_",
|
| 27 |
+
"description": lang.get("regular_desc")
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"name": lang.get("stationarity"),
|
| 31 |
+
"prefix": ["Stationary_", "Non_Stationary_"],
|
| 32 |
+
"description": lang.get("stationarity_desc")
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": lang.get("trend_strength"),
|
| 36 |
+
"prefix": "Trend_Strength_",
|
| 37 |
+
"description": lang.get("trend_strength_desc")
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"name": lang.get("seasonality_strength"),
|
| 41 |
+
"prefix": "Seasonality_Strength_",
|
| 42 |
+
"description": lang.get("seasonality_strength_desc")
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"name": lang.get("seasonality_count"),
|
| 46 |
+
"prefix": "Seasonality_Count_",
|
| 47 |
+
"description": lang.get("seasonality_count_desc")
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"name": lang.get("volatility"),
|
| 51 |
+
"prefix": "Volatility_",
|
| 52 |
+
"description": lang.get("volatility_desc")
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": lang.get("memory"),
|
| 56 |
+
"prefix": "Memory_",
|
| 57 |
+
"description": lang.get("memory_desc")
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"name": lang.get("variance_characteristics"),
|
| 61 |
+
"prefix": ["Homo-Scedasticity_", "Hetero-Scedasticity_"],
|
| 62 |
+
"description": lang.get("variance_characteristics_desc")
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"name": lang.get("outliers"),
|
| 66 |
+
"prefix": "Anomaly_",
|
| 67 |
+
"description": lang.get("outliers_desc")
|
| 68 |
+
}
|
| 69 |
+
]
|
| 70 |
+
|
src/language.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# src/language.py
|
| 2 |
+
class LanguageManager:
|
| 3 |
+
def __init__(self):
|
| 4 |
+
self.current_lang = "en" # 默认中文
|
| 5 |
+
self.translations = {
|
| 6 |
+
"zh": {
|
| 7 |
+
# app.py 中的文本
|
| 8 |
+
"title": "🚀 Aries 模型评估排行榜",
|
| 9 |
+
"model_leaderboard": "模型排行榜",
|
| 10 |
+
"filter_conditions": "筛选条件",
|
| 11 |
+
"model_type": "模型类型",
|
| 12 |
+
"strategies": "策略",
|
| 13 |
+
"filter_mode": "筛选模式",
|
| 14 |
+
"refresh": "刷新",
|
| 15 |
+
"apply_filters": "应用筛选",
|
| 16 |
+
"all": "All", # 保持英文
|
| 17 |
+
"intersection": "交集 (满足所有选中策略)",
|
| 18 |
+
"union": "并集 (满足任一选中策略)",
|
| 19 |
+
"no_results": "⚠️ 没有找到符合筛选条件的模型。",
|
| 20 |
+
"results_dir_not_exist": "❌ 结果目录不存在: {path}",
|
| 21 |
+
"not_a_directory": "❌ {path} 不是一个目录",
|
| 22 |
+
"no_model_data": "⚠️ 找到模型文件夹,但无法加载数据",
|
| 23 |
+
"no_model_folders": "⚠️ 未在 {path} 中找到模型",
|
| 24 |
+
|
| 25 |
+
# 指标类别 - src/display/filters.py
|
| 26 |
+
"regular_metrics": "常规指标",
|
| 27 |
+
"stationarity": "平稳性/非平稳性",
|
| 28 |
+
"trend_strength": "趋势强度",
|
| 29 |
+
"seasonality_strength": "季节强度",
|
| 30 |
+
"seasonality_count": "季节数",
|
| 31 |
+
"volatility": "波动性",
|
| 32 |
+
"memory": "记忆性",
|
| 33 |
+
"variance_characteristics": "方差特性",
|
| 34 |
+
"outliers": "异常值",
|
| 35 |
+
|
| 36 |
+
# 指标描述
|
| 37 |
+
"regular_desc": "基础评估指标,适用于所有类型的数据",
|
| 38 |
+
"stationarity_desc": "模型在平稳和非平稳序列上的表现",
|
| 39 |
+
"trend_strength_desc": "模型在不同趋势强度数据上的表现",
|
| 40 |
+
"seasonality_strength_desc": "模型在不同季节强度数据上的表现",
|
| 41 |
+
"seasonality_count_desc": "模型在不同季节计数(周期数量)数据上的表现",
|
| 42 |
+
"volatility_desc": "模型在不同波动性特征数据上的表现",
|
| 43 |
+
"memory_desc": "模型在不同记忆性特征数据上的表现",
|
| 44 |
+
"variance_characteristics_desc": "模型在同方差和异方差数据上的表现",
|
| 45 |
+
"outliers_desc": "模型在包含不同比例异常值数据上的表现"
|
| 46 |
+
},
|
| 47 |
+
"en": {
|
| 48 |
+
# app.py 中的文本
|
| 49 |
+
"title": "🚀 Aries Model Evaluation Leaderboard",
|
| 50 |
+
"model_leaderboard": "Model Leaderboard",
|
| 51 |
+
"filter_conditions": "Filter Conditions",
|
| 52 |
+
"model_type": "Model Type",
|
| 53 |
+
"strategies": "Strategies",
|
| 54 |
+
"filter_mode": "Filter Mode",
|
| 55 |
+
"refresh": "Refresh",
|
| 56 |
+
"apply_filters": "Apply Filters",
|
| 57 |
+
"all": "All",
|
| 58 |
+
"intersection": "Intersection (meet all selected strategies)",
|
| 59 |
+
"union": "Union (meet any selected strategy)",
|
| 60 |
+
"no_results": "⚠️ No models found matching the filter criteria.",
|
| 61 |
+
"results_dir_not_exist": "❌ Results directory does not exist: {path}",
|
| 62 |
+
"not_a_directory": "❌ {path} is not a directory",
|
| 63 |
+
"no_model_data": "⚠️ Model folders found, but unable to load data",
|
| 64 |
+
"no_model_folders": "⚠️ No models found in {path}",
|
| 65 |
+
|
| 66 |
+
# 指标类别
|
| 67 |
+
"regular_metrics": "Regular Metrics",
|
| 68 |
+
"stationarity": "Stationarity/Non-stationarity",
|
| 69 |
+
"trend_strength": "Trend Strength",
|
| 70 |
+
"seasonality_strength": "Seasonality Strength",
|
| 71 |
+
"seasonality_count": "Seasonality Count",
|
| 72 |
+
"volatility": "Volatility",
|
| 73 |
+
"memory": "Memory",
|
| 74 |
+
"variance_characteristics": "Variance Characteristics",
|
| 75 |
+
"outliers": "Anomalies",
|
| 76 |
+
|
| 77 |
+
# 指标描述
|
| 78 |
+
"regular_desc": "Basic evaluation metrics applicable to all data types",
|
| 79 |
+
"stationarity_desc": "Model performance on stationary and non-stationary sequences",
|
| 80 |
+
"trend_strength_desc": "Model performance on data with different trend strengths",
|
| 81 |
+
"seasonality_strength_desc": "Model performance on data with different seasonality strengths",
|
| 82 |
+
"seasonality_count_desc": "Model performance on data with different seasonality counts (number of cycles)",
|
| 83 |
+
"volatility_desc": "Model performance on data with different volatility characteristics",
|
| 84 |
+
"memory_desc": "Model performance on data with different memory characteristics",
|
| 85 |
+
"variance_characteristics_desc": "Model performance on homoscedastic and heteroscedastic data",
|
| 86 |
+
"outliers_desc": "Model performance on data containing different proportions of outliers"
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
def switch_language(self):
|
| 91 |
+
"""切换语言"""
|
| 92 |
+
self.current_lang = "en" if self.current_lang == "zh" else "zh"
|
| 93 |
+
return self.current_lang
|
| 94 |
+
|
| 95 |
+
def get(self, key, **kwargs):
|
| 96 |
+
"""获取翻译文本,支持格式化参数"""
|
| 97 |
+
text = self.translations[self.current_lang].get(key, key)
|
| 98 |
+
if kwargs:
|
| 99 |
+
return text.format(**kwargs)
|
| 100 |
+
return text
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
# 创建全局实例
|
| 104 |
+
lang = LanguageManager()
|
src/leaderboard/__pycache__/read_evals.cpython-39.pyc
CHANGED
|
Binary files a/src/leaderboard/__pycache__/read_evals.cpython-39.pyc and b/src/leaderboard/__pycache__/read_evals.cpython-39.pyc differ
|
|
|