Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -132,8 +132,7 @@ def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
|
132 |
if c not in seen:
|
133 |
unique_columns.append(c)
|
134 |
seen.add(c)
|
135 |
-
|
136 |
-
unique_columns.insert(1, AutoEvalColumn.model.name) # Type_の次にModelを挿入
|
137 |
filtered_df = df[unique_columns]
|
138 |
return filtered_df
|
139 |
|
@@ -293,47 +292,105 @@ with demo:
|
|
293 |
# visible=True,
|
294 |
# )
|
295 |
|
296 |
-
# 初期のカラム選択
|
297 |
initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
|
298 |
leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns)
|
299 |
|
300 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
leaderboard_df_filtered = leaderboard_df_filtered.rename(columns={'T': 'Type_'})
|
|
|
|
|
|
|
|
|
302 |
|
303 |
-
# '
|
304 |
-
leaderboard_df_filtered['
|
305 |
|
306 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
for col in leaderboard_df_filtered.columns:
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
# デバッグ用出力
|
311 |
-
print("
|
312 |
-
print(leaderboard_df_filtered
|
313 |
-
print("\nFirst few rows of leaderboard_df_filtered:")
|
314 |
print(leaderboard_df_filtered.head())
|
315 |
-
# データを辞書のリストに変換
|
316 |
-
data_dict = leaderboard_df_filtered.to_dict('records')
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
headers = list(leaderboard_df_filtered.columns)
|
321 |
-
datatype = {col: "str" for col in headers}
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
|
|
|
|
|
|
|
|
327 |
elem_id="leaderboard-table",
|
328 |
interactive=False,
|
329 |
visible=True,
|
330 |
)
|
331 |
|
332 |
-
|
333 |
-
|
334 |
-
# デバッグ情報の出力
|
335 |
-
print("\nLeaderboard table headers:")
|
336 |
-
print(leaderboard_table.headers)
|
337 |
|
338 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
339 |
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
@@ -416,14 +473,8 @@ with demo:
|
|
416 |
open=False,
|
417 |
):
|
418 |
with gr.Row():
|
419 |
-
# finished_eval_table = gr.components.Dataframe(
|
420 |
-
# value=finished_eval_queue_df,
|
421 |
-
# headers=EVAL_COLS,
|
422 |
-
# datatype=EVAL_TYPES,
|
423 |
-
# row_count=5,
|
424 |
-
# )
|
425 |
finished_eval_table = gr.components.Dataframe(
|
426 |
-
value=finished_eval_queue_df
|
427 |
headers=EVAL_COLS,
|
428 |
datatype=EVAL_TYPES,
|
429 |
row_count=5,
|
|
|
132 |
if c not in seen:
|
133 |
unique_columns.append(c)
|
134 |
seen.add(c)
|
135 |
+
# フィルタリングされたカラムでデータフレームを作成
|
|
|
136 |
filtered_df = df[unique_columns]
|
137 |
return filtered_df
|
138 |
|
|
|
292 |
# visible=True,
|
293 |
# )
|
294 |
|
|
|
295 |
initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
|
296 |
leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns)
|
297 |
|
298 |
+
# 重複カラムの確認と削除
|
299 |
+
duplicate_columns = leaderboard_df_filtered.columns[leaderboard_df_filtered.columns.duplicated()]
|
300 |
+
if len(duplicate_columns) > 0:
|
301 |
+
print(f"Duplicate columns found: {duplicate_columns.tolist()}")
|
302 |
+
# 重複カラムを削除(最初の出現を保持)
|
303 |
+
leaderboard_df_filtered = leaderboard_df_filtered.loc[:, ~leaderboard_df_filtered.columns.duplicated()]
|
304 |
+
print("Duplicate columns have been removed.")
|
305 |
+
else:
|
306 |
+
print("No duplicate columns found.")
|
307 |
+
|
308 |
+
# 'T' カラムの欠損値を確認
|
309 |
+
missing_T = leaderboard_df_filtered['T'].isna().sum()
|
310 |
+
print(f"Number of rows with missing 'T': {missing_T}")
|
311 |
+
|
312 |
+
# 'T' カラムが欠損している場合、埋める(ここでは空文字)
|
313 |
+
if missing_T > 0:
|
314 |
+
print("Filling missing 'T' values with empty strings.")
|
315 |
+
leaderboard_df_filtered['T'] = leaderboard_df_filtered['T'].fillna('')
|
316 |
+
|
317 |
+
# データ型を定義
|
318 |
+
datatype_dict = {}
|
319 |
+
for col in leaderboard_df_filtered.columns:
|
320 |
+
if col == AutoEvalColumn.model.name: # 'Model'
|
321 |
+
datatype_dict[col] = "markdown"
|
322 |
+
elif col in TYPES:
|
323 |
+
datatype_dict[col] = TYPES[col]
|
324 |
+
else:
|
325 |
+
datatype_dict[col] = "str" # デフォルトのデータ型
|
326 |
+
|
327 |
+
# 'T' カラムがすべてのレコードに存在するか確認
|
328 |
+
records = leaderboard_df_filtered.to_dict('records')
|
329 |
+
missing_T_in_records = [i for i, record in enumerate(records) if 'T' not in record]
|
330 |
+
print(f"Number of records missing 'T' key: {len(missing_T_in_records)}")
|
331 |
+
|
332 |
+
if len(missing_T_in_records) > 0:
|
333 |
+
print("Records missing 'T' key:")
|
334 |
+
for i in missing_T_in_records[:5]: # 最初の5件のみ表示
|
335 |
+
print(f"Record {i}: {records[i]}")
|
336 |
+
# 欠損している場合、'T' キーを追加して空文字で埋める
|
337 |
+
for i in missing_T_in_records:
|
338 |
+
records[i]['T'] = ''
|
339 |
+
# データフレームを更新
|
340 |
+
leaderboard_df_filtered = pd.DataFrame(records)
|
341 |
+
|
342 |
+
|
343 |
leaderboard_df_filtered = leaderboard_df_filtered.rename(columns={'T': 'Type_'})
|
344 |
+
|
345 |
+
# 'Type_' カラムのデータ型と内容を確認
|
346 |
+
print(f"'Type_' カラムのデータ型: {leaderboard_df_filtered['Type_'].dtype}")
|
347 |
+
print(f"'Type_' カラムのユニーク値: {leaderboard_df_filtered['Type_'].unique()}")
|
348 |
|
349 |
+
# 'Type_' カラムを文字列型に変換
|
350 |
+
leaderboard_df_filtered['Type_'] = leaderboard_df_filtered['Type_'].astype(str)
|
351 |
|
352 |
+
# 'COLS' リストから 'T' と 'Model' を除外
|
353 |
+
if 'T' in COLS:
|
354 |
+
COLS.remove('T')
|
355 |
+
if 'Model' in COLS:
|
356 |
+
COLS.remove('Model')
|
357 |
+
|
358 |
+
# 'datatype_dict' を再定義
|
359 |
+
datatype_dict = {}
|
360 |
for col in leaderboard_df_filtered.columns:
|
361 |
+
if col == 'Model':
|
362 |
+
datatype_dict[col] = "markdown"
|
363 |
+
elif col in TYPES:
|
364 |
+
datatype_dict[col] = TYPES[col]
|
365 |
+
else:
|
366 |
+
datatype_dict[col] = "str" # デフォルトのデータ型
|
367 |
+
|
368 |
+
# 'Type_' が 'datatype_dict' に含まれているか確認
|
369 |
+
if 'Type_' not in datatype_dict:
|
370 |
+
print("Warning: 'Type_' column not found in TYPES. Setting its datatype to 'str'.")
|
371 |
+
datatype_dict['Type_'] = "str"
|
372 |
|
373 |
# デバッグ用出力
|
374 |
+
print("Datatype dictionary after renaming 'T' to 'Type_':", datatype_dict)
|
375 |
+
print("Preview of leaderboard_df_filtered after renaming:")
|
|
|
376 |
print(leaderboard_df_filtered.head())
|
|
|
|
|
377 |
|
378 |
+
# カラム名を確認してスペースや特殊文字がないか確認
|
379 |
+
print([f"'{c}'" for c in leaderboard_df_filtered.columns])
|
|
|
|
|
380 |
|
381 |
+
# 'Type_' カラムのデータ型とユニーク値を再確認
|
382 |
+
print(f"'Type_' カラムのデータ型: {leaderboard_df_filtered['Type_'].dtype}")
|
383 |
+
print(f"'Type_' カラムのユニーク値: {leaderboard_df_filtered['Type_'].unique()}")
|
384 |
+
|
385 |
+
# Gradio Dataframe コンポーネントの初期化(datatype を省略)
|
386 |
+
leaderboard_table = gr.components.Dataframe(
|
387 |
+
value=leaderboard_df_filtered,
|
388 |
+
# datatype=datatype_dict, # 一時的にコメントアウト
|
389 |
elem_id="leaderboard-table",
|
390 |
interactive=False,
|
391 |
visible=True,
|
392 |
)
|
393 |
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
# Dummy leaderboard for handling the case when the user uses backspace key
|
396 |
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
|
|
473 |
open=False,
|
474 |
):
|
475 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
finished_eval_table = gr.components.Dataframe(
|
477 |
+
value=finished_eval_queue_df,
|
478 |
headers=EVAL_COLS,
|
479 |
datatype=EVAL_TYPES,
|
480 |
row_count=5,
|