File size: 5,353 Bytes
82327d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | import gradio as gr
import pandas as pd
import re
from pathlib import Path
# Column order matching the original
COL_ORDER = [
"Model Name",
"WorldScore-Static",
"WorldScore-Dynamic",
"Camera Control",
"Object Control",
"Content Alignment",
"3D Consistency",
"Photometric Consistency",
"Style Consistency",
"Subjective Quality",
"Motion Accuracy",
"Motion Magnitude",
"Motion Smoothness",
"Model Type",
"Ability",
"Sampled by",
"Evaluated by",
"Accessibility",
"Date",
]
# Numeric columns for highlighting
NUMERIC_COLS = {
"WorldScore-Static",
"WorldScore-Dynamic",
"Camera Control",
"Object Control",
"Content Alignment",
"3D Consistency",
"Photometric Consistency",
"Style Consistency",
"Subjective Quality",
"Motion Accuracy",
"Motion Magnitude",
"Motion Smoothness",
}
def parse_markdown_link(text):
"""Parse markdown link format [text](url) and return HTML link"""
match = re.match(r'^\[(.*?)\]\((.*?)\)$', str(text))
if match:
text_content = match.group(1)
url = match.group(2)
# Return HTML link for Gradio to render
return f'<a href="{url}" target="_blank" style="color: #1d4ed8; text-decoration: none; font-weight: 600;">{text_content}</a>'
return str(text)
def load_and_process_data():
"""Load CSV and process data"""
csv_path = Path("leaderboard.csv")
if not csv_path.exists():
return pd.DataFrame()
df = pd.read_csv(csv_path)
# Reorder columns according to COL_ORDER (only include columns that exist)
existing_cols = [col for col in COL_ORDER if col in df.columns]
df = df[existing_cols]
# Parse markdown links in Model Name column and convert to HTML
if "Model Name" in df.columns:
df["Model Name"] = df["Model Name"].apply(parse_markdown_link)
# Convert numeric columns to float for proper sorting
for col in NUMERIC_COLS:
if col in df.columns:
df[col] = pd.to_numeric(df[col], errors='coerce')
# Sort by WorldScore-Static descending by default
if "WorldScore-Static" in df.columns:
df = df.sort_values("WorldScore-Static", ascending=False, na_position='last')
# Format numeric columns to 2 decimal places
for col in NUMERIC_COLS:
if col in df.columns:
df[col] = df[col].apply(lambda x: f"{x:.2f}" if pd.notna(x) else "")
return df
def create_leaderboard():
"""Create the Gradio interface"""
df = load_and_process_data()
# Custom CSS to match the original styling
css = """
.gradio-container {
background-color: #0b1120;
color: #e5e7eb;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.intro-section {
padding: 24px 32px;
color: #e5e7eb;
}
.intro-section h1 {
font-size: 2rem;
font-weight: 800;
margin-bottom: 8px;
color: #ffffff;
}
.intro-links {
margin-bottom: 12px;
font-size: 1rem;
}
.intro-links a {
color: #60a5fa;
text-decoration: none;
font-weight: 600;
margin-right: 8px;
}
.intro-links a:hover {
text-decoration: underline;
}
.intro-text {
color: #d1d5db;
font-size: 1rem;
margin-top: 6px;
line-height: 1.5rem;
}
.divider {
margin: 20px 0;
border: none;
height: 1px;
background-color: #374151;
}
"""
# Create intro HTML
intro_html = """
<div class="intro-section">
<h1>WorldScore Leaderboard</h1>
<div class="intro-links">
<a href="https://arxiv.org/abs/2504.00983" target="_blank">Paper</a> |
<a href="https://haoyi-duan.github.io/WorldScore/" target="_blank">Website</a> |
<a href="https://github.com/haoyi-duan/WorldScore" target="_blank">Code</a> |
<a href="https://huggingface.co/datasets/Howieeeee/WorldScore" target="_blank">Dataset</a> |
<a href="https://github.com/haoyi-duan/WorldScore?tab=readme-ov-file#leaderboard" target="_blank">Join Leaderboard</a>
</div>
<p class="intro-text">
🏆 Welcome to the leaderboard of <b>WorldScore</b>, the first unified evaluation benchmark for world generation.
</p>
<hr class="divider">
</div>
"""
with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="blue")) as demo:
gr.HTML(intro_html)
# Create dataframe component with sorting enabled
if len(df.columns) > 0:
# Set datatype for Model Name column to markdown to render HTML links
datatypes = ["markdown" if col == "Model Name" else "str" for col in df.columns]
dataframe = gr.Dataframe(
value=df,
label="",
interactive=False,
wrap=True,
column_widths=["auto"] * len(df.columns),
height=600,
datatype=datatypes,
)
else:
gr.Markdown("No data available. Please ensure leaderboard.csv exists.")
return demo
if __name__ == "__main__":
demo = create_leaderboard()
demo.launch()
|