Speech-DF-Arena / ui /leaderboard.py
Speech-Arena-2025's picture
Phase II Version 1
dba927a
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."
info_text = """The advent of machine generated speech calls for dedicated research to develop countermeasure systems to protect against their misuse through deepfakes.
The Speech DF arena leaderboard provides a standardized benchmarking platform for both commercial and open source systems to compare different detection approaches and ranks them using standard metrics.
This leaderboard is an evolving inititatie where new systems and attacks can can be added upon request to keep it up to date with the latest advancements in the field. Check out the Submit Your System section to learn how to submit your system.
Below we report the Equal Error Rate (EER %), Accuracy (%) and F1 scores. The table consists of both pooled and average results. Pooled results are computed
by using thresholds obtained across all datasets, while average results are computed by simply averaging the dataset level results. We rank the systems according to the Pooled results
"""
# HTML formatted info text
return gr.Markdown(info_text)
def highlight_min(s, props=''):
return np.where(s == np.nanmin(s.values), props, '')
def highlight_max(s, props=''):
return np.where(s == np.nanmax(s.values), props, '')
def render_leader_board(leaderboard_df, model_citations, model_licenses, model_params, _ascending):
if not leaderboard_df.empty:
leaderboard_df.insert(1, "License", leaderboard_df["System"].apply(lambda x: model_licenses.get(x)))
leaderboard_df.insert(2, "Num Params (M)", leaderboard_df["System"].apply(lambda x: model_params.get(x)))
print(leaderboard_df.head())
leaderboard_df = leaderboard_df.sort_values(by='Pooled', ascending=_ascending).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.loc[0, "System"] = f"{emojis[0]} {leaderboard_df.System[0]}"
leaderboard_df.loc[1, "System"] = f"{emojis[1]} {leaderboard_df.System[1]}"
leaderboard_df.loc[2, "System"] = f"{emojis[2]} {leaderboard_df.System[2]}"
styler = (
leaderboard_df
.style \
.format(precision=2)
.apply(highlight_min if _ascending else highlight_max, props='color:green', axis=0)
)
return gr.Dataframe(styler, datatype=['markdown'] * 3 + ['number'] * 15, elem_id="leaderboard-table", pinned_columns=1, column_widths=["200px", "150px", "150px"] + ["100px"] * 15)
return gr.HTML(value="<p>No data available in the leaderboard.</p>")
def render_citation():
return gr.Markdown(r"""
If you use Speech DF Arena in your work, it can be cited as:
```bibtex
@misc{speecharena-df-leaderboard,
title = {Speech Arena: Speech DeepFake Leaderboard},
author = {Speech Arena},
year = 2025,
publisher = {Hugging Face},
howpublished = "\url{link}"
}
```""")