File size: 18,821 Bytes
5a3d99d 644a993 641159b b07e01e 641159b f7cb4f5 4974a11 40fa7db 411153e 641159b 411153e 9716860 411153e 40fa7db 641159b 411153e ed7d966 411153e 1f2bf05 411153e 1f2bf05 ed7d966 c4fcf32 3f367ae c4fcf32 411153e c4fcf32 f433418 1f2bf05 69d86e9 411153e 9d82914 69d86e9 9d82914 9a0955a 9d82914 411153e 9d82914 f573d75 9d82914 411153e 0ce2cc7 9d82914 411153e 9d82914 0ce2cc7 411153e c4fcf32 ed7d966 411153e ed7d966 411153e ed7d966 8203961 ed7d966 1f2bf05 ed7d966 f4a45de ac4d2ae f4a45de 411153e 741d530 641159b 4974a11 ed7d966 641159b eca2497 641159b 1f2bf05 641159b ed7d966 6855ecc ed7d966 1f2bf05 641159b 411153e 1f2bf05 641159b ed7d966 411153e ed7d966 4974a11 bad05e2 411153e 1f2bf05 5338988 1ef22f4 5338988 641159b 411153e 9241fd9 eca2497 9241fd9 840231a 9241fd9 502a22b 9241fd9 bff85a2 eca2497 9241fd9 840231a 9241fd9 3afc45c 5a67c3c 411153e 929d67e a873be1 929d67e 54120fa 5a67c3c 929d67e 9241fd9 965c1dd b29a68d 5ce9216 3a90fbb 29e0ceb 3afc45c a873be1 fb73b9e 3afc45c 3a90fbb 411153e 9241fd9 fd8e409 9241fd9 411153e b29a68d be28a85 b29a68d 840231a b29a68d 3afc45c b29a68d 5a67c3c b29a68d cbf4788 a873be1 cbf4788 54120fa 5a67c3c cbf4788 b29a68d fb73b9e 3afc45c 3c59ccb fb73b9e 3afc45c b29a68d 3afc45c 4623c5b 825cd1e 4623c5b 5237e9c 4623c5b b29a68d c0ee7e9 b29a68d 411153e 644a993 840231a 644a993 074a26b 644a993 5a67c3c 644a993 a873be1 644a993 54120fa 5a67c3c 644a993 fb73b9e 644a993 a873be1 29e0ceb 644a993 d402b0b 644a993 5237e9c 644a993 411153e 4974a11 21e4633 8c7843b 21e4633 c55bb79 411153e c55bb79 ed7d966 c55bb79 ed7d966 c55bb79 ed7d966 c55bb79 8573cfd 6247ea8 c55bb79 bad05e2 c55bb79 bad05e2 ed7d966 c55bb79 ed7d966 c55bb79 9db562c c55bb79 ed7d966 c55bb79 |
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
from src.score_calculation.score import score_predictions
import ast
from datasets import load_dataset
from huggingface_hub import login
import multiprocessing
import numpy as np
import streamlit as st
from streamlit_chunk_file_uploader import uploader
import pandas as pd
from pathlib import Path
import plotly.graph_objects as go
import plotly.express as px
from io import StringIO
import json
import os
RESULTS_DIR = "results/"
# Page config
st.set_page_config(
page_title="NaviTrace Leaderboard",
layout="centered",
initial_sidebar_state="collapsed"
)
# Custom CSS for Nerfies-style design
st.markdown("""
<style>
/* Import Font Awesome */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
.header-container {
display: flex;
flex-direction: column;
align-items: center;
}
/* Headings */
h1 {
text-align: center;
font-size: 4.5rem !important;
font-weight: 500;
margin-top: 1rem;
margin-bottom: 1rem;
}
/* Links container */
.links-container {
display: flex;
flex-wrap: wrap;
row-gap: 1rem;
justify-content: center;
text-align: center;
margin-bottom: 3rem;
font-size: 1.1rem;
}
.links-container a {
white-space: nowrap;
margin: 0 1rem;
text-decoration: none;
color: #3b82f6;
font-weight: 600;
transition: color 0.3s;
}
.links-container a:hover {
color: #1e3a8a;
}
/* Instructions styling */
.instruction-item {
display: flex;
gap: 1.5rem;
margin: 2rem 0;
align-items: flex-start;
}
.instruction-number {
flex-shrink: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background: linear-gradient(135deg, #3b82f6 0%, #1e3a8a 100%);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 1.2rem;
}
.instruction-content {
flex-grow: 1;
padding-top: 0.3rem;
}
/* Media Query for mobile devices */
@media (max-width: 600px) {
h1 {
font-size: 3.5rem !important; /* Adjust font size for small screens */
}
}
</style>
""", unsafe_allow_html=True)
def load_data():
"""Load all result files as one data frame"""
try:
# Load all results files
all_dfs = []
for file_path in Path(RESULTS_DIR).glob('*.tsv'):
df = pd.read_csv(file_path, sep='\t')
model_name = file_path.stem.replace('_', ' ')
df["model"] = model_name
all_dfs.append(df)
# Concatenate all DataFrames into one
if all_dfs:
final_df = pd.concat(all_dfs, ignore_index=True)
return final_df
except Exception as e:
st.error(f"Error loading data: {str(e)}")
return None
def calculate_score(results_df):
"""Calculate score using private test split ground truth."""
try:
# Access to private dataset with test labels
login(token=os.environ.get("HF_TOKEN"))
dataset = load_dataset(os.environ.get("HF_DATASET_ID"), split="test")
# Calculate score
return score_predictions(results_df, dataset)
except Exception as e:
st.error(f"Error calculating score")
return None
def validate_tsv_format(uploaded_file):
"""Validate that the uploaded TSV has the correct format"""
try:
df = pd.read_csv(uploaded_file, sep='\t')
# Check for required columns, data types, etc.
required_cols = ["sample_id", "embodiment", "category", "prediction"]
if not all(col in df.columns for col in required_cols):
return False, f"Missing required columns. Expected: {required_cols}"
return True, df
except Exception as e:
return False, f"Error reading file: {str(e)}"
@st.cache_data
def convert_df_to_tsv(df):
return df.to_csv(sep='\t', index=False).encode('utf-8')
def create_bar_chart(df, view_type):
"""Create interactive bar chart based on view type"""
# Copy df
df_fig = df.copy()
df_fig = df_fig[df_fig["score"] != np.inf]
# Split too long names
model_renaming_map = {
"Qwen 3 VL 235b Thinking": "Qwen 3 VL 235b<br>Thinking",
}
df_fig["model"] = df_fig["model"].map(model_renaming_map).fillna(df_fig["model"])
if view_type == "Total Score":
# Calculate mean score per model
df_fig = df_fig.groupby("model")[["score"]].mean().reset_index()
# Sort the results from best to worst
df_fig = df_fig.sort_values(by="score", ascending=False)
# Create the Plotly figure
fig = px.bar(
df_fig,
x="model",
y="score",
color="score",
color_continuous_scale=px.colors.diverging.RdYlBu,
orientation="v",
)
max_score = df_fig["score"].max()
min_score = df_fig["score"].min()
fig.update_layout(
xaxis=dict(
title=dict(
text="Model",
standoff=25,
),
tickangle=-45,
),
yaxis=dict(
title_text="Score",
range=[min_score * 1.25, max_score * 1.25]
),
title_text="",
font=dict(size=15),
bargap=0.2,
height=600,
showlegend=False,
margin=dict(
l=60, # Left
r=0, # Right
b=95, # Bottom
t=80, # Top
pad=0 # Padding
),
)
# Remove the color legend from the chart.
fig.update_coloraxes(showscale=False)
# Add annotations to show the exact score on each bar.
fig.update_traces(
texttemplate="%{y:.0f}",
textposition="outside"
)
elif view_type == "Per Embodiment":
# Calculate the model order
df_model_order = df_fig.groupby("model")[["score"]].mean().reset_index()
model_order = df_model_order.sort_values(by="score", ascending=True)["model"].tolist()
# Calculate mean score per model and embodiment
df_fig = df_fig.groupby(["model", "embodiment"])[["score"]].mean().reset_index()
# Convert the "model" column to a categorical type with the sorted order
df_fig["model"] = pd.Categorical(df_fig["model"], categories=model_order, ordered=True)
# Sort the DataFrame based on the new categorical order
df_fig = df_fig.sort_values(by=["model", "score"], ascending=[False, False])
# Create the Plotly figure
fig = px.bar(
df_fig,
x="model",
y="score",
color="embodiment",
color_discrete_sequence=px.colors.qualitative.Plotly,
orientation="v",
)
max_score = df_fig["score"].max()
min_score = df_fig["score"].min()
fig.update_layout(
xaxis=dict(
title=dict(
text="Model",
standoff=25,
),
tickangle=-45,
),
yaxis=dict(
title_text="Score",
range=[min_score * 1.25, max_score * 1.25]
),
title_text="",
font=dict(size=15),
bargap=0.1,
barmode="group",
height=600,
margin=dict(
l=60, # Left
r=0, # Right
b=95, # Bottom
t=80, # Top
pad=0 # Padding
),
showlegend=True,
legend=dict(
orientation="h",
x=0.5,
y=1.1,
xanchor="center",
yanchor="top",
borderwidth=0,
itemclick="toggle",
itemdoubleclick="toggleothers",
title=dict(
text="<b>Embodiments</b>",
side="top center"
)
),
uniformtext_minsize=10,
uniformtext_mode="show",
)
# Remove the color legend from the chart.
fig.update_coloraxes(showscale=False)
else: # Per Category
# Calculate the model order
df_model_order = df_fig.groupby("model")[["score"]].mean().reset_index()
model_order = df_model_order.sort_values(by="score", ascending=True)["model"].tolist()
# Calculate mean score per model and embodiment
df_fig["category"] = df_fig["category"].apply(ast.literal_eval)
df_fig = df_fig.explode("category")
df_fig = df_fig.groupby(["model", "category"])[["score"]].mean().reset_index()
# Convert the "model" column to a categorical type with the sorted order
df_fig["model"] = pd.Categorical(df_fig["model"], categories=model_order, ordered=True)
# Sort the DataFrame based on the new categorical order
df_fig = df_fig.sort_values(by=["model", "score"], ascending=[False, False])
# Create the Plotly figure
fig = px.bar(
df_fig,
x="model",
y="score",
color="category",
color_discrete_sequence=px.colors.qualitative.Plotly[::-1],
orientation="v",
)
max_score = df_fig["score"].max()
min_score = df_fig["score"].min()
fig.update_layout(
xaxis=dict(
title=dict(
text="Model",
standoff=25,
),
tickangle=-45,
),
yaxis=dict(
title_text="Score",
range=[min_score * 1.25, max_score * 1.25]
),
title_text="",
font=dict(size=15),
bargap=0.1,
barmode="group",
height=600,
margin=dict(
l=60, # Left
r=0, # Right
b=95, # Bottom
t=80, # Top
pad=0 # Padding
),
showlegend=True,
legend=dict(
orientation="h",
x=0.5,
y=1.1,
xanchor="center",
yanchor="top",
borderwidth=0,
itemclick="toggle",
itemdoubleclick="toggleothers",
title=dict(
text="<b>Categories</b>",
side="top center"
)
),
uniformtext_minsize=10,
uniformtext_mode="show",
)
# Remove the color legend from the chart.
fig.update_coloraxes(showscale=False)
return fig
def create_summary_table(df):
# Copy df
df_table = df.copy()
df_table = df_table[df_table["score"] != np.inf]
# Calculate total score per model
df_total = df_table.groupby("model")[["score"]].mean().reset_index()
df_total.columns = ["model", "Total Score"]
# Calculate scores per embodiment
df_embodiment = df_table.groupby(["model", "embodiment"])[["score"]].mean().reset_index()
df_embodiment_pivot = df_embodiment.pivot(index="model", columns="embodiment", values="score")
df_embodiment_pivot.columns = [f"{col}" for col in df_embodiment_pivot.columns]
# Calculate scores per category
df_category = df_table.copy()
df_category["category"] = df_category["category"].apply(ast.literal_eval)
df_category = df_category.explode("category")
df_category = df_category.groupby(["model", "category"])[["score"]].mean().reset_index()
df_category_pivot = df_category.pivot(index="model", columns="category", values="score")
df_category_pivot.columns = [f"{col}" for col in df_category_pivot.columns]
# Combine all tables
df_summary = df_total.set_index("model")
df_summary = df_summary.join(df_embodiment_pivot)
df_summary = df_summary.join(df_category_pivot)
# Sort by total score
df_summary = df_summary.sort_values(by="Total Score", ascending=False)
# Reset index to make model a column again
df_summary = df_summary.reset_index()
return df_summary
def main():
# Header
st.markdown("""
<div class="header-container">
<h1>NaviTrace Leaderboard</h1>
<div class="links-container">
<a href="https://leggedrobotics.github.io/navitrace_webpage/">
๐ Project
</a>
<a href="https://arxiv.org/abs/2510.26909">
๐ Paper
</a>
<a href="https://github.com/leggedrobotics/navitrace_evaluation">
๐ป Code
</a>
<a href="https://huggingface.co/datasets/leggedrobotics/navitrace">
๐พ Dataset
</a>
</div>
</div>
""", unsafe_allow_html=True)
# Load data
df = load_data()
# Add user's model if it exists in session state
if 'user_results' in st.session_state:
user_results = pd.DataFrame(st.session_state.user_results)
df = pd.concat([user_results, df], ignore_index=True)
# View selector
view_type = st.selectbox(
"Select View",
["Total Score", "Per Embodiment", "Per Category"],
)
# Display chart
fig = create_bar_chart(df, view_type)
st.plotly_chart(fig, use_container_width=True, config={
'displayModeBar': True,
'displaylogo': False,
'toImageButtonOptions': {
'format': 'png',
'filename': 'navitrace_leaderboard',
'height': 600,
'width': 1200,
'scale': 2
}
})
# Detailed table
with st.expander("View Detailed Scores"):
# Create the summary table
df_summary = create_summary_table(df)
# Display table
st.dataframe(
df_summary.style.background_gradient(
cmap="Blues",
subset=[col for col in df_summary.columns if col != "model"]
).format("{:.2f}", subset=[col for col in df_summary.columns if col != "model"]),
width="stretch",
hide_index=True,
)
with st.expander("How to Test Your Model", expanded=True):
# Step 1
st.markdown("""
<div class="instruction-item">
<div class="instruction-number">1</div>
<div class="instruction-content">
<div><b>Run Evaluation</b></div>
<div>
Download and run our evaluation notebook adjusted to your model. The notebook will generate a TSV file with your model's predictions on the test set.
</div>
</div>
</div>
""", unsafe_allow_html=True)
st.link_button("๐ Open Evaluation Notebook", "https://github.com/leggedrobotics/navitrace_evaluation", width="stretch")
# Step 2
st.markdown("""
<div class="instruction-item">
<div class="instruction-number">2</div>
<div class="instruction-content">
<div><b>Upload Results</b></div>
<div>
Upload the TSV file generated by the evaluation notebook.
</div>
</div>
</div>
""", unsafe_allow_html=True)
# Chunk uploaded file to circumvent HF limit
#uploaded_file = st.file_uploader("Upload your TSV file with results", type=['tsv', 'txt'], label_visibility="collapsed")
uploaded_file = uploader("", key="chunk_uploader", chunk_size=0.5)
# Step 3
st.markdown("""
<div class="instruction-item">
<div class="instruction-number">3</div>
<div class="instruction-content">
<div><b>Calculate Score</b></div>
<div>
Click the button below to evaluate your predictions. Scores are calculated using hidden test set ground-truths.
</div>
</div>
</div>
""", unsafe_allow_html=True)
if uploaded_file is not None:
if st.button("๐งฎ Calculate Score", width="stretch"):
# Validate format
with st.spinner("Validating format and calculating score..."):
is_valid, result = validate_tsv_format(uploaded_file)
if is_valid:
# Calculate score using hidden ground-truth
scores = calculate_score(result)
if scores is not None:
# Store in session state
scores["model"] = "Your Model"
st.session_state.user_results = scores.to_dict(orient='list')
st.rerun()
else:
st.error(f"โ Invalid file format: {result}")
else:
st.info("๐ Upload a TSV file to calculate your score")
# Allow download of results
if 'user_results' in st.session_state:
user_results = pd.DataFrame(st.session_state.user_results)
st.success(f"โ
Score calculated successfully: **{user_results['score'].mean():.1f}**")
st.info("๐ Scroll up to see your model on the leaderboard!")
tsv_data = convert_df_to_tsv(user_results)
st.download_button(
label="๐
Download Score",
data=tsv_data,
file_name='scores.tsv',
mime='text/tab-separated-values',
width="stretch",
)
# Step 4
st.markdown("""
<div class="instruction-item">
<div class="instruction-number">4</div>
<div class="instruction-content">
<div><b>Submit to Official Leaderboard</b></div>
<div>
Happy with your score? Submit your model to appear on the official leaderboard.
Fill out the form below with your model details and results.
</div>
</div>
</div>
""", unsafe_allow_html=True)
st.link_button("๐ณ๏ธ Submit Model", "https://docs.google.com/forms/d/e/1FAIpQLSfcAQ6JW7eey-8OFSAz2ea_StCezxJK1dt6mjW_wR-9jCHnXg/viewform?usp=dialog", width="stretch")
if __name__ == "__main__":
main() |