Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,16 +111,12 @@ def compute_efficiency_ratio(df):
|
|
| 111 |
|
| 112 |
def generate_info_callout(ratio, scope_text):
|
| 113 |
"""
|
| 114 |
-
Returns
|
| 115 |
-
The callout uses a light green background, a small font, and
|
| 116 |
-
"💡 did you know: XXXx energy use difference between most and least efficient model in [scope_text]."
|
| 117 |
"""
|
| 118 |
return (
|
| 119 |
-
f'<div style="
|
| 120 |
-
f'
|
| 121 |
-
f' border-radius: 5px; font-size: 0.8em;">'
|
| 122 |
-
f' 💡 Did you know? There\'s a <strong>{ratio:,.1f}x</strong> energy use difference between the most and least efficient models in {scope_text}.'
|
| 123 |
-
f' </div>'
|
| 124 |
f'</div>'
|
| 125 |
)
|
| 126 |
|
|
@@ -295,20 +291,53 @@ with demo:
|
|
| 295 |
</div>
|
| 296 |
''')
|
| 297 |
|
| 298 |
-
# --- Logo
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
with gr.Tabs():
|
| 313 |
# --- Text Generation Tab (dropdowns side by side with task callout to the right) ---
|
| 314 |
with gr.TabItem("Text Generation 💬"):
|
|
|
|
| 111 |
|
| 112 |
def generate_info_callout(ratio, scope_text):
|
| 113 |
"""
|
| 114 |
+
Returns a "did you know" callout with a lightbulb emoji.
|
| 115 |
+
The callout uses a light green background, a small font, and is limited to a max-width of 250px.
|
|
|
|
| 116 |
"""
|
| 117 |
return (
|
| 118 |
+
f'<div style="max-width:250px; font-size:0.8em; background-color:#e6ffe6; padding:8px; border-radius:5px;">'
|
| 119 |
+
f'💡 did you know: <strong>{ratio:,.1f}x</strong> energy use difference between most and least efficient model in {scope_text}.'
|
|
|
|
|
|
|
|
|
|
| 120 |
f'</div>'
|
| 121 |
)
|
| 122 |
|
|
|
|
| 291 |
</div>
|
| 292 |
''')
|
| 293 |
|
| 294 |
+
# --- Global Header: Centered Logo with Global Callout Positioned to Its Right ---
|
| 295 |
+
<!-- We force the logo to be 300px wide and center it. The callout is positioned 160px to the right of the center. -->
|
| 296 |
+
{% raw %}
|
| 297 |
+
<div style="position: relative; width: 100%; text-align: center; margin-bottom: 20px;">
|
| 298 |
+
<img src="https://huggingface.co/spaces/AIEnergyScore/Leaderboard/resolve/main/logo.png"
|
| 299 |
+
alt="Logo"
|
| 300 |
+
style="width:300px; max-width:300px; height:auto; display: inline-block;">
|
| 301 |
+
<div style="position: absolute; top: 50%; left: calc(50% + 160px); transform: translateY(-50%);">
|
| 302 |
+
<!-- Insert the global callout HTML here -->
|
| 303 |
+
{global_callout_html}
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
{% endraw %}
|
| 307 |
+
<!-- We'll compute global_callout_html below and pass it into the template using gr.HTML(). -->
|
| 308 |
+
<!-- Instead, we'll do this in Python: -->
|
| 309 |
+
{% raw %}
|
| 310 |
+
<script>
|
| 311 |
+
// The following script block is just a placeholder. In Gradio we will generate the full HTML in Python.
|
| 312 |
+
</script>
|
| 313 |
+
{% endraw %}
|
| 314 |
+
|
| 315 |
+
<!-- For Gradio, we generate the combined HTML in Python -->
|
| 316 |
+
{% endraw %}
|
| 317 |
+
<!-- Generate the global header HTML with the computed callout -->
|
| 318 |
+
{% raw %}
|
| 319 |
+
<script>
|
| 320 |
+
</script>
|
| 321 |
+
{% endraw %}
|
| 322 |
+
<!-- We'll now use gr.HTML with f-string formatting: -->
|
| 323 |
+
{% raw %}
|
| 324 |
+
{% endraw %}
|
| 325 |
+
{# Compute the global callout HTML in Python #}
|
| 326 |
+
{% python %}
|
| 327 |
+
global_callout_html = get_global_callout()
|
| 328 |
+
{% endpython %}
|
| 329 |
+
{% raw %}
|
| 330 |
+
<div style="position: relative; width: 100%; text-align: center; margin-bottom: 20px;">
|
| 331 |
+
<img src="https://huggingface.co/spaces/AIEnergyScore/Leaderboard/resolve/main/logo.png"
|
| 332 |
+
alt="Logo"
|
| 333 |
+
style="width:300px; max-width:300px; height:auto; display: inline-block;">
|
| 334 |
+
<div style="position: absolute; top: 50%; left: calc(50% + 160px); transform: translateY(-50%);">
|
| 335 |
+
{global_callout_html}
|
| 336 |
+
</div>
|
| 337 |
+
</div>
|
| 338 |
+
{% endraw %}
|
| 339 |
+
|
| 340 |
+
<!-- --- Tabs for the different tasks --- -->
|
| 341 |
with gr.Tabs():
|
| 342 |
# --- Text Generation Tab (dropdowns side by side with task callout to the right) ---
|
| 343 |
with gr.TabItem("Text Generation 💬"):
|