DF-Arena-Test / ui /leaderboard.py
Speech-Arena-2025's picture
Upload folder using huggingface_hub
5ecb433 verified
import pandas as pd
import gradio as gr
from utils import load_leaderboard
import numpy as np
from huggingface_hub import snapshot_download
def make_clickable(url, name):
return f'<a href="{url}" target="_blank">{name}</a>'
def render_info_html():
info_text = "With the growing advent of machine-generated speech, the scientific community is responding with exciting resources " \
"to detect deep fakes. With research moving at such a rapid pace, it becomes challenging to keep track of generalizability " \
"of SOTA DF detection systems. This leaderboard thus presents a comprehensive benchmark of 10 SOTA speech antispoofing " \
"systems across 13 popular speech deep fake detection datasets."
# HTML formatted info text
return gr.Markdown(info_text)
def highlight_min(s, props=''):
return np.where(s == np.nanmin(s.values), props, '')
def render_leader_board(leaderboard_df, model_citations):
if not leaderboard_df.empty:
# Convert model names and dataset names to clickable links
# leaderboard_df['System'] = leaderboard_df['System'].apply(lambda x: make_clickable(model_citations.get(x, "#"), x))
# leaderboard_df['Average'] = leaderboard_df.loc[:, ['In-the-wild','ASVSpoof2019','ASVSpoof2021LA','ASVSpoof2021DF','ASVSpoof2024-Dev','ASVSpoof2024-Eval','FakeOrReal','codecfake3','ADD2022','ADD2023','DFADD','LibriVoc','SONAR']].mean(axis=1)
leaderboard_df.insert(1, 'Average', leaderboard_df.loc[:, ['In-the-wild','ASVSpoof2019','ASVSpoof2021LA','ASVSpoof2021DF','ASVSpoof2024-Dev','ASVSpoof2024-Eval','FakeOrReal','codecfake3','ADD2022','ADD2023','DFADD','LibriVoc','SONAR']].mean(axis=1))
leaderboard_df = leaderboard_df.sort_values(by="Average", ascending=True).reset_index(drop=True)
# Assign rank emojis πŸ₯‡πŸ₯ˆπŸ₯‰
leaderboard_df["System"] = leaderboard_df["System"].apply(lambda x: f"[{x}]({model_citations.get(x, '#')})")
emojis = ["πŸ₯‡", "πŸ₯ˆ", "πŸ₯‰"]
leaderboard_df.System[0] = f"{emojis[0]} {leaderboard_df.System[0]}"
leaderboard_df.System[1] = f"{emojis[1]} {leaderboard_df.System[1]}"
leaderboard_df.System[2] = f"{emojis[2]} {leaderboard_df.System[2]}"
temp = leaderboard_df.loc[:, ['System', 'Training Data', 'Num Parameters', 'Data Augmentation']]
# styler = leaderboard_df.drop(columns=['Training Data', 'Num Parameters', 'Data Augmentation'], axis=1).style.highlight_min(color = 'lightgreen', axis = 0).format(precision=2)
styler = (
leaderboard_df
.drop(columns=['Training Data', 'Num Parameters', 'Data Augmentation'], axis=1).style \
.format(precision=2))
styler.apply(highlight_min, props='color:green', axis=0)
# styler['System'] = temp['System']
# styler['Training Data'] = temp['Training Data']
# styler['Num Parameters'] = temp['Num Parameters']
# styler['Data Augmentation'] = temp['Data Augmentation']
return gr.Dataframe(styler, datatype=['markdown'] * 1 + ['number'] * 14)
return gr.HTML(value="<p>No data available in the leaderboard.</p>")