Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
-
import os
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
| 6 |
import requests
|
| 7 |
from huggingface_hub import HfApi, hf_hub_download, InferenceClient
|
| 8 |
|
|
|
|
|
|
|
| 9 |
# Initialize Hugging Face API and real AI Client
|
| 10 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 11 |
api = HfApi(token=HF_TOKEN)
|
|
@@ -221,7 +224,7 @@ HERO_HTML = """
|
|
| 221 |
letter-spacing:.1em; text-transform:uppercase; margin-bottom:22px;
|
| 222 |
box-shadow: 0 0 20px rgba(245, 166, 35, 0.4), inset 0 0 10px rgba(245, 166, 35, 0.2);
|
| 223 |
text-shadow: 0 0 8px rgba(255,255,255,0.6);
|
| 224 |
-
">π
|
| 225 |
|
| 226 |
<h1 style="
|
| 227 |
font-size:clamp(2.5rem,7vw,4.2rem); font-weight:800;
|
|
@@ -237,7 +240,7 @@ HERO_HTML = """
|
|
| 237 |
color:#F5A623; margin-bottom:20px; letter-spacing:-.01em;
|
| 238 |
text-shadow: 0 0 15px rgba(245, 166, 35, 0.6);
|
| 239 |
">
|
| 240 |
-
|
| 241 |
</div>
|
| 242 |
|
| 243 |
<p style="
|
|
@@ -245,7 +248,7 @@ HERO_HTML = """
|
|
| 245 |
line-height:1.8; margin:0 auto 28px;
|
| 246 |
text-shadow: 0 0 5px rgba(160, 160, 192, 0.3);
|
| 247 |
">
|
| 248 |
-
|
| 249 |
</p>
|
| 250 |
|
| 251 |
<div style="
|
|
@@ -261,12 +264,12 @@ HERO_HTML = """
|
|
| 261 |
</div>
|
| 262 |
"""
|
| 263 |
|
| 264 |
-
QUICKSTART_LABEL_HTML = """<div style="font-family:'Inter',sans-serif; padding:28px 0 10px;"><p style="font-size:.75rem; color:#F5A623; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:10px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">β‘ Quick Start β Run
|
| 265 |
OR_DIVIDER_HTML = """<div style="display:flex; align-items:center; gap:12px; font-family:'Inter',sans-serif; font-size:.8rem; color:#606090; font-weight: 600; padding: 18px 0 6px; text-shadow: 0 0 8px rgba(96, 96, 144, 0.4);"><div style="flex:1; height:1px; background: linear-gradient(90deg, transparent, rgba(245,166,35,0.4)); box-shadow: 0 0 8px rgba(245,166,35,0.4);"></div><span>OR PASTE REPO LINKS</span><div style="flex:1; height:1px; background: linear-gradient(270deg, transparent, rgba(245,166,35,0.4)); box-shadow: 0 0 8px rgba(245,166,35,0.4);"></div></div>"""
|
| 266 |
CUSTOM_LABEL_HTML = """<div style="font-family:'Inter',sans-serif; padding:4px 0 6px;"><p style="font-size:.75rem; color:#80a0ff; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:4px; text-shadow: 0 0 12px rgba(128, 160, 255, 0.6);">Submissions to Judge</p></div>"""
|
| 267 |
CRITERIA_HEADER_HTML = """<div style="font-family:'Inter',sans-serif; padding:20px 0 6px;"><p style="font-size:.75rem; color:#F5A623; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:6px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">Target Judging Criteria</p></div>"""
|
| 268 |
-
HANDOFF_HTML = """<div style="background: radial-gradient(circle at center, #150f28, #05050f); border: 1px solid rgba(245, 166, 35, 0.4); border-radius: 16px; padding:35px 24px; text-align:center; margin-top:30px; font-family:'Inter',sans-serif; box-shadow: 0 0 40px rgba(245, 166, 35, 0.15), inset 0 0 20px rgba(245, 166, 35, 0.05);"><div style="font-size:3rem;margin-bottom:15px; filter: drop-shadow(0 0 15px rgba(255,255,255,0.5));">π</div><h3 style="font-size:1.4rem; font-weight:800; color:#fff; margin-bottom:12px; letter-spacing:-.01em; text-shadow: 0 0 20px rgba(245, 166, 35, 0.8), 0 0 10px rgba(255,255,255,0.5);">
|
| 269 |
-
FOOTER_HTML = """<div style="text-align:center; padding:25px 16px; font-size:.8rem; font-weight: 600; color:#404070; border-top:1px solid rgba(245, 166, 35, 0.15); margin-top:30px; font-family:'Inter',sans-serif; text-shadow: 0 0 8px rgba(64,64,112,0.5); box-shadow: inset 0 10px 20px -10px rgba(245, 166, 35, 0.05);">
|
| 270 |
|
| 271 |
PRESETS = {
|
| 272 |
"π Build Small Hackathon": "https://huggingface.co/build-small-hackathon",
|
|
@@ -466,7 +469,6 @@ def build_podium_html(results):
|
|
| 466 |
ok = [r for r in results if not r["error"]]
|
| 467 |
if not ok: return ""
|
| 468 |
|
| 469 |
-
# Renders 3 Overall Winners side by side explicitly
|
| 470 |
medals = [("π₯","1st Place Overall","#F5A623","rgba(245,166,35,.15)"),
|
| 471 |
("π₯","2nd Place Overall","#b0b8d0","rgba(176,184,208,.15)"),
|
| 472 |
("π₯","3rd Place Overall","#cd7f32","rgba(205,127,50,.15)")]
|
|
@@ -481,7 +483,7 @@ def build_podium_html(results):
|
|
| 481 |
<div style="font-size:1.5rem;font-weight:800;color:{color};">{r["overall"]}/10</div>
|
| 482 |
{"<a href='" + r['url'] + "' target='_blank' style='display:inline-block; margin-top:8px; font-size:.8rem; font-weight:700; color:#80a0ff; text-decoration:none;'>Open Repo β</a>" if r["url"] else ""}
|
| 483 |
</div>""")
|
| 484 |
-
return f"""<div style="padding:30px 0 15px;font-family:'Inter',sans-serif;"><div style="font-size:.8rem;color:#F5A623;font-weight:800;letter-spacing:.15em;text-transform:uppercase;margin-bottom:18px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">π
|
| 485 |
|
| 486 |
def build_leaderboard(results, criteria_list):
|
| 487 |
cols = ["π
","Project","β Overall"] + criteria_list + ["β€οΈ Likes"]
|
|
@@ -496,28 +498,26 @@ def build_criteria_table(results, criteria_list):
|
|
| 496 |
def build_winners_breakdown(results, criteria_list):
|
| 497 |
if not results: return ""
|
| 498 |
|
| 499 |
-
lines = ["## π
|
| 500 |
for c in criteria_list:
|
| 501 |
winner = max(results, key=lambda x: x["scores"].get(c, 0))
|
| 502 |
lines.append(f"- **{c.upper()}**: **{winner['title']}** ({winner['scores'].get(c, 0)}/10) β _{winner['justifications'].get(c, '')}_")
|
| 503 |
|
| 504 |
lines.extend(["\n---", "### π Top Overall Champions\n"])
|
| 505 |
|
| 506 |
-
# Render the 3 Overall Winners
|
| 507 |
for idx, badge in enumerate(["π₯ **1st Place Grand Champion**", "π₯ **2nd Place Grand Champion**", "π₯ **3rd Place Grand Champion**"]):
|
| 508 |
if len(results) > idx:
|
| 509 |
r = results[idx]
|
| 510 |
-
lines.append(f"- {badge}: **{r['title']}** ({r['overall']}/10) | β€οΈ {r['likes']} Likes\n
|
| 511 |
|
| 512 |
-
# Render the Runner-Up (4th overall placement entry)
|
| 513 |
if len(results) > 3:
|
| 514 |
runner_up = results[3]
|
| 515 |
-
lines.append(f"\n- ποΈ **Official Runner-Up (4th Place)**: **{runner_up['title']}** ({runner_up['overall']}/10) | β€οΈ {runner_up['likes']} Likes\n
|
| 516 |
|
| 517 |
return "\n".join(lines)
|
| 518 |
|
| 519 |
def build_briefing(results, criteria_list):
|
| 520 |
-
lines = ["## π
|
| 521 |
for i, r in enumerate(results, 1):
|
| 522 |
lines.append(f"### #{i} {r['title']}\nπ Link: {r['url']}\n_{r['summary']}_\n")
|
| 523 |
for c in criteria_list:
|
|
@@ -573,7 +573,7 @@ def fill_and_run(preset_url, criteria_text):
|
|
| 573 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 574 |
# UI Architecture Entry Layout
|
| 575 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 576 |
-
with gr.Blocks(theme=gr.themes.Base(), css=CSS, title="Judges Copilot
|
| 577 |
gr.HTML(HERO_HTML)
|
| 578 |
gr.HTML(QUICKSTART_LABEL_HTML)
|
| 579 |
|
|
@@ -590,11 +590,11 @@ with gr.Blocks(theme=gr.themes.Base(), css=CSS, title="Judges Copilot Real-Grade
|
|
| 590 |
gr.HTML(CRITERIA_HEADER_HTML)
|
| 591 |
criteria_box = gr.Textbox(label="", value="Innovation, Technical Execution, Usability & Design, Impact", lines=2, show_label=False)
|
| 592 |
|
| 593 |
-
analyse_btn = gr.Button("β‘ Run
|
| 594 |
confetti_out = gr.HTML(value="")
|
| 595 |
podium_out = gr.HTML(value="")
|
| 596 |
|
| 597 |
-
gr.HTML("""<div style="font-family:'Inter',sans-serif;font-size:.8rem;color:#F5A623;font-weight:800;letter-spacing:.15em;text-transform:uppercase;padding:35px 0 15px;text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">π
|
| 598 |
|
| 599 |
with gr.Tabs():
|
| 600 |
with gr.Tab("π Winners Breakdown"): winners_out = gr.Markdown(value="")
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
import random
|
| 4 |
+
import json
|
| 5 |
import gradio as gr
|
| 6 |
import pandas as pd
|
| 7 |
import requests
|
| 8 |
from huggingface_hub import HfApi, hf_hub_download, InferenceClient
|
| 9 |
|
| 10 |
+
os.environ.setdefault("GRADIO_ANALYTICS_ENABLED", "False")
|
| 11 |
+
|
| 12 |
# Initialize Hugging Face API and real AI Client
|
| 13 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 14 |
api = HfApi(token=HF_TOKEN)
|
|
|
|
| 224 |
letter-spacing:.1em; text-transform:uppercase; margin-bottom:22px;
|
| 225 |
box-shadow: 0 0 20px rgba(245, 166, 35, 0.4), inset 0 0 10px rgba(245, 166, 35, 0.2);
|
| 226 |
text-shadow: 0 0 8px rgba(255,255,255,0.6);
|
| 227 |
+
">π NOW, WE ARE TO BE JUDGED ONLY BY YOU</div>
|
| 228 |
|
| 229 |
<h1 style="
|
| 230 |
font-size:clamp(2.5rem,7vw,4.2rem); font-weight:800;
|
|
|
|
| 240 |
color:#F5A623; margin-bottom:20px; letter-spacing:-.01em;
|
| 241 |
text-shadow: 0 0 15px rgba(245, 166, 35, 0.6);
|
| 242 |
">
|
| 243 |
+
We helped everyone else.
|
| 244 |
</div>
|
| 245 |
|
| 246 |
<p style="
|
|
|
|
| 248 |
line-height:1.8; margin:0 auto 28px;
|
| 249 |
text-shadow: 0 0 5px rgba(160, 160, 192, 0.3);
|
| 250 |
">
|
| 251 |
+
Now this tool itself is a submission, sitting in the same pile, waiting for the same verdict. The judge is you.
|
| 252 |
</p>
|
| 253 |
|
| 254 |
<div style="
|
|
|
|
| 264 |
</div>
|
| 265 |
"""
|
| 266 |
|
| 267 |
+
QUICKSTART_LABEL_HTML = """<div style="font-family:'Inter',sans-serif; padding:28px 0 10px;"><p style="font-size:.75rem; color:#F5A623; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:10px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">β‘ Quick Start β Run Evaluations</p></div>"""
|
| 268 |
OR_DIVIDER_HTML = """<div style="display:flex; align-items:center; gap:12px; font-family:'Inter',sans-serif; font-size:.8rem; color:#606090; font-weight: 600; padding: 18px 0 6px; text-shadow: 0 0 8px rgba(96, 96, 144, 0.4);"><div style="flex:1; height:1px; background: linear-gradient(90deg, transparent, rgba(245,166,35,0.4)); box-shadow: 0 0 8px rgba(245,166,35,0.4);"></div><span>OR PASTE REPO LINKS</span><div style="flex:1; height:1px; background: linear-gradient(270deg, transparent, rgba(245,166,35,0.4)); box-shadow: 0 0 8px rgba(245,166,35,0.4);"></div></div>"""
|
| 269 |
CUSTOM_LABEL_HTML = """<div style="font-family:'Inter',sans-serif; padding:4px 0 6px;"><p style="font-size:.75rem; color:#80a0ff; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:4px; text-shadow: 0 0 12px rgba(128, 160, 255, 0.6);">Submissions to Judge</p></div>"""
|
| 270 |
CRITERIA_HEADER_HTML = """<div style="font-family:'Inter',sans-serif; padding:20px 0 6px;"><p style="font-size:.75rem; color:#F5A623; font-weight:800; letter-spacing:.15em; text-transform:uppercase; margin-bottom:6px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">Target Judging Criteria</p></div>"""
|
| 271 |
+
HANDOFF_HTML = """<div style="background: radial-gradient(circle at center, #150f28, #05050f); border: 1px solid rgba(245, 166, 35, 0.4); border-radius: 16px; padding:35px 24px; text-align:center; margin-top:30px; font-family:'Inter',sans-serif; box-shadow: 0 0 40px rgba(245, 166, 35, 0.15), inset 0 0 20px rgba(245, 166, 35, 0.05);"><div style="font-size:3rem;margin-bottom:15px; filter: drop-shadow(0 0 15px rgba(255,255,255,0.5));">π</div><h3 style="font-size:1.4rem; font-weight:800; color:#fff; margin-bottom:12px; letter-spacing:-.01em; text-shadow: 0 0 20px rgba(245, 166, 35, 0.8), 0 0 10px rgba(255,255,255,0.5);">Now, We Are To Be Judged Only By You</h3></div>"""
|
| 272 |
+
FOOTER_HTML = """<div style="text-align:center; padding:25px 16px; font-size:.8rem; font-weight: 600; color:#404070; border-top:1px solid rgba(245, 166, 35, 0.15); margin-top:30px; font-family:'Inter',sans-serif; text-shadow: 0 0 8px rgba(64,64,112,0.5); box-shadow: inset 0 10px 20px -10px rgba(245, 166, 35, 0.05);">Judges Copilot Submission Core 2026</div>"""
|
| 273 |
|
| 274 |
PRESETS = {
|
| 275 |
"π Build Small Hackathon": "https://huggingface.co/build-small-hackathon",
|
|
|
|
| 469 |
ok = [r for r in results if not r["error"]]
|
| 470 |
if not ok: return ""
|
| 471 |
|
|
|
|
| 472 |
medals = [("π₯","1st Place Overall","#F5A623","rgba(245,166,35,.15)"),
|
| 473 |
("π₯","2nd Place Overall","#b0b8d0","rgba(176,184,208,.15)"),
|
| 474 |
("π₯","3rd Place Overall","#cd7f32","rgba(205,127,50,.15)")]
|
|
|
|
| 483 |
<div style="font-size:1.5rem;font-weight:800;color:{color};">{r["overall"]}/10</div>
|
| 484 |
{"<a href='" + r['url'] + "' target='_blank' style='display:inline-block; margin-top:8px; font-size:.8rem; font-weight:700; color:#80a0ff; text-decoration:none;'>Open Repo β</a>" if r["url"] else ""}
|
| 485 |
</div>""")
|
| 486 |
+
return f"""<div style="padding:30px 0 15px;font-family:'Inter',sans-serif;"><div style="font-size:.8rem;color:#F5A623;font-weight:800;letter-spacing:.15em;text-transform:uppercase;margin-bottom:18px; text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">π Submission Leaderboard Podium</div><div style="display:flex;gap:16px;flex-wrap:wrap;">{"".join(cards)}</div></div>"""
|
| 487 |
|
| 488 |
def build_leaderboard(results, criteria_list):
|
| 489 |
cols = ["π
","Project","β Overall"] + criteria_list + ["β€οΈ Likes"]
|
|
|
|
| 498 |
def build_winners_breakdown(results, criteria_list):
|
| 499 |
if not results: return ""
|
| 500 |
|
| 501 |
+
lines = ["## π Hackathon Champions","---","### ποΈ Category Winners\n"]
|
| 502 |
for c in criteria_list:
|
| 503 |
winner = max(results, key=lambda x: x["scores"].get(c, 0))
|
| 504 |
lines.append(f"- **{c.upper()}**: **{winner['title']}** ({winner['scores'].get(c, 0)}/10) β _{winner['justifications'].get(c, '')}_")
|
| 505 |
|
| 506 |
lines.extend(["\n---", "### π Top Overall Champions\n"])
|
| 507 |
|
|
|
|
| 508 |
for idx, badge in enumerate(["π₯ **1st Place Grand Champion**", "π₯ **2nd Place Grand Champion**", "π₯ **3rd Place Grand Champion**"]):
|
| 509 |
if len(results) > idx:
|
| 510 |
r = results[idx]
|
| 511 |
+
lines.append(f"- {badge}: **{r['title']}** ({r['overall']}/10) | β€οΈ {r['likes']} Likes\n > _{r['summary']}_")
|
| 512 |
|
|
|
|
| 513 |
if len(results) > 3:
|
| 514 |
runner_up = results[3]
|
| 515 |
+
lines.append(f"\n- ποΈ **Official Runner-Up (4th Place)**: **{runner_up['title']}** ({runner_up['overall']}/10) | β€οΈ {runner_up['likes']} Likes\n > _{runner_up['summary']}_")
|
| 516 |
|
| 517 |
return "\n".join(lines)
|
| 518 |
|
| 519 |
def build_briefing(results, criteria_list):
|
| 520 |
+
lines = ["## π Judge's Dossier Briefing","---"]
|
| 521 |
for i, r in enumerate(results, 1):
|
| 522 |
lines.append(f"### #{i} {r['title']}\nπ Link: {r['url']}\n_{r['summary']}_\n")
|
| 523 |
for c in criteria_list:
|
|
|
|
| 573 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 574 |
# UI Architecture Entry Layout
|
| 575 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 576 |
+
with gr.Blocks(theme=gr.themes.Base(), css=CSS, title="Judges Copilot Submission Runtime") as demo:
|
| 577 |
gr.HTML(HERO_HTML)
|
| 578 |
gr.HTML(QUICKSTART_LABEL_HTML)
|
| 579 |
|
|
|
|
| 590 |
gr.HTML(CRITERIA_HEADER_HTML)
|
| 591 |
criteria_box = gr.Textbox(label="", value="Innovation, Technical Execution, Usability & Design, Impact", lines=2, show_label=False)
|
| 592 |
|
| 593 |
+
analyse_btn = gr.Button("β‘ Run Submission Evaluation Matrix", elem_classes=["cta"])
|
| 594 |
confetti_out = gr.HTML(value="")
|
| 595 |
podium_out = gr.HTML(value="")
|
| 596 |
|
| 597 |
+
gr.HTML("""<div style="font-family:'Inter',sans-serif;font-size:.8rem;color:#F5A623;font-weight:800;letter-spacing:.15em;text-transform:uppercase;padding:35px 0 15px;text-shadow: 0 0 12px rgba(245, 166, 35, 0.6);">π Performance Portals Matrix</div>""")
|
| 598 |
|
| 599 |
with gr.Tabs():
|
| 600 |
with gr.Tab("π Winners Breakdown"): winners_out = gr.Markdown(value="")
|