Spaces:
Running
Running
| import gradio as gr | |
| import pandas as pd | |
| from apscheduler.schedulers.background import BackgroundScheduler | |
| # Deepfake detector data | |
| data_avg_performance = { | |
| "Detector": ["NPR", "UCF", "CAMO"], | |
| "Accuracy": [0.7169, 0.7229, 0.7555], | |
| "Precision": [0.9193, 0.9436, 0.9442], | |
| "Recall": [0.5996, 0.592, 0.647], | |
| "F1-Score": [0.7258, 0.7275, 0.7679], | |
| "MCC": [0.5044, 0.5285, 0.5707], | |
| } | |
| data_dataset_accuracy = { | |
| "Detector": ["NPR", "UCF", "CAMO"], | |
| "CelebA-HQ": [0.987, 0.995, 0.999], | |
| "Flickr30k": [0.916, 0.981, 0.979], | |
| "ImageNet": [0.834, 0.847, 0.831], | |
| "DiffusionDB": [0.876, 0.85, 0.961], | |
| "CelebA-HQ-SDXL": [0.386, 0.484, 0.682], | |
| "CelebA-HQ-Flux": [0.846, 0.794, 0.722], | |
| "Flickr30k-SDXL": [0.302, 0.256, 0.28], | |
| "MS-COCO-Flux": [0.588, 0.576, 0.59], | |
| } | |
| # Convert data to DataFrames | |
| df_avg_performance = pd.DataFrame(data_avg_performance) | |
| df_dataset_accuracy = pd.DataFrame(data_dataset_accuracy) | |
| # Function to highlight the maximum values in bold and color them | |
| def highlight_max(s): | |
| is_max = s == s.max() | |
| return ['font-weight: bold; color: red;' if v else '' for v in is_max] | |
| # Style the dataframe | |
| def style_dataframe(df): | |
| return df.style.apply(highlight_max, subset=["Accuracy", "Precision", "Recall", "F1-Score", "MCC"]) | |
| def style_dataset_accuracy(df): | |
| return df.style.apply(highlight_max, subset=df.columns[1:]) | |
| # Gradio demo with the styled dataframes | |
| demo = gr.Blocks() | |
| with demo: | |
| gr.HTML("<h1>Deepfake Detector Arena</h1>") | |
| gr.Markdown("### Welcome to the Deepfake Detector Leaderboard") | |
| with gr.Tabs(): | |
| with gr.TabItem("π Deepfake Detector Arena", elem_id="dfd-leaderboard-tab"): | |
| # Add text for Average Performance Metrics | |
| gr.Markdown("## Average Performance Metrics") | |
| # Display the average performance metrics with highlighted max values | |
| styled_avg_performance = style_dataframe(df_avg_performance) | |
| gr.DataFrame(styled_avg_performance.render(), label="Average Performance Metrics", interactive=False) | |
| # Add a separate dataframe for dataset-specific accuracy with highlighted max values | |
| gr.Markdown("## Dataset-specific Accuracy") | |
| styled_dataset_accuracy = style_dataset_accuracy(df_dataset_accuracy) | |
| gr.DataFrame(styled_dataset_accuracy.render(), label="Dataset-specific Accuracy", interactive=False) | |
| with gr.TabItem("π About"): | |
| gr.Markdown("This leaderboard evaluates deepfake detection algorithms on various metrics and datasets.") | |
| with gr.TabItem("π Submit Detector Results"): | |
| gr.Markdown("Submit your detector results for evaluation.") | |
| # Add submission form elements as needed here | |
| demo.queue(default_concurrency_limit=40).launch() | |