Spaces:
Paused
Paused
Download hf_workspace/scripts/create_learned_report.py from modventures/iris: direct link, hf CLI and curl.
- Browser
- Download file 7.11 kB
-
https://huggingface.co/spaces/modventures/iris/resolve/main/hf_workspace/scripts/create_learned_report.py
- Command line
-
hf download hf://spaces/modventures/iris/hf_workspace/scripts/create_learned_report.py
-
curl -L -o create_learned_report.py https://huggingface.co/spaces/modventures/iris/resolve/main/hf_workspace/scripts/create_learned_report.py
7.11 kB
| """Results-only PDF and full-resolution HTML for the integrated learned batch.""" | |
| import io,json | |
| from pathlib import Path | |
| from PIL import Image,ImageOps | |
| from reportlab.pdfgen import canvas | |
| from reportlab.lib import colors | |
| from reportlab.lib.utils import ImageReader | |
| from reportlab.platypus import Table,TableStyle,Paragraph | |
| from reportlab.lib.styles import ParagraphStyle | |
| ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/learned_batch' | |
| rows=json.loads((OUT/'results.json').read_text());by={r['sample']:r for r in rows} | |
| W,H=595.28,841.89;M=42 | |
| ink=colors.HexColor('#193540');teal=colors.HexColor('#087E80');gray=colors.HexColor('#526975') | |
| c=canvas.Canvas(str(OUT/'Real_Iris_Evaluation.pdf'),pagesize=(W,H));c.setTitle('Real Iris Evaluation - 23 September 2026');c.setAuthor('Iris Registration POC') | |
| style=ParagraphStyle('body',fontName='Helvetica',fontSize=10,leading=15,textColor=gray) | |
| def text(s,x,y,width=511,size=10): | |
| p=Paragraph(s,ParagraphStyle('p',parent=style,fontSize=size,leading=size*1.45));_,ht=p.wrap(width,H);p.drawOn(c,x,y-ht);return y-ht | |
| def title(s,x,y,size=15): | |
| c.setFont('Helvetica-Bold',size);c.setFillColor(ink);c.drawString(x,y,s) | |
| def page(name,number): | |
| c.setFillColor(teal);c.rect(0,H-8,W,8,fill=1,stroke=0) | |
| title('REAL CLIENT IRIS EVALUATION / 23 SEPTEMBER 2026',M,H-43,9) | |
| title(name,M,H-88,25) | |
| c.setStrokeColor(colors.HexColor('#D8E4E8'));c.line(M,47,W-M,47) | |
| text('PRELIMINARY RESULTS - NOT INDEPENDENTLY ACCURACY-VALIDATED',M,34,size=7) | |
| text(f'{number} / 4',W-65,34,width=30,size=8) | |
| def pic(path,x,top,size,caption): | |
| with Image.open(path) as im: | |
| im=ImageOps.contain(im.convert('RGB'),(1000,1000));buf=io.BytesIO();im.save(buf,format='JPEG',quality=93);buf.seek(0) | |
| c.drawImage(ImageReader(buf),x,top-size,width=size,height=size,preserveAspectRatio=True,anchor='c') | |
| text(caption,x,top-size-6,width=size,size=8) | |
| page('Measured consistency on six pairs',1) | |
| y=text('All six real pairs in the supplied folder were evaluated. Five produce alignment previews requiring review. Sample 1 remains unaligned and its reference is preserved.',M,H-113)-26 | |
| title('Automatic consistency within pixel tolerances',M,y,14);y-=18 | |
| values=[['Sample','Within 1 px','Within 2 px','Within 3 px','Within 5 px','Verified / proposed']] | |
| for row in rows: | |
| m=row['metrics'];e=m['evaluation'];p=e['within_px_percent'] | |
| values.append([row['sample']]+[f'{p[str(t)]:.2f}%' if p else 'N/A' for t in [1,2,3,5]]+[f"{m['verified_matches']} / {m.get('raw_matches',m['matches'])}"]) | |
| t=Table(values,colWidths=[43,77,77,77,77,160],rowHeights=[34]+[34]*6) | |
| t.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),ink),('TEXTCOLOR',(0,0),(-1,0),colors.white),('FONTNAME',(0,0),(-1,0),'Helvetica-Bold'),('FONTNAME',(0,1),(-1,-1),'Helvetica'),('FONTSIZE',(0,0),(-1,-1),9),('VALIGN',(0,0),(-1,-1),'MIDDLE'),('LEFTPADDING',(0,0),(-1,-1),7),('ROWBACKGROUNDS',(0,1),(-1,-1),[colors.white,colors.HexColor('#EFF5F6')])])) | |
| _,ht=t.wrap(511,H);t.drawOn(c,M,y-ht);y-=ht+26 | |
| for heading,body in [ | |
| ('What these percentages mean','Each percentage is the fraction of patch-verified automatic correspondences whose held-out prediction falls within the stated distance. Coordinates are measured in the 2200 x 2200 native-resolution iris crops. The 1, 2, 3 and 5 pixel columns expose the effect of tolerance; none is an agreed production acceptance threshold.'), | |
| ('What these percentages do not mean','These are not independently verified anatomical accuracy, whole-iris coverage, or a probability that a finished image is correct. Only a subset of proposed correspondences survived checking. All six pairs have been used during development; there is no separate unseen validation set. Client-finished images were not used as source pixels.'), | |
| ('Remaining limitations','Sample 1 has too little verified evidence to score. Sample 5 is below 95% consistency even at 5 pixels. Glare and occlusions remain, and the previews are not finished client composites. Independent landmark review and additional real test pairs are still required.')]: | |
| title(heading,M,y,12);y=text(body,M,y-12,size=9.5)-21 | |
| c.showPage() | |
| for page_no,samples in [(2,['2','3']),(3,['4','5']),(4,['6','1'])]: | |
| page('Alignment previews',page_no) | |
| y=H-139 | |
| for sample in samples: | |
| row=by[sample];m=row['metrics'];ok=m['status']!='unaligned' | |
| title('Sample '+sample+' / '+('Review required' if ok else 'Not aligned'),M,y,15) | |
| text(row['reference']+' + '+row['moving'],M,y-12,size=9) | |
| top=y-39;size=160 | |
| keys=[('reference','Reference original'),('adjusted','Aligned second image'),('overlay','Alignment overlay')] if ok else [('reference','Reference original'),('moving','Second original')] | |
| for i,(key,caption) in enumerate(keys):pic(OUT/sample/(key+'.png'),M+i*175,top,size,caption) | |
| bottom=top-size-34 | |
| text('Uses source-image detail only. Inspect fine structures at full resolution; reflections and uncertain regions still need review.' if ok else 'Insufficient verified correspondence. No generated replacement or unsupported merge is shown.',M,bottom,size=9) | |
| y-=315 | |
| c.showPage() | |
| c.save() | |
| headers=''.join('<th>'+s+'</th>' for s in values[0]);body=''.join('<tr>'+''.join('<td>'+str(v)+'</td>' for v in r)+'</tr>' for r in values[1:]) | |
| sections=[] | |
| for row in rows: | |
| n=row['sample'];ok=row['metrics']['status']!='unaligned';keys=['reference','adjusted','overlay','composite','local_confidence','contribution'] if ok else ['reference','moving'] | |
| panels=''.join(f'<figure><a href="{n}/{key}.png"><img loading="lazy" src="{n}/{key}.png"></a><figcaption>{key.replace("_"," ")}</figcaption></figure>' for key in keys) | |
| sections.append(f'<section><h2>Sample {n} — {"review required" if ok else "not aligned"}</h2><p>{row["reference"]} + {row["moving"]}</p><div class="grid">{panels}</div></section>') | |
| (OUT/'index.html').write_text('<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Real iris evaluation</title><style>body{font:16px system-ui;background:#101b22;color:#dfebef;max-width:1500px;margin:40px auto;padding:20px}p{line-height:1.6;color:#b7cbd6}a{color:#7fe1bf}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:20px}figure{margin:0}img{width:100%}th,td{padding:12px;border-bottom:1px solid #40545f}table{border-collapse:collapse}section{margin-top:50px}@media(max-width:800px){.grid{grid-template-columns:1fr}table{font-size:11px}th,td{padding:5px}}</style><h1>Real iris evaluation</h1><p>Six real pairs; five review previews; one unresolved. No independently validated anatomical accuracy claim. Percentages below measure held-out automatic correspondence consistency on the patch-verified subset. They do not describe whole-iris coverage. Sample 5 remains below 95% at 5 pixels; sample 1 is not measurable. All six are development pairs. Click images for native-resolution PNGs.</p><p><a href="Real_Iris_Evaluation.pdf">Download PDF</a> · <a href="../research/landmarks.html">Independent landmark review</a></p><table><thead><tr>'+headers+'</tr></thead><tbody>'+body+'</tbody></table>'+''.join(sections)+'</html>') | |
| print(OUT/'Real_Iris_Evaluation.pdf') | |