villekuosmanen commited on
Commit
0359b8a
·
verified ·
1 Parent(s): 0e7a6b3

Leaderboard: small inline avatar via injected CSS (Gradio 6 strips img sizing)

Browse files
Files changed (2) hide show
  1. app.py +18 -0
  2. leaderboard.py +3 -6
app.py CHANGED
@@ -145,7 +145,24 @@ def _on_run(preset_label: str, custom: str):
145
  )
146
 
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  with gr.Blocks(title="armnet demo — evaluate a policy on real robots") as demo:
 
 
 
149
  gr.Markdown(
150
  "# armnet demo — evaluate a policy on real robots\n"
151
  "Pick or paste a policy, press **Run**, and watch **"
@@ -207,6 +224,7 @@ with gr.Blocks(title="armnet demo — evaluate a policy on real robots") as demo
207
  interactive=False,
208
  wrap=True,
209
  label="Leaderboard",
 
210
  )
211
 
212
  # Timers drive every session from the shared state (this keeps the demo
 
145
  )
146
 
147
 
148
+ # Gradio's Dataframe markdown strips <img> sizing attributes, so force a small,
149
+ # inline avatar next to the trainer name via CSS.
150
+ _CSS = """
151
+ #leaderboard-table img {
152
+ width: 20px !important;
153
+ height: 20px !important;
154
+ min-width: 20px !important;
155
+ border-radius: 50%;
156
+ display: inline-block;
157
+ vertical-align: middle;
158
+ margin: 0 4px 0 0 !important;
159
+ }
160
+ """
161
+
162
  with gr.Blocks(title="armnet demo — evaluate a policy on real robots") as demo:
163
+ # Inject CSS via a <style> element (Gradio 6 moved the Blocks `css=` arg to
164
+ # launch(), which the Space controls, so this is the portable way).
165
+ gr.HTML(f"<style>{_CSS}</style>")
166
  gr.Markdown(
167
  "# armnet demo — evaluate a policy on real robots\n"
168
  "Pick or paste a policy, press **Run**, and watch **"
 
224
  interactive=False,
225
  wrap=True,
226
  label="Leaderboard",
227
+ elem_id="leaderboard-table",
228
  )
229
 
230
  # Timers drive every session from the shared state (this keeps the demo
leaderboard.py CHANGED
@@ -159,12 +159,9 @@ class Leaderboard:
159
 
160
  def _row(self, e: Entry) -> list:
161
  avatar = self._avatar_url(e.username)
162
- pfp = (
163
- f'<img src="{avatar}" width="20" height="20" '
164
- f'style="border-radius:50%;vertical-align:middle;margin-right:4px">'
165
- if avatar
166
- else ""
167
- )
168
  trainer = f"{pfp}[{e.username}](https://huggingface.co/{e.username})"
169
  policy = f"[{e.repo_id}](https://huggingface.co/{e.repo_id})"
170
  if e.revision and e.revision != "unknown":
 
159
 
160
  def _row(self, e: Entry) -> list:
161
  avatar = self._avatar_url(e.username)
162
+ # Sizing/style is enforced via CSS (#leaderboard-table img) because
163
+ # Gradio's Dataframe markdown strips width/height/style off <img>.
164
+ pfp = f'<img src="{avatar}"> ' if avatar else ""
 
 
 
165
  trainer = f"{pfp}[{e.username}](https://huggingface.co/{e.username})"
166
  policy = f"[{e.repo_id}](https://huggingface.co/{e.repo_id})"
167
  if e.revision and e.revision != "unknown":