sh1gechan commited on
Commit
aa3bf1f
·
verified ·
1 Parent(s): 4cf9d15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -41
app.py CHANGED
@@ -300,51 +300,29 @@ with demo:
300
  # visible=True,
301
  # )
302
 
 
303
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
304
- leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns).copy()
305
 
306
- # 'T' カラムが存在しない場合、追加する
307
- if 'T' not in leaderboard_df_filtered.columns:
308
- leaderboard_df_filtered['T'] = '?' # デフォルト値を設定
309
-
310
- # データ型を定義
311
- datatype = {col: "str" for col in leaderboard_df_filtered.columns}
312
- datatype['Model'] = "markdown"
313
- datatype['T'] = "str"
314
-
315
- # 'T' カラムを文字列型に変換
316
- leaderboard_df_filtered.loc[:, 'T'] = leaderboard_df_filtered['T'].astype(str)
317
-
318
- # デバッグ用の出力
319
- print("Columns in leaderboard_df_filtered:", leaderboard_df_filtered.columns)
320
- print("First few rows of leaderboard_df_filtered:")
321
- print(leaderboard_df_filtered.head())
322
-
323
- # データフレームを辞書に変換
324
- df_dict = leaderboard_df_filtered.to_dict('records')
325
 
326
- # デバッグ用の出力
327
- print("First row of df_dict:")
328
- print(df_dict[0])
329
- print("Keys in the first row:")
330
- print(list(df_dict[0].keys()))
331
 
332
- # Gradio Dataframe コンポーネントの初期化
333
- try:
334
- leaderboard_table = gr.components.Dataframe(
335
- value=df_dict,
336
- headers=list(leaderboard_df_filtered.columns),
337
- datatype=datatype,
338
- elem_id="leaderboard-table",
339
- interactive=False,
340
- visible=True,
341
- )
342
- print("Dataframe component initialized successfully")
343
- except Exception as e:
344
- print(f"Error initializing Dataframe component: {str(e)}")
345
- print("datatype dictionary:")
346
- print(datatype)
347
- raise
348
 
349
  # Dummy leaderboard for handling the case when the user uses backspace key
350
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
 
300
  # visible=True,
301
  # )
302
 
303
+ # DataFrameの初期化部分のみを修正
304
  initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
305
+ leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns)
306
 
307
+ # Model列のリンク形式を修正
308
+ leaderboard_df_filtered['Model'] = leaderboard_df_filtered['Model'].apply(
309
+ lambda x: f'[{x.split(">")[-2].split("<")[0]}]({x.split("href=")[1].split(chr(34))[1]})' if isinstance(x, str) and 'href=' in x else x
310
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
 
312
+ # 数値データを文字列に変換
313
+ for col in leaderboard_df_filtered.columns:
314
+ if col not in ['T', 'Model']:
315
+ leaderboard_df_filtered[col] = leaderboard_df_filtered[col].astype(str)
 
316
 
317
+ # DataFrameコンポーネントの初期化
318
+ leaderboard_table = gr.components.Dataframe(
319
+ value=leaderboard_df_filtered.to_dict('records'),
320
+ headers=list(leaderboard_df_filtered.columns),
321
+ datatype={col: "markdown" if col == "Model" else "str" for col in leaderboard_df_filtered.columns},
322
+ elem_id="leaderboard-table",
323
+ interactive=False,
324
+ visible=True
325
+ )
 
 
 
 
 
 
 
326
 
327
  # Dummy leaderboard for handling the case when the user uses backspace key
328
  hidden_leaderboard_table_for_search = gr.components.Dataframe(