Skip to content

Commit 48e1e63

Browse files
committed
Updated gui_benchmark.py
1 parent 8121b6e commit 48e1e63

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

examples/official/annotation_tool/benchmark/gui_benchmark.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def run(self):
418418
'success': True,
419419
'barcodes_detected': barcode_count,
420420
'barcodes_expected': len(task.expected_barcodes) if task.expected_barcodes else 0,
421+
'expected_values': list(task.expected_barcodes) if task.expected_barcodes else [],
421422
'detection_time_ms': detection_time_ms,
422423
'detected_data': detected_data,
423424
'validation': validation
@@ -502,6 +503,9 @@ class HTMLReportExporter:
502503
.benchmark-image-title { font-size: 0.95rem; font-weight: 600; color: #475569;
503504
margin: 18px 0 6px; padding-bottom: 4px;
504505
border-bottom: 1px solid #e2e8f0; }
506+
.expected-values { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px;
507+
background: #fff7ed; color: #9a3412; font-size: 0.86rem; }
508+
.expected-values strong { color: #7c2d12; }
505509
"""
506510

507511
@staticmethod
@@ -635,16 +639,28 @@ def export(results: Dict[str, List[Dict]], output_path: str, has_annotation: boo
635639
html += f' <li>Fastest: <strong>{esc(fastest_lib)}</strong> ({agg[fastest_lib]["total_time"]:.0f} ms total)</li>\n'
636640
html += ' </ul>\n</div>\n'
637641

638-
def render_image_section(fp: str) -> str:
642+
def render_image_section(fp: str, show_expected_values: bool = False) -> str:
639643
lib_map = file_results[fp]
640644
fname = Path(fp).name
641645
has_gt = any(r.get('validation') for r in lib_map.values())
646+
expected_values = []
647+
for result in lib_map.values():
648+
expected_values = result.get('expected_values') or []
649+
if expected_values:
650+
break
642651
gt_badge = (
643652
' <span style="font-size:0.78rem;font-weight:500;color:#16a34a;'
644653
'background:#d1fae5;padding:1px 7px;border-radius:10px;margin-left:4px;">GT</span>'
645654
if has_gt else ''
646655
)
647656
section_html = f'<h4 class="benchmark-image-title">{esc(fname)}{gt_badge}</h4>\n'
657+
if show_expected_values and expected_values:
658+
expected_html = ', '.join(esc(value) for value in expected_values)
659+
section_html += (
660+
'<div class="expected-values">'
661+
f'<strong>Expected:</strong> {expected_html}'
662+
'</div>\n'
663+
)
648664
section_html += '<div class="benchmark-table-wrap"><table class="benchmark-table">\n <thead><tr>'
649665
if has_gt:
650666
section_html += '<th>SDK</th><th>Found</th><th>Expected</th><th>Detected &#10003;</th><th>Rate</th><th>Precision</th><th>Time</th><th>Details</th>'
@@ -728,7 +744,7 @@ def render_image_section(fp: str) -> str:
728744
html += f' <summary>{esc(group_name)} ({len(group_files)})</summary>\n'
729745
html += ' <div class="benchmark-group-body">\n'
730746
for fp in group_files:
731-
html += render_image_section(fp)
747+
html += render_image_section(fp, show_expected_values=(group_name == 'Needs Review'))
732748
html += ' </div>\n'
733749
html += '</details>\n'
734750

0 commit comments

Comments
 (0)