Spaces:
Paused
Paused
File size: 6,558 Bytes
1d21e88 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """Private, results-only review page and independent landmark annotation UI."""
import json
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/research'
rows=json.loads((OUT/'mesh.json').read_text());selected=[r for r in rows if r['method']=='loftr_patch_mesh']
cards=[]
for row in selected:
n=row['sample'];base=f'{n}-loftr_patch_mesh'
cards.append(f'''<section><h2>Sample {n} · research candidate</h2><p>Automatic correspondence consistency: median {row['mesh_median']:.2f}px, 95th percentile {row['mesh_p95']:.2f}px ({row['test_count']} held-out automatic matches). These are not independently verified anatomical accuracy scores.</p><div class="grid"><figure><a href="../client_iris/{n}/reference.png"><img loading="lazy" src="../client_iris/{n}/reference.png"></a><figcaption>Reference</figcaption></figure><figure><a href="{base}/adjusted.png"><img loading="lazy" src="{base}/adjusted.png"></a><figcaption>Aligned second photograph, exposure adjusted</figcaption></figure><figure><a href="{base}/overlay.png"><img loading="lazy" src="{base}/overlay.png"></a><figcaption>Overlay — examine fibers, not glare</figcaption></figure></div><p><a href="{base}/aligned.png">Download aligned source before exposure adjustment</a></p></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>Iris research review</title><style>body{font:16px system-ui;background:#101a22;color:#e1ebef;max-width:1500px;margin:40px auto;padding:20px}p{line-height:1.7;color:#b7cad6}a{color:#7ddfc2}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:20px}figure{margin:0}img{width:100%}section{padding-top:25px;margin-top:40px;border-top:1px solid #43555e}@media(max-width:800px){.grid{grid-template-columns:1fr}}</style><h1>Real iris alignment — research iteration</h1><p>Five improved research candidates; sample 1 remains unresolved. No pair is independently accuracy-validated or accepted as a finished composite. Images are from the same six development pairs, not a separate validation set. Uncertain regions and reflection removal still need work.</p><p><a href="landmarks.html">Mark independent corresponding landmarks</a> · <a href="../client_iris/index.html">Original baseline report</a></p><h2>Sample 1 — unresolved</h2><p>The candidate still disagrees with the image evidence. It is not included as a successful result.</p>'''+''.join(cards)+'</html>')
(OUT/'landmarks.html').write_text(r'''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Independent iris landmarks</title><style>body{font:15px system-ui;background:#111b23;color:#e6edf1;padding:24px}p{line-height:1.6;max-width:1100px}button,select,input{padding:8px;margin:8px}.panes{display:grid;grid-template-columns:1fr 1fr;gap:20px}.pane{height:650px;overflow:auto;background:#000}.image{position:relative;width:1100px}.image img{width:100%;display:block}.dot{position:absolute;background:#f33;color:#fff;border:1px solid white;border-radius:50%;width:19px;height:19px;transform:translate(-50%,-50%);text-align:center;font-size:12px;pointer-events:none}a{color:#7fdec1}</style><h1>Mark matching real structures</h1><p>These are the two original crops, with no predicted alignment shown. Select a distinctive crypt corner or fiber junction in the reference (left), then the same point in the second original (right). Avoid glare, occluded regions, and vague edges. Spread at least 10–20 points around the iris. Coordinate uncertainty in your marking affects the reported error. Export each sample separately; selections are not sent to a server.</p><label>Sample <select id="sample">'''+''.join(f'<option>{i}</option>' for i in range(1,7))+'''</select></label><label>Display scale <select id="zoom"><option value="550">25%</option><option value="1100" selected>50%</option><option value="2200">100%</option></select></label><button id="undo">Undo last pair</button><button id="save">Download landmark JSON</button><p id="status"></p><div class="panes"><div><h2>Reference original</h2><div class="pane"><div class="image" id="left"><img id="ref"></div></div></div><div><h2>Second original</h2><div class="pane"><div class="image" id="right"><img id="mov"></div></div></div></div><p><a href="index.html">Back to review</a></p><script>
let pairs=[],pending=null,currentSample='1';
const sample=document.querySelector('#sample'),status=document.querySelector('#status');
function redraw(){document.querySelectorAll('.dot').forEach(e=>e.remove());for(const [i,p] of pairs.entries()){dot('left',p.reference,i+1);dot('right',p.moving,i+1);}if(pending)dot('left',pending,pairs.length+1);status.textContent=pairs.length+' completed pairs. '+(pending?'Click the same structure in the second original.':'Click a structure in the reference.');}
function dot(id,p,n){const el=document.createElement('span');el.className='dot';el.textContent=n;el.style.left=(p[0]/2200*100)+'%';el.style.top=(p[1]/2200*100)+'%';document.getElementById(id).appendChild(el);}
function load(){currentSample=sample.value;pairs=[];pending=null;document.querySelector('#ref').src='../client_iris/'+sample.value+'/reference.png';document.querySelector('#mov').src='../client_iris/'+sample.value+'/moving.png';redraw();}
for(const id of ['ref','mov'])document.getElementById(id).onclick=e=>{const r=e.target.getBoundingClientRect();const p=[(e.clientX-r.left)/r.width*2200,(e.clientY-r.top)/r.height*2200];if(id==='ref'){pending=p;}else if(pending){pairs.push({reference:pending,moving:p});pending=null;}redraw();};
sample.onchange=()=>{if(pairs.length && !confirm('Switch sample and clear unexported marks?')){sample.value=currentSample;return;}load();};
document.querySelector('#zoom').onchange=e=>document.querySelectorAll('.image').forEach(el=>el.style.width=e.target.value+'px');
document.querySelector('#undo').onclick=()=>{if(pending)pending=null;else pairs.pop();redraw();};
document.querySelector('#save').onclick=()=>{if(pending || pairs.length<6){alert('Complete at least six pairs before export.');return;}const blob=new Blob([JSON.stringify({sample:sample.value,coordinate_frame:'native_2200_crop',points:pairs},null,2)],{type:'application/json'});const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download='iris-landmarks-'+sample.value+'.json';a.click();setTimeout(()=>URL.revokeObjectURL(a.href),1000);};load();
</script></html>''')
print(OUT/'index.html')
|