studyOverflow commited on
Commit
9e4df69
·
verified ·
1 Parent(s): 5781a78

fix: use CSS class with !important to force text visibility in aux info box

Browse files
Files changed (1) hide show
  1. app.py +27 -14
app.py CHANGED
@@ -228,10 +228,8 @@ def _render_mbench_a_aux(task: dict) -> str:
228
  """Render auxiliary HTML info based on task subset."""
229
  subset = task["subset"]
230
 
231
- # Shared style: visible on both light and dark themes
232
- box = 'style="background:#e8edf2;color:#1a1a1a;padding:12px;border-radius:8px;margin-bottom:12px;border:1px solid #c0c8d0"'
233
- label_style = 'style="margin:0 0 4px;color:#1a1a1a;font-weight:bold"'
234
- text_style = 'style="margin:0;color:#2a2a2a;font-size:14px;line-height:1.5"'
235
 
236
  # Camera motion info (shown for ALL subsets)
237
  motion = task.get("camera_motion", "left_then_right")
@@ -239,22 +237,21 @@ def _render_mbench_a_aux(task: dict) -> str:
239
  gif_url = _mbench_a_asset_hf_url(f"camera_diagrams/{motion}.gif")
240
  camera_html = (
241
  f'<div style="flex:0 0 200px">'
242
- f'<p {label_style}>🎬 预期相机运动</p>'
243
- f'<p style="margin:0 0 8px;color:#2a2a2a">{motion_desc}</p>'
244
- f'<img src="{gif_url}" style="width:180px;border-radius:4px;border:1px solid #aaa">'
245
  f'</div>'
246
  )
247
 
248
  if subset == "object":
249
- # Show mask overlay image from HF assets
250
  sample_id = task["sample_id"]
251
  mask_url = _mbench_a_asset_hf_url(f"mask_viz/{sample_id}.png")
252
  return (
253
  f'<div {box}>'
254
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
255
  f'<div style="flex:1;min-width:300px">'
256
- f'<p {label_style}>🎯 请关注画面中被标注(高亮)的物体</p>'
257
- f'<img src="{mask_url}" style="max-width:100%;max-height:280px;border-radius:4px;margin-top:8px;border:1px solid #aaa">'
258
  f'</div>'
259
  f'{camera_html}'
260
  f'</div></div>'
@@ -267,8 +264,8 @@ def _render_mbench_a_aux(task: dict) -> str:
267
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
268
  f'{camera_html}'
269
  f'<div style="flex:1;min-width:250px">'
270
- f'<p {label_style}>📝 场景描述</p>'
271
- f'<p {text_style}>{caption}</p>'
272
  f'</div>'
273
  f'</div></div>'
274
  )
@@ -278,7 +275,7 @@ def _render_mbench_a_aux(task: dict) -> str:
278
  f'<div {box}>'
279
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
280
  f'<div style="flex:1;min-width:250px">'
281
- f'<p {text_style}><b>👤 请关注视频中的人物</b>:观察人物离开画面再回来后,面部和外观是否保持一致。</p>'
282
  f'</div>'
283
  f'{camera_html}'
284
  f'</div></div>'
@@ -289,7 +286,7 @@ def _render_mbench_a_aux(task: dict) -> str:
289
  f'<div {box}>'
290
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
291
  f'<div style="flex:1;min-width:250px">'
292
- f'<p {text_style}><b>🏞️ 请关注整体场景</b>:观察相机转回来后,场景的布局、风格、光照是否保持一致。</p>'
293
  f'</div>'
294
  f'{camera_html}'
295
  f'</div></div>'
@@ -771,6 +768,22 @@ CUSTOM_CSS = """
771
  #prompt_box textarea { height: 300px !important; overflow-y: auto !important; }
772
  .video-pair { display: flex; gap: 12px; }
773
  .video-pair > div { flex: 1; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
774
  """
775
 
776
  with gr.Blocks(title="MBench 标注", theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
 
228
  """Render auxiliary HTML info based on task subset."""
229
  subset = task["subset"]
230
 
231
+ # Use CSS class for guaranteed visibility (Gradio themes can override inline styles)
232
+ box = 'class="aux-info-box"'
 
 
233
 
234
  # Camera motion info (shown for ALL subsets)
235
  motion = task.get("camera_motion", "left_then_right")
 
237
  gif_url = _mbench_a_asset_hf_url(f"camera_diagrams/{motion}.gif")
238
  camera_html = (
239
  f'<div style="flex:0 0 200px">'
240
+ f'<p><b>🎬 预期相机运动</b></p>'
241
+ f'<p style="margin:0 0 8px">{motion_desc}</p>'
242
+ f'<img src="{gif_url}" style="width:180px">'
243
  f'</div>'
244
  )
245
 
246
  if subset == "object":
 
247
  sample_id = task["sample_id"]
248
  mask_url = _mbench_a_asset_hf_url(f"mask_viz/{sample_id}.png")
249
  return (
250
  f'<div {box}>'
251
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
252
  f'<div style="flex:1;min-width:300px">'
253
+ f'<p><b>🎯 请关注画面中被标注(高亮)的物体</b></p>'
254
+ f'<img src="{mask_url}" style="max-width:100%;max-height:280px;margin-top:8px">'
255
  f'</div>'
256
  f'{camera_html}'
257
  f'</div></div>'
 
264
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
265
  f'{camera_html}'
266
  f'<div style="flex:1;min-width:250px">'
267
+ f'<p><b>📝 场景描述</b></p>'
268
+ f'<p style="font-size:14px;line-height:1.5">{caption}</p>'
269
  f'</div>'
270
  f'</div></div>'
271
  )
 
275
  f'<div {box}>'
276
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
277
  f'<div style="flex:1;min-width:250px">'
278
+ f'<p><b>👤 请关注视频中的人物</b>:观察人物离开画面再回来后,面部和外观是否保持一致。</p>'
279
  f'</div>'
280
  f'{camera_html}'
281
  f'</div></div>'
 
286
  f'<div {box}>'
287
  f'<div style="display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start">'
288
  f'<div style="flex:1;min-width:250px">'
289
+ f'<p><b>🏞️ 请关注整体场景</b>:观察相机转回来后,场景的布局、风格、光照是否保持一致。</p>'
290
  f'</div>'
291
  f'{camera_html}'
292
  f'</div></div>'
 
768
  #prompt_box textarea { height: 300px !important; overflow-y: auto !important; }
769
  .video-pair { display: flex; gap: 12px; }
770
  .video-pair > div { flex: 1; }
771
+ /* Force aux info box to be visible regardless of Gradio theme */
772
+ .aux-info-box {
773
+ background: #e3e8ef !important;
774
+ color: #111 !important;
775
+ padding: 14px !important;
776
+ border-radius: 8px !important;
777
+ margin-bottom: 12px !important;
778
+ border: 1px solid #b0b8c4 !important;
779
+ }
780
+ .aux-info-box * {
781
+ color: #111 !important;
782
+ }
783
+ .aux-info-box img {
784
+ border: 1px solid #999;
785
+ border-radius: 4px;
786
+ }
787
  """
788
 
789
  with gr.Blocks(title="MBench 标注", theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo: