68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
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 = """
|
|
<html>
|
|
<head>
|
|
<title>Seal Unwarp Verification Report</title>
|
|
<style>
|
|
body { font-family: sans-serif; margin: 20px; background: #f0f0f0; }
|
|
.section { background: white; padding: 20px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
|
.row { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
|
|
.col { flex: 1; }
|
|
img { max-width: 100%; border: 1px solid #ccc; }
|
|
.label { font-weight: bold; margin-bottom: 5px; color: #555; }
|
|
h1 { color: #333; }
|
|
h2 { border-bottom: 2px solid #333; padding-bottom: 5px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Seal Unwarp Verification Report</h1>
|
|
<p>Intermediate steps for seal detection and unwarping.</p>
|
|
"""
|
|
|
|
# Group by similarity in timestamp (they might not be identical)
|
|
# Actually, let's just show them in sequence.
|
|
|
|
html += '<div class="section"><h2>1. Full Page Detections</h2>'
|
|
for pf in full_pages:
|
|
html += f'<div class="row"><div class="col"><div class="label">{pf}</div><img src="{pf}"></div></div>'
|
|
html += '</div>'
|
|
|
|
html += '<div class="section"><h2>2. Seal Crops & Unwarps</h2>'
|
|
# 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 += '<div class="row">'
|
|
html += f'<div class="col"><div class="label">Step A: Seal Crop</div><img src="{crop}"></div>'
|
|
|
|
for u in matching_unwarps:
|
|
label = "Step B: 7:30 Unwarp" if "730" in u else "Step C: Smart Unwarp"
|
|
html += f'<div class="col"><div class="label">{label}</div><img src="{u}"></div>'
|
|
|
|
html += '</div>'
|
|
html += '</div>'
|
|
|
|
html += "</body></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()
|