import os import glob import re def generate_html(viz_dir="report_viz"): html_file = os.path.join(viz_dir, "index.html") # Sort files by timestamp files = sorted(os.listdir(viz_dir)) full_pages = [f for f in files if f.startswith("viz_")] crops = [f for f in files if "seal_crop_" in f] unwarps = [f for f in files if "seal_localized_" in f] html = """ Seal Unwarp Verification Report

Seal Unwarp Verification Report

Intermediate steps for seal detection and unwarping.

""" # Group by similarity in timestamp (they might not be identical) # Actually, let's just show them in sequence. html += '

1. Full Page Detections

' for pf in full_pages: html += f'
{pf}
' html += '
' html += '

2. Seal Crops & Unwarps

' # Match crops with unwarps by proximity in sorted list or timestamp extraction for crop in crops: ts = re.search(r"(\d+)", crop).group(1) # Find unwarps that happened shortly after this crop matching_unwarps = [u for u in unwarps if abs(int(re.search(r"(\d+)", u).group(1)) - int(ts)) < 2000] html += '
' html += f'
Step A: Seal Crop
' for u in matching_unwarps: label = "Step B: 7:30 Unwarp" if "730" in u else "Step C: Smart Unwarp" html += f'
{label}
' html += '
' html += '
' html += "" with open(html_file, "w", encoding="utf-8") as f: f.write(html) print(f"HTML report generated: {html_file}") if __name__ == "__main__": generate_html()