Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,10 +10,8 @@ SUBMISSIONS_REPO = "oddadmix/ocr-competition-submissions"
|
|
| 10 |
RESULTS_REPO = "oddadmix/ocr-competition-results"
|
| 11 |
|
| 12 |
def validate_fields(team_name, email, model_name, hf_model_id, hf_token, code):
|
| 13 |
-
# Check if any field is empty
|
| 14 |
if not team_name or not email or not model_name or not hf_model_id or not hf_token or not code:
|
| 15 |
return "All fields are required. Please fill in all fields."
|
| 16 |
-
# Proceed with submission if all fields are filled
|
| 17 |
return submit(team_name, email, model_name, hf_model_id, hf_token, code)
|
| 18 |
|
| 19 |
def submit(team_name, email, model_name, hf_model_id, hf_token, code):
|
|
@@ -37,9 +35,7 @@ def submit(team_name, email, model_name, hf_model_id, hf_token, code):
|
|
| 37 |
|
| 38 |
def show_results():
|
| 39 |
try:
|
| 40 |
-
# Load results from the results dataset
|
| 41 |
ds = load_dataset("oddadmix/ocr-competition-results", split="train")
|
| 42 |
-
# Check if the dataset is empty
|
| 43 |
if len(ds) == 0:
|
| 44 |
return "No results available yet."
|
| 45 |
df = ds.to_pandas()[["model_name", "WER", "CER", "BLEU", "team_name"]]
|
|
@@ -48,23 +44,36 @@ def show_results():
|
|
| 48 |
return f"An error occurred while loading the results: {e}"
|
| 49 |
|
| 50 |
with gr.Blocks() as demo:
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
with gr.Tabs():
|
| 54 |
with gr.Tab("π Rules"):
|
| 55 |
gr.Markdown("""
|
| 56 |
-
|
| 57 |
-
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
<div style="display:flex; align-items:center; gap:20px;">
|
| 69 |
<div>
|
| 70 |
<a href="https://www.linkedin.com/company/68577545" target="_blank">
|
|
@@ -81,34 +90,41 @@ with gr.Blocks() as demo:
|
|
| 81 |
|
| 82 |
with gr.Tab("π Prizes"):
|
| 83 |
gr.Markdown("""
|
| 84 |
-
|
| 85 |
-
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
| 90 |
""")
|
| 91 |
|
| 92 |
with gr.Tab("π Evaluation"):
|
| 93 |
gr.Markdown("""
|
| 94 |
-
|
| 95 |
-
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
""")
|
| 103 |
|
| 104 |
with gr.Tab("π Submit & Leaderboard"):
|
| 105 |
-
gr.Markdown("
|
| 106 |
with gr.Row():
|
| 107 |
-
team = gr.Textbox(label="Team Name")
|
| 108 |
-
email = gr.Textbox(label="Email")
|
| 109 |
-
model = gr.Textbox(label="Model Name")
|
| 110 |
-
hf_model = gr.Textbox(label="Hugging Face Model ID")
|
| 111 |
-
hf_token = gr.Textbox(label="Hugging Face Access Token", type="password")
|
| 112 |
code = gr.Textbox(label="Code (instructions to run your model)", lines=6, placeholder="Paste your run code here...")
|
| 113 |
|
| 114 |
submit_btn = gr.Button("Submit")
|
|
@@ -118,7 +134,7 @@ with gr.Blocks() as demo:
|
|
| 118 |
inputs=[team, email, model, hf_model, hf_token, code],
|
| 119 |
outputs=status)
|
| 120 |
|
| 121 |
-
gr.Markdown("
|
| 122 |
results = gr.Dataframe(headers=["model_name", "WER", "CER", "BLEU", "team_name"])
|
| 123 |
demo.load(fn=show_results, outputs=results)
|
| 124 |
|
|
|
|
| 10 |
RESULTS_REPO = "oddadmix/ocr-competition-results"
|
| 11 |
|
| 12 |
def validate_fields(team_name, email, model_name, hf_model_id, hf_token, code):
|
|
|
|
| 13 |
if not team_name or not email or not model_name or not hf_model_id or not hf_token or not code:
|
| 14 |
return "All fields are required. Please fill in all fields."
|
|
|
|
| 15 |
return submit(team_name, email, model_name, hf_model_id, hf_token, code)
|
| 16 |
|
| 17 |
def submit(team_name, email, model_name, hf_model_id, hf_token, code):
|
|
|
|
| 35 |
|
| 36 |
def show_results():
|
| 37 |
try:
|
|
|
|
| 38 |
ds = load_dataset("oddadmix/ocr-competition-results", split="train")
|
|
|
|
| 39 |
if len(ds) == 0:
|
| 40 |
return "No results available yet."
|
| 41 |
df = ds.to_pandas()[["model_name", "WER", "CER", "BLEU", "team_name"]]
|
|
|
|
| 44 |
return f"An error occurred while loading the results: {e}"
|
| 45 |
|
| 46 |
with gr.Blocks() as demo:
|
| 47 |
+
# Welcome message
|
| 48 |
+
gr.Markdown("""
|
| 49 |
+
<h2 style="font-size:28px;">π Welcome to the VLM OCR Competition!</h2>
|
| 50 |
+
<p style="font-size:18px;">
|
| 51 |
+
This competition aims to improve **open-source Arabic OCR models**.
|
| 52 |
+
It's part of the NAMAA Community mission to strengthen the Arabic presence in the ML space.
|
| 53 |
+
This competition is designed to **push the boundaries** of OCR performance on diverse Arabic documents.
|
| 54 |
+
</p>
|
| 55 |
+
""")
|
| 56 |
|
| 57 |
with gr.Tabs():
|
| 58 |
with gr.Tab("π Rules"):
|
| 59 |
gr.Markdown("""
|
| 60 |
+
<h3 style="font-size:22px;">Competition Rules</h3>
|
| 61 |
+
<ul style="font-size:18px;">
|
| 62 |
+
<li>Each team can submit **one model evaluation per week**.</li>
|
| 63 |
+
<li>The competition runs from **September 12 to October 12** (1 month).</li>
|
| 64 |
+
<li>The evaluation dataset will **not be provided** to participants.</li>
|
| 65 |
+
<li>Teams must submit:
|
| 66 |
+
<ol>
|
| 67 |
+
<li>The Hugging Face Model ID.</li>
|
| 68 |
+
<li>A valid Hugging Face token with access.</li>
|
| 69 |
+
<li>The code required to run the model.</li>
|
| 70 |
+
</ol>
|
| 71 |
+
</li>
|
| 72 |
+
<li><b>Team name must remain the same across all submissions.</b></li>
|
| 73 |
+
<li>The **trained dataset does not need to be public or open-sourced**, only the submitted model will be open-sourced after the competition.</li>
|
| 74 |
+
</ul>
|
| 75 |
+
<hr>
|
| 76 |
+
<h4>Sponsored & Organized By</h4>
|
| 77 |
<div style="display:flex; align-items:center; gap:20px;">
|
| 78 |
<div>
|
| 79 |
<a href="https://www.linkedin.com/company/68577545" target="_blank">
|
|
|
|
| 90 |
|
| 91 |
with gr.Tab("π Prizes"):
|
| 92 |
gr.Markdown("""
|
| 93 |
+
<h3 style="font-size:22px;">Prize Distribution</h3>
|
| 94 |
+
<ul style="font-size:18px;">
|
| 95 |
+
<li>1st Place: π₯ 250 USD (bank transfer or API credits)</li>
|
| 96 |
+
<li>2nd Place: π₯ 125 USD</li>
|
| 97 |
+
<li>3rd Place: π₯ 75 USD</li>
|
| 98 |
+
<li>4th Place: ποΈ 50 USD</li>
|
| 99 |
+
<li>5th Place: ποΈ 25 USD</li>
|
| 100 |
+
</ul>
|
| 101 |
""")
|
| 102 |
|
| 103 |
with gr.Tab("π Evaluation"):
|
| 104 |
gr.Markdown("""
|
| 105 |
+
<h3 style="font-size:22px;">Evaluation Details</h3>
|
| 106 |
+
<ul style="font-size:18px;">
|
| 107 |
+
<li>The evaluation dataset will remain **private**.</li>
|
| 108 |
+
<li>It will include:
|
| 109 |
+
<ul>
|
| 110 |
+
<li>Historical documents</li>
|
| 111 |
+
<li>Scanned pages</li>
|
| 112 |
+
<li>Different layouts</li>
|
| 113 |
+
<li>Handwritten pages</li>
|
| 114 |
+
</ul>
|
| 115 |
+
</li>
|
| 116 |
+
<li>Models will be evaluated on **accuracy metrics** such as WER, CER, and BLEU.</li>
|
| 117 |
+
</ul>
|
| 118 |
""")
|
| 119 |
|
| 120 |
with gr.Tab("π Submit & Leaderboard"):
|
| 121 |
+
gr.Markdown("<h3 style='font-size:22px;'>Submit Your Model</h3>")
|
| 122 |
with gr.Row():
|
| 123 |
+
team = gr.Textbox(label="Team Name", placeholder="Enter your team name")
|
| 124 |
+
email = gr.Textbox(label="Email", placeholder="Enter your email")
|
| 125 |
+
model = gr.Textbox(label="Model Name", placeholder="Enter your model name")
|
| 126 |
+
hf_model = gr.Textbox(label="Hugging Face Model ID", placeholder="Enter your HF Model ID")
|
| 127 |
+
hf_token = gr.Textbox(label="Hugging Face Access Token", type="password", placeholder="Enter your HF token")
|
| 128 |
code = gr.Textbox(label="Code (instructions to run your model)", lines=6, placeholder="Paste your run code here...")
|
| 129 |
|
| 130 |
submit_btn = gr.Button("Submit")
|
|
|
|
| 134 |
inputs=[team, email, model, hf_model, hf_token, code],
|
| 135 |
outputs=status)
|
| 136 |
|
| 137 |
+
gr.Markdown("<h3 style='font-size:22px;'>Leaderboard Results</h3>")
|
| 138 |
results = gr.Dataframe(headers=["model_name", "WER", "CER", "BLEU", "team_name"])
|
| 139 |
demo.load(fn=show_results, outputs=results)
|
| 140 |
|