Spaces:
Running
Running
Upload 2 files
Browse files- app.py +59 -16
- dashboard.css +22 -0
app.py
CHANGED
@@ -368,32 +368,51 @@ def create_leaderboard(selected_categories):
|
|
368 |
for category_name, category in data['scores'].items():
|
369 |
category_score = 0
|
370 |
category_total = 0
|
|
|
371 |
|
372 |
for section in category.values():
|
373 |
if section['status'] != 'N/A':
|
|
|
374 |
questions = section.get('questions', {})
|
375 |
category_score += sum(1 for q in questions.values() if q)
|
376 |
category_total += len(questions)
|
377 |
|
378 |
if category_total > 0:
|
379 |
score_by_category[category_name] = (category_score / category_total) * 100
|
380 |
-
|
381 |
-
|
|
|
|
|
382 |
|
383 |
# Calculate overall score
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
|
386 |
# Get model type and URL
|
387 |
model_type = data['metadata'].get('Type', 'Unknown')
|
388 |
model_url = data['metadata'].get('URL', '')
|
389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
# Create model name with HTML link if URL exists
|
391 |
model_display = f'<a href="{model_url}" target="_blank">{model}</a>' if model_url else model
|
392 |
|
393 |
# Create entry with numerical scores
|
394 |
model_entry = {
|
395 |
'AI System': model_display,
|
396 |
-
'
|
397 |
'Overall Completion Rate': score_percentage
|
398 |
}
|
399 |
|
@@ -418,17 +437,40 @@ def create_leaderboard(selected_categories):
|
|
418 |
# Convert to DataFrame
|
419 |
df = pd.DataFrame(scores)
|
420 |
|
421 |
-
# Sort by Overall Completion Rate descending
|
422 |
-
df = df
|
|
|
|
|
|
|
|
|
423 |
|
424 |
# Add rank column based on current sort
|
425 |
df.insert(0, 'Rank', range(1, len(df) + 1))
|
426 |
|
427 |
-
#
|
428 |
-
|
429 |
-
|
430 |
-
if
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
|
433 |
return df
|
434 |
|
@@ -436,10 +478,11 @@ first_model = next(iter(models.values()))
|
|
436 |
category_choices = list(first_model['scores'].keys())
|
437 |
|
438 |
with gr.Column(visible=True) as leaderboard_tab:
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
443 |
)
|
444 |
|
445 |
def create_category_chart(selected_models, selected_categories):
|
@@ -645,7 +688,7 @@ with gr.Blocks(css=css) as demo:
|
|
645 |
value=create_leaderboard(category_choices),
|
646 |
interactive=False,
|
647 |
wrap=True,
|
648 |
-
datatype=["markdown", "markdown", "markdown"] + ["markdown"] * len(category_choices) #
|
649 |
)
|
650 |
|
651 |
with gr.Column(visible=False) as category_analysis_tab:
|
|
|
368 |
for category_name, category in data['scores'].items():
|
369 |
category_score = 0
|
370 |
category_total = 0
|
371 |
+
all_na = True
|
372 |
|
373 |
for section in category.values():
|
374 |
if section['status'] != 'N/A':
|
375 |
+
all_na = False
|
376 |
questions = section.get('questions', {})
|
377 |
category_score += sum(1 for q in questions.values() if q)
|
378 |
category_total += len(questions)
|
379 |
|
380 |
if category_total > 0:
|
381 |
score_by_category[category_name] = (category_score / category_total) * 100
|
382 |
+
elif all_na:
|
383 |
+
score_by_category[category_name] = "N/A"
|
384 |
+
total_score += category_score
|
385 |
+
total_questions += category_total
|
386 |
|
387 |
# Calculate overall score
|
388 |
+
overall_all_na = all(
|
389 |
+
all(section['status'] == 'N/A' for section in category.values())
|
390 |
+
for category_name, category in data['scores'].items()
|
391 |
+
if category_name in selected_categories
|
392 |
+
)
|
393 |
+
|
394 |
+
score_percentage = "N/A" if overall_all_na else (
|
395 |
+
(total_score / total_questions * 100) if total_questions > 0 else 0
|
396 |
+
)
|
397 |
|
398 |
# Get model type and URL
|
399 |
model_type = data['metadata'].get('Type', 'Unknown')
|
400 |
model_url = data['metadata'].get('URL', '')
|
401 |
|
402 |
+
# Get modalities and create badges
|
403 |
+
modalities = data['metadata'].get('Modalities', [])
|
404 |
+
modality_badges = " ".join(
|
405 |
+
f"<span class='modality-badge'>{get_modality_icon(m)} {m}</span>"
|
406 |
+
for m in modalities
|
407 |
+
) if modalities else "<span class='modality-badge'>💫 Unknown</span>"
|
408 |
+
|
409 |
# Create model name with HTML link if URL exists
|
410 |
model_display = f'<a href="{model_url}" target="_blank">{model}</a>' if model_url else model
|
411 |
|
412 |
# Create entry with numerical scores
|
413 |
model_entry = {
|
414 |
'AI System': model_display,
|
415 |
+
'Modality': f"<div class='modality-container'>{modality_badges}</div>",
|
416 |
'Overall Completion Rate': score_percentage
|
417 |
}
|
418 |
|
|
|
437 |
# Convert to DataFrame
|
438 |
df = pd.DataFrame(scores)
|
439 |
|
440 |
+
# Sort by Overall Completion Rate descending, putting N/A at the end
|
441 |
+
df['_sort_value'] = df['Overall Completion Rate'].apply(
|
442 |
+
lambda x: -float('inf') if x == "N/A" else float(x)
|
443 |
+
)
|
444 |
+
df = df.sort_values('_sort_value', ascending=False)
|
445 |
+
df = df.drop('_sort_value', axis=1)
|
446 |
|
447 |
# Add rank column based on current sort
|
448 |
df.insert(0, 'Rank', range(1, len(df) + 1))
|
449 |
|
450 |
+
# Get completion rate columns (Overall + category-specific)
|
451 |
+
completion_rate_columns = ['Overall Completion Rate'] + [
|
452 |
+
display_name for full_cat_name, display_name in category_map.items()
|
453 |
+
if full_cat_name in selected_categories
|
454 |
+
]
|
455 |
+
|
456 |
+
# Format non-completion rate columns
|
457 |
+
df['Rank'] = df['Rank'].astype(str)
|
458 |
+
|
459 |
+
# Identify and format highest values for completion rate columns
|
460 |
+
for col in completion_rate_columns:
|
461 |
+
if col in df.columns:
|
462 |
+
# Filter out N/A values to find the maximum numerical value
|
463 |
+
numeric_values = df[df[col] != "N/A"][col]
|
464 |
+
if not numeric_values.empty:
|
465 |
+
max_value = numeric_values.max()
|
466 |
+
df[col] = df.apply(
|
467 |
+
lambda row: "N/A" if row[col] == "N/A"
|
468 |
+
else f"**{row[col]:.1f}%**" if row[col] == max_value
|
469 |
+
else f"{row[col]:.1f}%",
|
470 |
+
axis=1
|
471 |
+
)
|
472 |
+
else:
|
473 |
+
df[col] = df[col].apply(lambda x: "N/A")
|
474 |
|
475 |
return df
|
476 |
|
|
|
478 |
category_choices = list(first_model['scores'].keys())
|
479 |
|
480 |
with gr.Column(visible=True) as leaderboard_tab:
|
481 |
+
leaderboard_output = gr.DataFrame(
|
482 |
+
value=create_leaderboard(category_choices),
|
483 |
+
interactive=False,
|
484 |
+
wrap=True,
|
485 |
+
datatype=["markdown", "markdown", "markdown"] + ["markdown"] * (len(category_choices)+1) # Support markdown in all columns
|
486 |
)
|
487 |
|
488 |
def create_category_chart(selected_models, selected_categories):
|
|
|
688 |
value=create_leaderboard(category_choices),
|
689 |
interactive=False,
|
690 |
wrap=True,
|
691 |
+
datatype=["markdown", "markdown", "markdown"] + ["markdown"] * (len(category_choices)+1) # Support markdown in all columns
|
692 |
)
|
693 |
|
694 |
with gr.Column(visible=False) as category_analysis_tab:
|
dashboard.css
CHANGED
@@ -616,4 +616,26 @@
|
|
616 |
|
617 |
.dark .leaderboard-table tr:hover {
|
618 |
background-color: #2d2d2d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
}
|
|
|
616 |
|
617 |
.dark .leaderboard-table tr:hover {
|
618 |
background-color: #2d2d2d;
|
619 |
+
}
|
620 |
+
.dataframe .modality-container {
|
621 |
+
margin-top: 4px;
|
622 |
+
}
|
623 |
+
|
624 |
+
.dataframe .modality-badge {
|
625 |
+
display: inline-flex;
|
626 |
+
align-items: center;
|
627 |
+
gap: 4px;
|
628 |
+
padding: 2px 6px;
|
629 |
+
background-color: #f0f7ff;
|
630 |
+
border: 1px solid #cce3ff;
|
631 |
+
border-radius: 12px;
|
632 |
+
font-size: 0.85em;
|
633 |
+
color: #0066cc;
|
634 |
+
margin: 2px;
|
635 |
+
}
|
636 |
+
|
637 |
+
.dark .dataframe .modality-badge {
|
638 |
+
background-color: #1a2733;
|
639 |
+
border-color: #2c3e50;
|
640 |
+
color: #99ccff;
|
641 |
}
|