Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -461,7 +461,7 @@ CHALLENGES = [
|
|
| 461 |
"description": "Answer open-ended questions about images taken by blind users. Models are evaluated on answer accuracy and relevance.",
|
| 462 |
"metrics": "Coming soon",
|
| 463 |
"route": "/vqa",
|
| 464 |
-
"active":
|
| 465 |
},
|
| 466 |
{
|
| 467 |
"id": "answer-grounding",
|
|
@@ -665,11 +665,72 @@ with demo.route("Object Localization", "/object-localization") as obj_loc:
|
|
| 665 |
|
| 666 |
# ββ VQA PAGE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 667 |
with demo.route("Visual Question Answering", "/vqa"):
|
| 668 |
-
gr.Markdown("# π€ Visual Question Answering")
|
| 669 |
-
gr.Markdown("### π Coming Soon")
|
| 670 |
-
gr.Markdown(
|
| 671 |
-
|
| 672 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
|
| 674 |
# ββ ANSWER GROUNDING PAGE βββββββββββββββββββββββββββββββββββββββββββββ
|
| 675 |
with demo.route("Answer Grounding", "/answer-grounding"):
|
|
|
|
| 461 |
"description": "Answer open-ended questions about images taken by blind users. Models are evaluated on answer accuracy and relevance.",
|
| 462 |
"metrics": "Coming soon",
|
| 463 |
"route": "/vqa",
|
| 464 |
+
"active": True,
|
| 465 |
},
|
| 466 |
{
|
| 467 |
"id": "answer-grounding",
|
|
|
|
| 665 |
|
| 666 |
# ββ VQA PAGE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 667 |
with demo.route("Visual Question Answering", "/vqa"):
|
| 668 |
+
# gr.Markdown("# π€ Visual Question Answering")
|
| 669 |
+
# gr.Markdown("### π Coming Soon")
|
| 670 |
+
# gr.Markdown(
|
| 671 |
+
# "This challenge is currently under development. "
|
| 672 |
+
# )
|
| 673 |
+
|
| 674 |
+
with gr.Row():
|
| 675 |
+
with gr.Column(scale=5):
|
| 676 |
+
gr.Markdown("# π€ Visual Question Answering Challenge")
|
| 677 |
+
gr.Markdown(
|
| 678 |
+
"Answer open-ended questions about images taken by blind users. "
|
| 679 |
+
"Models are evaluated on answer accuracy and relevance."
|
| 680 |
+
)
|
| 681 |
+
with gr.Column(scale=1, min_width=160):
|
| 682 |
+
gr.LoginButton(size="lg")
|
| 683 |
+
vqa_greeting = gr.Markdown("π Log in to view or submit.")
|
| 684 |
+
|
| 685 |
+
gr.Markdown("---")
|
| 686 |
+
|
| 687 |
+
with gr.Tabs():
|
| 688 |
+
# Task 2: Leaderboard Tab showing Empty DF if no submissions
|
| 689 |
+
with gr.TabItem("π Leaderboard"):
|
| 690 |
+
gr.Markdown("### VQA Challenge Rankings")
|
| 691 |
+
lb_msg = gr.Markdown("")
|
| 692 |
+
|
| 693 |
+
# The Dataframe component that will hold our submissions (or empty columns)
|
| 694 |
+
vqa_lb_table = gr.Dataframe(interactive=False, wrap=True)
|
| 695 |
+
refresh_vqa_lb_btn = gr.Button("π Refresh Leaderboard", variant="secondary", size="sm")
|
| 696 |
+
|
| 697 |
+
def refresh_vqa_leaderboard(profile: gr.OAuthProfile | None):
|
| 698 |
+
# 1. Define the empty DataFrame structure for VQA
|
| 699 |
+
empty_df = pd.DataFrame(columns=["Rank", "Team", "Model", "Accuracy", "Scored At"])
|
| 700 |
+
|
| 701 |
+
try:
|
| 702 |
+
df = _load_leaderboard_df()
|
| 703 |
+
# Filter for VQA submissions if they exist
|
| 704 |
+
if not df.empty and "challenge_type" in df.columns:
|
| 705 |
+
df = df[df["challenge_type"] == "vqa"]
|
| 706 |
+
except Exception as e:
|
| 707 |
+
return empty_df, f"β Could not load leaderboard: {e}", get_user_greeting(profile)
|
| 708 |
+
|
| 709 |
+
# 2. Return the empty DataFrame if no VQA submissions exist
|
| 710 |
+
if df.empty:
|
| 711 |
+
return empty_df, "βΉοΈ No VQA submissions yet. Be the first to conquer the challenge!", get_user_greeting(profile)
|
| 712 |
+
|
| 713 |
+
# 3. Process existing submissions (if any)
|
| 714 |
+
df_display = df.copy()
|
| 715 |
+
df_display.insert(0, "Rank", range(1, len(df_display) + 1))
|
| 716 |
+
if "timestamp" in df_display.columns:
|
| 717 |
+
df_display["Scored At"] = pd.to_datetime(
|
| 718 |
+
df_display["timestamp"], unit="s", errors="coerce"
|
| 719 |
+
).dt.strftime("%d %b %Y, %I:%M %p")
|
| 720 |
+
|
| 721 |
+
# Keep only relevant columns and rename them cleanly
|
| 722 |
+
cols_to_keep = ["Rank", "team", "model", "accuracy", "Scored At"]
|
| 723 |
+
df_display = df_display[[c for c in cols_to_keep if c in df_display.columns]]
|
| 724 |
+
df_display.rename(columns={"team": "Team", "model": "Model", "accuracy": "Accuracy"}, inplace=True)
|
| 725 |
+
|
| 726 |
+
return df_display, "", get_user_greeting(profile)
|
| 727 |
+
|
| 728 |
+
# Bind the functions to the load and button click events
|
| 729 |
+
refresh_vqa_lb_btn.click(refresh_vqa_leaderboard, outputs=[vqa_lb_table, lb_msg, vqa_greeting])
|
| 730 |
+
vqa_page.load(refresh_vqa_leaderboard, outputs=[vqa_lb_table, lb_msg, vqa_greeting])
|
| 731 |
+
|
| 732 |
+
# (Optional) You can add the "π Submit Predictions" tab here later using the
|
| 733 |
+
# same pattern as the Object Localization page!
|
| 734 |
|
| 735 |
# ββ ANSWER GROUNDING PAGE βββββββββββββββββββββββββββββββββββββββββββββ
|
| 736 |
with demo.route("Answer Grounding", "/answer-grounding"):
|