Jahnavibh commited on
Commit
2d18dcc
Β·
1 Parent(s): 1e4b23a

Add CSS overrides to preserve original SR110 Vela results colors and prevent grey text interference

Browse files
Files changed (1) hide show
  1. app.py +41 -20
app.py CHANGED
@@ -106,7 +106,7 @@ def run_vela(model_file):
106
  ]
107
  if any(pat in vela_stdout for pat in unsupported_patterns):
108
  summary_html = (
109
- "<div style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
110
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
111
  "font-size:1.1em;text-align:left;font-weight:600;'>"
112
  "This model has unsupported layers and needs investigation based on layers.<br>"
@@ -139,32 +139,32 @@ def run_vela(model_file):
139
  return val.lstrip("= ").strip() if isinstance(val, str) else val
140
 
141
  summary_html = (
142
- "<div style='background:#1e1e2f;border-radius:18px;padding:18px 18px 12px 18px;"
143
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#eee;font-family:sans-serif;'>"
144
- "<h3 style='margin-top:0;margin-bottom:12px;font-size:1.35em;color:#00b0ff;text-align:left;'>Estimated Results on SR110</h3>"
145
  "<div style='display:flex;flex-wrap:wrap;gap:10px;justify-content:center;'>"
146
  # Card 1: Accelerator
147
- "<div style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
148
- "<div style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸš€ Accelerator</div>"
149
- f"<div style='margin-bottom:2px;'><span style='color:#ccc;'>Configuration:</span> <span style='color:#fff;font-weight:500'>{summary_dict.get('Accelerator configuration','-')}</span></div>"
150
- f"<div><span style='color:#ccc;'>Accelerator clock:</span> <span style='color:#fff;font-weight:500'>{summary_dict.get('Accelerator clock','-')}</span></div>"
151
  "</div>"
152
  # Card 2: Memory Usage
153
- "<div style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
154
- "<div style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸ’Ύ Memory Usage</div>"
155
- f"<div style='margin-bottom:2px;'><span style='color:#ccc;'>Total SRAM:</span> <span style='color:#fff;font-weight:500'>{summary_dict.get('Total SRAM used','-')}</span></div>"
156
- f"<div><span style='color:#ccc;'>Total On-chip Flash:</span> <span style='color:#fff;font-weight:500'>{summary_dict.get('Total On-chip Flash used','-')}</span></div>"
157
  "</div>"
158
  # Card 3: Operator Distribution
159
- "<div style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
160
- "<div style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸ“ˆ Operator Distribution</div>"
161
- f"<div style='margin-bottom:2px;'><span style='color:#ccc;'>CPU Operators:</span> <span style='color:#fff;font-weight:500'>{clean_ops(summary_dict.get('CPU operators','-'))}</span></div>"
162
- f"<div><span style='color:#ccc;'>NPU Operators:</span> <span style='color:#fff;font-weight:500'>{clean_ops(summary_dict.get('NPU operators','-'))}</span></div>"
163
  "</div>"
164
  # Card 4: Performance
165
- "<div style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
166
- "<div style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>⚑ Performance</div>"
167
- f"<div><span style='color:#ccc;'>Inference time:</span> <span style='color:#fff;font-weight:500'>{summary_dict.get('Inference time','-')}</span></div>"
168
  "</div>"
169
  "</div></div>"
170
  ) if summary_items else "<div style='color:red'>Summary info not found in log.</div>"
@@ -304,7 +304,7 @@ def compile_uploaded_model(model_file):
304
  """Compile uploaded model with Vela and return results"""
305
  if model_file is None:
306
  error_html = (
307
- "<div style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
308
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
309
  "font-size:1.1em;text-align:center;font-weight:600;'>"
310
  "No model file uploaded."
@@ -327,7 +327,7 @@ def compile_uploaded_model(model_file):
327
  )
328
  except Exception as e:
329
  error_html = (
330
- "<div style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
331
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
332
  "font-size:1.1em;text-align:center;font-weight:600;'>"
333
  f"Vela compilation failed: {str(e)}"
@@ -469,6 +469,27 @@ with gr.Blocks(
469
  .card-header * {
470
  color: white !important;
471
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  .example-grid {
473
  display: grid !important;
474
  grid-template-columns: 1fr !important;
 
106
  ]
107
  if any(pat in vela_stdout for pat in unsupported_patterns):
108
  summary_html = (
109
+ "<div class='sr110-results' style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
110
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
111
  "font-size:1.1em;text-align:left;font-weight:600;'>"
112
  "This model has unsupported layers and needs investigation based on layers.<br>"
 
139
  return val.lstrip("= ").strip() if isinstance(val, str) else val
140
 
141
  summary_html = (
142
+ "<div class='sr110-results' style='background:#1e1e2f;border-radius:18px;padding:18px 18px 12px 18px;"
143
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#eee;font-family:sans-serif;'>"
144
+ "<h3 class='sr110-title' style='margin-top:0;margin-bottom:12px;font-size:1.35em;color:#00b0ff;text-align:left;'>Estimated Results on SR110</h3>"
145
  "<div style='display:flex;flex-wrap:wrap;gap:10px;justify-content:center;'>"
146
  # Card 1: Accelerator
147
+ "<div class='sr110-card' style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
148
+ "<div class='sr110-title' style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸš€ Accelerator</div>"
149
+ f"<div style='margin-bottom:2px;'><span class='sr110-label' style='color:#ccc;'>Configuration:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{summary_dict.get('Accelerator configuration','-')}</span></div>"
150
+ f"<div><span class='sr110-label' style='color:#ccc;'>Accelerator clock:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{summary_dict.get('Accelerator clock','-')}</span></div>"
151
  "</div>"
152
  # Card 2: Memory Usage
153
+ "<div class='sr110-card' style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
154
+ "<div class='sr110-title' style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸ’Ύ Memory Usage</div>"
155
+ f"<div style='margin-bottom:2px;'><span class='sr110-label' style='color:#ccc;'>Total SRAM:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{summary_dict.get('Total SRAM used','-')}</span></div>"
156
+ f"<div><span class='sr110-label' style='color:#ccc;'>Total On-chip Flash:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{summary_dict.get('Total On-chip Flash used','-')}</span></div>"
157
  "</div>"
158
  # Card 3: Operator Distribution
159
+ "<div class='sr110-card' style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
160
+ "<div class='sr110-title' style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>πŸ“ˆ Operator Distribution</div>"
161
+ f"<div style='margin-bottom:2px;'><span class='sr110-label' style='color:#ccc;'>CPU Operators:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{clean_ops(summary_dict.get('CPU operators','-'))}</span></div>"
162
+ f"<div><span class='sr110-label' style='color:#ccc;'>NPU Operators:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{clean_ops(summary_dict.get('NPU operators','-'))}</span></div>"
163
  "</div>"
164
  # Card 4: Performance
165
+ "<div class='sr110-card' style='flex:1 1 170px;min-width:170px;max-width:180px;background:#23233a;border-radius:12px;padding:10px 10px 8px 10px;'>"
166
+ "<div class='sr110-title' style='font-size:1em;font-weight:520;margin-bottom:6px;color:#00b0ff;'>⚑ Performance</div>"
167
+ f"<div><span class='sr110-label' style='color:#ccc;'>Inference time:</span> <span class='sr110-value' style='color:#fff;font-weight:500'>{summary_dict.get('Inference time','-')}</span></div>"
168
  "</div>"
169
  "</div></div>"
170
  ) if summary_items else "<div style='color:red'>Summary info not found in log.</div>"
 
304
  """Compile uploaded model with Vela and return results"""
305
  if model_file is None:
306
  error_html = (
307
+ "<div class='sr110-results' style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
308
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
309
  "font-size:1.1em;text-align:center;font-weight:600;'>"
310
  "No model file uploaded."
 
327
  )
328
  except Exception as e:
329
  error_html = (
330
+ "<div class='sr110-results' style='background:#fff3f3;border-radius:14px;padding:24px 18px 18px 18px;"
331
  "max-width:430px;min-width:320px;width:100%;margin:auto;color:#d32f2f;font-family:sans-serif;"
332
  "font-size:1.1em;text-align:center;font-weight:600;'>"
333
  f"Vela compilation failed: {str(e)}"
 
469
  .card-header * {
470
  color: white !important;
471
  }
472
+ /* Override grey colors for SR110 Vela results section */
473
+ .sr110-results,
474
+ .sr110-results *,
475
+ .sr110-results h3,
476
+ .sr110-results div,
477
+ .sr110-results span {
478
+ color: inherit !important;
479
+ }
480
+ /* Preserve original colors for dark theme cards */
481
+ .sr110-results .sr110-card {
482
+ background: #23233a !important;
483
+ }
484
+ .sr110-results .sr110-title {
485
+ color: #00b0ff !important;
486
+ }
487
+ .sr110-results .sr110-label {
488
+ color: #ccc !important;
489
+ }
490
+ .sr110-results .sr110-value {
491
+ color: #fff !important;
492
+ }
493
  .example-grid {
494
  display: grid !important;
495
  grid-template-columns: 1fr !important;