Spaces:
Running
Running
File size: 15,563 Bytes
560a8bd 4c99d55 560a8bd 4c99d55 560a8bd 4c99d55 560a8bd 4c99d55 560a8bd 6c1b51e 560a8bd 6c1b51e 560a8bd 4c99d55 27c52f6 560a8bd 6c1b51e f5ff4ae 27c52f6 f5ff4ae 37754c7 fd803db f5ff4ae fd803db f5ff4ae fd803db f5ff4ae 27c52f6 f5ff4ae 560a8bd dd6bfef f5ff4ae dd6bfef f5ff4ae 44deb2c f5ff4ae 44deb2c fd803db 44deb2c 560a8bd 6c1b51e beff22b dd6bfef 27c52f6 560a8bd 27c52f6 560a8bd dd6bfef c144126 27c52f6 fd803db 27c52f6 dd6bfef 560a8bd 27c52f6 fd803db 27c52f6 fd803db 27c52f6 fd803db 27c52f6 d9fe250 5e434f3 27c52f6 5e434f3 fd803db 27c52f6 fd803db 37754c7 f5ff4ae 37754c7 560a8bd 6b7eab4 c0a9c4e 560a8bd 6b7eab4 560a8bd dd6bfef 560a8bd 8d274b6 560a8bd 8d274b6 560a8bd 4c99d55 560a8bd bacd5ae 8d274b6 bacd5ae 27c52f6 bacd5ae 27c52f6 bacd5ae f5ff4ae d9fe250 f5ff4ae d9fe250 bacd5ae f5ff4ae bacd5ae f5ff4ae d9fe250 bacd5ae 8d274b6 bacd5ae f5ff4ae d9fe250 bacd5ae 560a8bd |
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 |
import gradio as gr
import pandas as pd
import os
# Load data from CSV files
DATA_DIR = "data"
def load_csv_data(filename):
"""Load data from CSV file"""
filepath = os.path.join(DATA_DIR, filename)
if os.path.exists(filepath):
return pd.read_csv(filepath)
else:
return pd.DataFrame()
# Load datasets
CLASSIFICATION_DF = load_csv_data("classification.csv")
DETECTION_DF = load_csv_data("detection.csv")
SEGMENTATION_DF = load_csv_data("segmentation.csv")
def filter_and_search(df, search, datasets, models, organizations, columns):
filtered = df.copy()
if search:
mask = filtered.apply(lambda row: row.astype(str).str.contains(search, case=False).any(), axis=1)
filtered = filtered[mask]
if datasets:
filtered = filtered[filtered["Dataset"].isin(datasets)]
if models:
filtered = filtered[filtered["Model"].isin(models)]
if organizations:
filtered = filtered[filtered["Organization"].isin(organizations)]
if columns:
display_cols = [col for col in columns if col in filtered.columns]
filtered = filtered[display_cols]
return filtered
def build_tab(df, name):
"""Build a leaderboard tab from a DataFrame"""
if df.empty:
return gr.TabItem(name)
# Pivot the dataframe to have columns like "Dataset1 (Metric1)", "Dataset1 (Metric2)", etc.
datasets = sorted(df["Dataset"].unique().tolist())
models = sorted(df["Model"].unique().tolist())
organizations = sorted(df["Organization"].unique().tolist())
metric_cols = [col for col in df.columns if col not in ["Model", "Organization", "Dataset", "Author", "Author Link"]]
# Create pivoted dataframe
pivoted_data = []
for model in models:
for org in organizations:
model_org_data = df[(df["Model"] == model) & (df["Organization"] == org)]
if not model_org_data.empty:
# Get Author and Author Link from the first entry (they should be the same for model+org)
author = model_org_data["Author"].values[0]
author_link = model_org_data["Author Link"].values[0]
# Format as markdown link if author_link exists
if pd.notna(author_link) and author_link.strip():
author_display = f"[{author}]({author_link})"
else:
author_display = author
row = {"Model": model, "Organization": org, "Author": author_display}
for dataset in datasets:
dataset_data = model_org_data[model_org_data["Dataset"] == dataset]
if not dataset_data.empty:
for metric in metric_cols:
col_name = f"{dataset} ({metric})"
row[col_name] = dataset_data[metric].values[0]
else:
for metric in metric_cols:
col_name = f"{dataset} ({metric})"
row[col_name] = "-"
pivoted_data.append(row)
pivoted_df = pd.DataFrame(pivoted_data)
# Build column list for selector
metric_combo_cols = []
for dataset in datasets:
for metric in metric_cols:
metric_combo_cols.append(f"{dataset} ({metric})")
all_cols = ["Model", "Organization", "Author"] + metric_combo_cols
with gr.TabItem(name, elem_id="llm-benchmark-tab-table"):
with gr.Row():
with gr.Column(scale=4):
search_bar = gr.Textbox(
label="Search",
placeholder="Separate multiple queries with ';'",
elem_id="search-bar"
)
# Column selector for base columns only (not dataset+metric combos)
base_cols = ["Model", "Organization", "Author"]
col_selector = gr.CheckboxGroup(
choices=base_cols,
value=base_cols,
label="Select Columns to Display:",
elem_classes="column-select"
)
# Set datatype to 'markdown' for Author column to enable clickable links
datatypes = []
for col in pivoted_df.columns:
if col == "Author":
datatypes.append("markdown")
else:
datatypes.append("str")
table = gr.Dataframe(
value=pivoted_df,
elem_id="leaderboard-table",
interactive=False,
wrap=True,
datatype=datatypes
)
with gr.Column(scale=1):
gr.Markdown("**Model types**")
model_filter = gr.CheckboxGroup(
choices=models,
value=models,
label="",
elem_classes="filter-group"
)
gr.Markdown("**Organizations**")
org_filter = gr.CheckboxGroup(
choices=organizations,
value=organizations,
label="",
elem_classes="filter-group"
)
gr.Markdown("**Datasets**")
dataset_filter = gr.CheckboxGroup(
choices=datasets,
value=datasets,
label="",
elem_classes="filter-group"
)
gr.Markdown("**Metrics**")
metric_filter = gr.CheckboxGroup(
choices=metric_cols,
value=metric_cols,
label="",
elem_classes="filter-group"
)
def update(search, md, org, dset, metrics, cols):
filtered = pivoted_df.copy()
if search:
mask = filtered.apply(lambda row: row.astype(str).str.contains(search, case=False).any(), axis=1)
filtered = filtered[mask]
if md:
filtered = filtered[filtered["Model"].isin(md)]
if org:
filtered = filtered[filtered["Organization"].isin(org)]
# Build display columns based on selected base columns and dataset/metric filters
display_cols = []
# Add selected base columns
for col in cols:
if col in base_cols:
display_cols.append(col)
# Add metric columns that match selected datasets and metrics
for col in metric_combo_cols:
# Check if this column matches selected datasets and metrics
col_dataset = col.split(" (")[0]
col_metric = col.split(" (")[1].rstrip(")")
if col_dataset in dset and col_metric in metrics:
display_cols.append(col)
filtered = filtered[display_cols]
return filtered
search_bar.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
model_filter.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
org_filter.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
dataset_filter.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
metric_filter.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
col_selector.change(update, [search_bar, model_filter, org_filter, dataset_filter, metric_filter, col_selector], table)
custom_css = """
.markdown-text {
font-size: 16px !important;
}
#leaderboard-table {
margin-top: 15px;
}
#leaderboard-table table {
width: 100%;
table-layout: auto;
}
#leaderboard-table thead th {
font-weight: bold;
text-align: center;
padding: 12px 8px;
white-space: normal;
word-wrap: break-word;
}
#leaderboard-table tbody td {
text-align: center;
padding: 10px 8px;
white-space: nowrap;
}
#leaderboard-table tbody td:first-child {
text-align: left;
font-weight: 500;
min-width: 120px;
max-width: 200px;
white-space: nowrap;
}
#leaderboard-table thead th:first-child {
text-align: left;
font-weight: bold;
min-width: 120px;
max-width: 200px;
white-space: nowrap;
}
#leaderboard-table tbody td:nth-child(2),
#leaderboard-table thead th:nth-child(2) {
text-align: left;
min-width: 100px;
}
#leaderboard-table tbody td:nth-child(3),
#leaderboard-table thead th:nth-child(3) {
text-align: left;
min-width: 120px;
}
/* Style links in Author column */
#leaderboard-table a {
color: #0066cc;
text-decoration: none;
}
#leaderboard-table a:hover {
text-decoration: underline;
}
#search-bar {
margin-bottom: 0px;
}
#search-bar textarea {
border: 1px solid #e0e0e0 !important;
border-radius: 8px !important;
}
.tab-buttons button {
font-size: 20px;
}
.filter-group {
margin-bottom: 1em;
}
.filter-group label {
font-size: 14px;
}
.column-select {
margin-bottom: 1.5em;
}
.column-select label {
display: flex;
flex-wrap: wrap;
gap: 0.5em;
}
.column-select label > span {
display: inline-flex;
align-items: center;
}
"""
TITLE = """<h1 align="center" id="space-title">Mars-Bench Leaderboard</h1>"""
INTRO = """
A comprehensive benchmark for evaluating computer vision models on Mars-specific datasets.
This leaderboard tracks model performance across three key tasks: classification, segmentation, and object detection.
"""
demo = gr.Blocks(css=custom_css, title="Mars-Bench Leaderboard")
with demo:
gr.HTML(TITLE)
gr.Markdown(INTRO, elem_classes="markdown-text")
with gr.Tabs(elem_classes="tab-buttons"):
build_tab(CLASSIFICATION_DF, "π
Classification")
build_tab(SEGMENTATION_DF, "π
Segmentation")
build_tab(DETECTION_DF, "π
Object Detection")
with gr.TabItem("π Submit", elem_id="submit-tab"):
gr.Markdown("""
# Submit Your Model Results
To submit your model's results to Mars-Bench, please provide the following information.
All submissions will be reviewed before being added to the leaderboard.
""")
gr.Markdown("""
### How to submit:
1. Fill out the form below
2. Click "Generate Submission Text"
3. Copy the generated text
4. Go to the [Community tab](https://huggingface.co/spaces/gremlin97/MarsBoard/discussions)
5. Click "New discussion"
6. Paste the text and submit
---
""")
with gr.Row():
with gr.Column():
submit_task = gr.Dropdown(
choices=["Classification", "Segmentation", "Object Detection"],
label="Task Type",
info="Select the task category"
)
submit_model = gr.Textbox(
label="Model Name",
placeholder="e.g., ResNet-50",
info="Name of your model"
)
submit_org = gr.Textbox(
label="Organization",
placeholder="e.g., Microsoft, Google",
info="Your organization or affiliation"
)
submit_dataset = gr.Textbox(
label="Dataset",
placeholder="e.g., DoMars16, Mars Crater",
info="Dataset used for evaluation"
)
with gr.Column():
submit_author = gr.Textbox(
label="Author",
placeholder="e.g., K. He",
info="Name of the author"
)
submit_author_link = gr.Textbox(
label="Author Page Link (Optional)",
placeholder="https://scholar.google.com/... or https://github.com/...",
info="Link to author's Google Scholar, GitHub, or personal page"
)
submit_metrics = gr.Textbox(
label="Metrics (JSON format)",
placeholder='{"Accuracy": 95.8, "F1-Score": 94.9}',
info="Provide metrics in JSON format",
lines=3
)
submit_paper = gr.Textbox(
label="Paper Link (Optional)",
placeholder="https://arxiv.org/abs/...",
info="Link to your research paper"
)
submit_code = gr.Textbox(
label="Code Repository (Optional)",
placeholder="https://github.com/...",
info="Link to your code repository"
)
submit_email = gr.Textbox(
label="Contact Email",
placeholder="your.email@example.com",
info="We'll contact you about your submission"
)
submit_notes = gr.Textbox(
label="Additional Notes (Optional)",
placeholder="Training details, hyperparameters, reproduction instructions...",
lines=4,
info="Any additional information"
)
generate_btn = gr.Button("Generate Submission Text", variant="primary", size="lg")
submission_output = gr.Textbox(
label="Copy this text and create a new discussion in the Community tab",
lines=15,
interactive=True
)
gr.Markdown("""
We'll review your submission and add it to the leaderboard if approved.
""")
def generate_submission_text(task, model, org, dataset, author, author_link, metrics, paper, code, email, notes):
if not all([task, model, org, dataset, author, metrics, email]):
return "β Error: Please fill in all required fields (Task Type, Model Name, Organization, Dataset, Author, Metrics, Contact Email)"
submission_text = f"""## New Model Submission
**Task Type:** {task}
**Model Name:** {model}
**Organization:** {org}
**Dataset:** {dataset}
**Author:** {author}
**Author Page Link:** {author_link if author_link else "N/A"}
### Metrics
```json
{metrics}
```
### Links
- **Paper:** {paper if paper else "N/A"}
- **Code:** {code if code else "N/A"}
### Contact
**Email:** {email}
### Additional Notes
{notes if notes else "N/A"}
---
*Please review this submission for inclusion in Mars-Bench.*
"""
return submission_text
generate_btn.click(
generate_submission_text,
inputs=[submit_task, submit_model, submit_org, submit_dataset, submit_author,
submit_author_link, submit_metrics, submit_paper, submit_code, submit_email, submit_notes],
outputs=submission_output
)
if __name__ == "__main__":
demo.launch()
|