diff --git a/backend/experimental/segmentation.py b/backend/experimental/segmentation.py index d016102fd98e95c43148d2cc6f948e639b525653..d6f73f274bf03bfd5a772d460d8acab9a9313c13 100644 --- a/backend/experimental/segmentation.py +++ b/backend/experimental/segmentation.py @@ -16,6 +16,7 @@ class IrisGeometry: pupil_radius: float iris_radius: float boundary_support: float + limbus_detected: bool = True def to_dict(self): return asdict(self) @@ -24,7 +25,9 @@ class IrisGeometry: def detect_geometry(image): h, w = image.shape[:2] scale = min(1., 600 / max(h, w)) - gray = cv2.cvtColor(cv2.resize(image, (round(w*scale), round(h*scale))), cv2.COLOR_BGR2GRAY) + # Red-channel contrast separates blue pupil reflections from iris tissue better + # than luminance on these visible-light crops. This is an analysis copy only. + gray = cv2.resize(image, (round(w*scale), round(h*scale)))[:, :, 2] gray = cv2.GaussianBlur(gray, (7, 7), 1.5) sh, sw = gray.shape size = min(sh, sw) @@ -46,7 +49,7 @@ def detect_geometry(image): offset = np.hypot(cx-sw/2, cy-sh/2)/size if circularity > .78 and offset < .18: candidates.append((circularity-offset, cx, cy, np.sqrt(area/np.pi))) - circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, size*.15, param1=80, param2=30, + circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, size*.15, param1=40, param2=20, minRadius=round(size*.065), maxRadius=round(size*.20)) if circles is not None: angles = np.linspace(0, 2*np.pi, 180, endpoint=False) @@ -64,10 +67,14 @@ def detect_geometry(image): if not candidates: return None _, cx, cy, pupil = max(candidates) + # Pupil-only detection is useful even when the outer boundary is occluded. + # Explicitly report the assumed conservative outer radius; never use it as + # a measured limbus for radial-model evaluation. + fallback = IrisGeometry((float(cx/scale), float(cy/scale)), float(pupil/scale), min(h,w)*.4, 0., False) angles = np.linspace(0, 2*np.pi, 180, endpoint=False) radii = np.arange(max(pupil*1.7, size*.29), size*.49, .5) if len(radii) < 20: - return None + return fallback mx = (cx+np.cos(angles[:, None])*radii).astype(np.float32) my = (cy+np.sin(angles[:, None])*radii).astype(np.float32) profile = cv2.remap(gray.astype(np.float32), mx, my, cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT) @@ -78,11 +85,11 @@ def detect_geometry(image): boundaries = radii[peaks+4] valid = strength > 12 if valid.sum() < 90: - return None + return fallback outer = float(np.median(boundaries[valid])) support = float((valid & (np.abs(boundaries-outer) < size*.035)).mean()) if support < .60 or not 1.8 < outer/pupil < 6: - return None + return fallback return IrisGeometry((float(cx/scale), float(cy/scale)), float(pupil/scale), outer/scale, support) @@ -101,6 +108,7 @@ def geometry_overlay(image, geometry): out = image.copy() if geometry is not None: center = tuple(round(v) for v in geometry.center) - for radius in (geometry.pupil_radius, geometry.iris_radius): - cv2.circle(out, center, round(radius), (0, 255, 0), max(2, image.shape[0]//400)) + for radius, detected in ((geometry.pupil_radius, True), (geometry.iris_radius, geometry.limbus_detected)): + color = (0, 255, 0) if detected else (0, 165, 255) + cv2.circle(out, center, round(radius), color, max(2, image.shape[0]//400)) return out diff --git a/hf_workspace/.env.example b/hf_workspace/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..81af6c28c880f422d6de7d35274167e0d2386d1b --- /dev/null +++ b/hf_workspace/.env.example @@ -0,0 +1,12 @@ +# Experimental learned registration. Export these variables before starting Python. +# Merely copying this file does not load it; Docker can use --env-file. +# Defaults reproduce the existing pipeline. Restart the worker after changes. +IRIS_MATCHER=loftr +IRIS_MATCH_MAX_SIZE=800 +IRIS_PATCH_VALIDATION=single +IRIS_ADAPTIVE_MASK=false +# Optional absolute paths (omit to use the repository models/ directory): +# IRIS_MODEL_PATH=/app/models/loftr_outdoor.ckpt +# IRIS_WEIGHTS_DIR=/app/models +# Candidate options: max size 1024; patches geometry; matcher lightglue with 1600. +# Native flow and radial priors remain research-only pending evaluation. diff --git a/hf_workspace/backend/experimental/lightglue_matching.py b/hf_workspace/backend/experimental/lightglue_matching.py new file mode 100644 index 0000000000000000000000000000000000000000..423f708cd04a8a882ec750148b5f68f0c4d763f3 --- /dev/null +++ b/hf_workspace/backend/experimental/lightglue_matching.py @@ -0,0 +1,58 @@ +"""Offline ALIKED + LightGlue adapter using the already pinned Kornia dependency.""" +from pathlib import Path +import hashlib +import cv2 +import numpy as np +from .preprocessing import iris_mask, glare_mask + + +class LightGlueMatcher: + def __init__(self, weights_dir, max_size=1600, device='cpu'): + import torch + from kornia.feature import ALIKED, LightGlue + if not 400 <= max_size <= 2200: + raise ValueError('ALIKED resolution must be between 400 and 2200.') + self.torch, self.device, self.max_size = torch, device, max_size + for name, checksum in [('aliked-n16.pth', '5be8704840ed662d9d8c561bf7279c222092674e7eb05fd0feab94899e9d82f2'), ('aliked_lightglue.pth', 'd975e965b105311a6143194852297dff4f02aea5cc2e10cecfed966ca0e22503')]: + if hashlib.sha256((Path(weights_dir)/name).read_bytes()).hexdigest() != checksum: + raise RuntimeError(f'{name} failed checkpoint integrity verification.') + torch.set_num_threads(4) + self.extractor = ALIKED(max_num_keypoints=4096).eval().to(device) + state = torch.load(Path(weights_dir)/'aliked-n16.pth', map_location='cpu', weights_only=True) + # Kornia owns this deterministic grid buffer; the original checkpoint omits it. + state['dkd.hw_grid'] = self.extractor.state_dict()['dkd.hw_grid'] + self.extractor.load_state_dict(state, strict=True) + self.model = LightGlue(features=None, input_dim=128, depth_confidence=-1, width_confidence=-1).eval().to(device) + state = torch.load(Path(weights_dir)/'aliked_lightglue.pth', map_location='cpu', weights_only=True) + for i in range(9): + for old, new in ((f'self_attn.{i}', f'transformers.{i}.self_attn'), (f'cross_attn.{i}', f'transformers.{i}.cross_attn')): + state = {k.replace(old, new): v for k, v in state.items()} + state['confidence_thresholds'] = self.model.state_dict()['confidence_thresholds'] + self.model.load_state_dict(state, strict=True) + + def __call__(self, reference, moving, masks=None): + features, scales = [], [] + for index, im in enumerate((reference, moving)): + h, w = im.shape[:2] + factor = min(1., self.max_size/max(h, w)) + size = (max(32, int(w*factor)//32*32), max(32, int(h*factor)//32*32)) + gray = cv2.cvtColor(cv2.resize(im, size), cv2.COLOR_BGR2GRAY) + gray = cv2.createCLAHE(2, (12, 12)).apply(gray) + tensor = self.torch.from_numpy(gray.copy()).float()[None, None].to(self.device)/255 + scale = np.float32([w/size[0], h/size[1]]) + with self.torch.inference_mode(): + f = self.extractor(tensor)[0] + points = f.keypoints.cpu().numpy()*scale + mask = (iris_mask(im) if masks is None else masks[index]) & ~glare_mask(im) + xy = np.rint(points).astype(int) + valid = (xy[:, 0]>=0)&(xy[:, 0]=0)&(xy[:, 1] 0) & (np.sqrt(ux**2+uy**2+vx**2+vy**2) < .35) + safe &= (candidate[..., 0]>=0)&(candidate[..., 0]=0)&(candidate[..., 1] .25) + return (candidate if applied else mapping.copy()), dict(applied=applied, trusted_fraction=float(trusted.sum()/max(support.sum(), 1)), max_motion_px=float(np.linalg.norm(delta, axis=2)[support].max()) if support.any() else 0.) diff --git a/hf_workspace/backend/experimental/radial.py b/hf_workspace/backend/experimental/radial.py new file mode 100644 index 0000000000000000000000000000000000000000..4b1d6a784be3424943bfe735209e3dfe7c6b210e --- /dev/null +++ b/hf_workspace/backend/experimental/radial.py @@ -0,0 +1,53 @@ +"""A bounded pupil-centered radial residual prior, fitted only to training matches. + +The displacement peaks at the pupil boundary and falls to zero at the limbus. +Unlike biometric texture unwrapping, this changes coordinates only. It assumes +approximately circular boundaries and uniform radial strain; a mesh fits residuals. +""" +from dataclasses import dataclass +import cv2 +import numpy as np +from .mesh import basis, fit_mesh +from .evaluation import fit_geometry + + +def radial_vectors(points, matrix, geometry): + points = np.asarray(points, np.float32) + base = cv2.perspectiveTransform(points[None], np.linalg.inv(matrix))[0] + center = cv2.perspectiveTransform(np.float32([[geometry.center]]), np.linalg.inv(matrix))[0, 0] + radius = np.linalg.norm(points-np.float32(geometry.center), axis=1) + weight = np.where(radius < geometry.pupil_radius, + radius/geometry.pupil_radius, + np.clip((geometry.iris_radius-radius)/(geometry.iris_radius-geometry.pupil_radius), 0, 1)) + direction = base-center + direction /= np.maximum(np.linalg.norm(direction, axis=1, keepdims=True), 1e-6) + return direction*weight[:, None] + + +@dataclass +class RadialMesh: + matrix: np.ndarray + coefficients: np.ndarray + geometry: object + amplitude: float + shape: tuple + + def predict(self, points): + base = cv2.perspectiveTransform(np.float32(points)[None], np.linalg.inv(self.matrix))[0] + return base + self.amplitude*radial_vectors(points, self.matrix, self.geometry) + basis(points, self.shape) @ self.coefficients.reshape(-1, 2) + + +def fit_radial_mesh(reference_points, moving_points, shape, geometry): + matrix, _, _, _ = fit_geometry(reference_points, moving_points, shape) + base = cv2.perspectiveTransform(reference_points[None], np.linalg.inv(matrix))[0] + vectors = radial_vectors(reference_points, matrix, geometry) + residual = moving_points-base + weight = np.ones(len(vectors)) + amplitude = 0. + for _ in range(6): + amplitude = float(np.sum(weight[:, None]*vectors*residual)/(np.sum(weight[:, None]*vectors**2)+1)) + amplitude = float(np.clip(amplitude, -min(shape)*.04, min(shape)*.04)) + error = np.linalg.norm(residual-amplitude*vectors, axis=1) + weight = np.minimum(1, 3/np.maximum(error, 1e-6)) + coefficients = fit_mesh(reference_points, moving_points-amplitude*vectors, matrix, shape) + return RadialMesh(matrix, coefficients, geometry, amplitude, shape) diff --git a/hf_workspace/backend/experimental/segmentation.py b/hf_workspace/backend/experimental/segmentation.py new file mode 100644 index 0000000000000000000000000000000000000000..d6f73f274bf03bfd5a772d460d8acab9a9313c13 --- /dev/null +++ b/hf_workspace/backend/experimental/segmentation.py @@ -0,0 +1,114 @@ +"""Conservative circle hypotheses for centered crops; uncertain boundaries fail closed. + +This is an interpretable detector, not a trained eyelid/eyelash segmentation model. +Native masks exclude boundary margins and saturated reflections. Inspect overlays +before using its pupil geometry as a deformation prior. +""" +from dataclasses import asdict, dataclass +import cv2 +import numpy as np +from .preprocessing import glare_mask, iris_mask + + +@dataclass(frozen=True) +class IrisGeometry: + center: tuple[float, float] + pupil_radius: float + iris_radius: float + boundary_support: float + limbus_detected: bool = True + + def to_dict(self): + return asdict(self) + + +def detect_geometry(image): + h, w = image.shape[:2] + scale = min(1., 600 / max(h, w)) + # Red-channel contrast separates blue pupil reflections from iris tissue better + # than luminance on these visible-light crops. This is an analysis copy only. + gray = cv2.resize(image, (round(w*scale), round(h*scale)))[:, :, 2] + gray = cv2.GaussianBlur(gray, (7, 7), 1.5) + sh, sw = gray.shape + size = min(sh, sw) + yy, xx = np.indices(gray.shape) + central = np.hypot(xx-sw/2, yy-sh/2) < size*.22 + candidates = [] + # Search several levels: a fixed darkness threshold is unreliable across exposures. + for percentile in (5, 8, 12, 15, 25, 35, 45): + threshold = np.percentile(gray[central], percentile) + binary = (gray <= threshold).astype(np.uint8) + binary = cv2.morphologyEx(binary, cv2.MORPH_CLOSE, np.ones((7, 7), np.uint8)) + contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + for contour in contours: + area = cv2.contourArea(contour) + if not np.pi*(size*.065)**2 < area < np.pi*(size*.24)**2: + continue + (cx, cy), radius = cv2.minEnclosingCircle(contour) + circularity = area / max(np.pi*radius**2, 1) + offset = np.hypot(cx-sw/2, cy-sh/2)/size + if circularity > .78 and offset < .18: + candidates.append((circularity-offset, cx, cy, np.sqrt(area/np.pi))) + circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, size*.15, param1=40, param2=20, + minRadius=round(size*.065), maxRadius=round(size*.20)) + if circles is not None: + angles = np.linspace(0, 2*np.pi, 180, endpoint=False) + for cx, cy, radius in circles[0]: + offset = np.hypot(cx-sw/2, cy-sh/2)/size + if offset > .18: + continue + def sample(r): + return cv2.remap(gray.astype(np.float32), (cx+np.cos(angles)*r).astype(np.float32), + (cy+np.sin(angles)*r).astype(np.float32), cv2.INTER_LINEAR).ravel() + contrast = sample(radius*1.15)-sample(radius*.8) + boundary_support = float((contrast > 10).mean()) + if boundary_support > .7: + candidates.append((boundary_support-offset, float(cx), float(cy), float(radius))) + if not candidates: + return None + _, cx, cy, pupil = max(candidates) + # Pupil-only detection is useful even when the outer boundary is occluded. + # Explicitly report the assumed conservative outer radius; never use it as + # a measured limbus for radial-model evaluation. + fallback = IrisGeometry((float(cx/scale), float(cy/scale)), float(pupil/scale), min(h,w)*.4, 0., False) + angles = np.linspace(0, 2*np.pi, 180, endpoint=False) + radii = np.arange(max(pupil*1.7, size*.29), size*.49, .5) + if len(radii) < 20: + return fallback + mx = (cx+np.cos(angles[:, None])*radii).astype(np.float32) + my = (cy+np.sin(angles[:, None])*radii).astype(np.float32) + profile = cv2.remap(gray.astype(np.float32), mx, my, cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT) + # Limbus transitions toward brighter sclera; both contrast and angular support matter. + gradient = cv2.GaussianBlur(profile, (11, 1), 2)[:, 8:] - cv2.GaussianBlur(profile, (11, 1), 2)[:, :-8] + peaks = gradient.argmax(axis=1) + strength = gradient[np.arange(len(angles)), peaks] + boundaries = radii[peaks+4] + valid = strength > 12 + if valid.sum() < 90: + return fallback + outer = float(np.median(boundaries[valid])) + support = float((valid & (np.abs(boundaries-outer) < size*.035)).mean()) + if support < .60 or not 1.8 < outer/pupil < 6: + return fallback + return IrisGeometry((float(cx/scale), float(cy/scale)), float(pupil/scale), outer/scale, support) + + +def adaptive_mask(image, geometry=None): + geometry = detect_geometry(image) if geometry is None else geometry + if geometry is None: + return iris_mask(image) & ~glare_mask(image), None + y, x = np.indices(image.shape[:2], dtype=np.float32) + radius = np.hypot(x-geometry.center[0], y-geometry.center[1]) + margin = min(image.shape[:2])*.015 + mask = (radius > geometry.pupil_radius+margin) & (radius < geometry.iris_radius-margin) + return mask & ~glare_mask(image), geometry + + +def geometry_overlay(image, geometry): + out = image.copy() + if geometry is not None: + center = tuple(round(v) for v in geometry.center) + for radius, detected in ((geometry.pupil_radius, True), (geometry.iris_radius, geometry.limbus_detected)): + color = (0, 255, 0) if detected else (0, 165, 255) + cv2.circle(out, center, round(radius), color, max(2, image.shape[0]//400)) + return out diff --git a/hf_workspace/backend/experimental/settings.py b/hf_workspace/backend/experimental/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..a57f2c302451bae19240a0ccedd88218e682e8d7 --- /dev/null +++ b/hf_workspace/backend/experimental/settings.py @@ -0,0 +1,28 @@ +"""Validated server-side switches for controlled learned-engine experiments.""" +from dataclasses import dataclass +import os + + +@dataclass(frozen=True) +class LearnedSettings: + matcher: str = 'loftr' + max_size: int = 800 + patches: str = 'single' + adaptive_mask: bool = False + + @classmethod + def from_env(cls): + matcher = os.environ.get('IRIS_MATCHER', 'loftr') + patches = os.environ.get('IRIS_PATCH_VALIDATION', 'single') + adaptive = os.environ.get('IRIS_ADAPTIVE_MASK', 'false').lower() + try: + size = int(os.environ.get('IRIS_MATCH_MAX_SIZE', '800' if matcher=='loftr' else '1600')) + except ValueError as exc: + raise RuntimeError('IRIS_MATCH_MAX_SIZE must be an integer.') from exc + if matcher not in {'loftr', 'lightglue'} or patches not in {'single', 'multiscale', 'geometry'}: + raise RuntimeError('Invalid learned matcher or patch-validation configuration.') + if adaptive not in {'true', 'false'}: + raise RuntimeError('IRIS_ADAPTIVE_MASK must be true or false.') + if not 400 <= size <= (1200 if matcher=='loftr' else 2200): + raise RuntimeError('IRIS_MATCH_MAX_SIZE exceeds the supported range.') + return cls(matcher, size, patches, adaptive=='true') diff --git a/hf_workspace/hf_workspace/PRODUCTION_READINESS.md b/hf_workspace/hf_workspace/PRODUCTION_READINESS.md new file mode 100644 index 0000000000000000000000000000000000000000..d1e7716a6dde1c11c530b68fb585cd661ddb05be --- /dev/null +++ b/hf_workspace/hf_workspace/PRODUCTION_READINESS.md @@ -0,0 +1,25 @@ +# Production readiness: remaining acceptance gates + +## Implemented in this iteration + +Valid uploaded pairs produce a review response even if geometric alignment fails. Failed registration preserves both originals, reports the reason, offers next steps, and does not invent an aligned composite. Match support is explicitly defined, with null when not measurable. Successful numerical registration still requires visual review. Malformed uploads and service failures remain errors; the UI does not conceal them as results. + +## Priority 1: establish the meaning of quality + +Use independently marked matching fibers/crypts to measure median and tail landmark error on the real photographs, along with valid iris coverage and deformation limits. Establish acceptable thresholds with the client at native resolution. Separate development pairs from a new held-out real test set. Calibration must precede any confidence percentage or automatic “ready” label. Neither inlier percentage nor agreement with the matcher's own predictions establishes anatomical correctness. + +## Priority 2: usable alignment workflow + +Add iris/pupil/eyelid/glare masking with corrections. Promote the experimental ML matcher only behind an explicit reviewed mode and the validated acceptance gates. Provide manual landmarks for difficult pairs; never force an unsupported warp. Keep matching features separate from source pixels, and only borrow glare-free source regions after adjacent geometry is verified. Save the composed transformation, source contribution masks and versioned settings with each result. The experimental model is now an opt-in API mode for confirmed centered square crops; it is not a production-approved or full-frame pipeline. + +## Priority 3: service and deployment + +Complete VM Docker and Vercel configuration, explicit backend HTTPS URL and exact allowed frontend origins. No VM or Vercel domains have been supplied yet. Move processing from long HTTP requests and base64-heavy responses to a bounded worker queue, job-status endpoints and private downloadable artifacts. Add job timeout/cancellation/retry semantics, memory limits, request limits, and health monitoring. Separate invalid input, alignment rejection and infrastructure failure in the API and telemetry. + +For CPU-heavy jobs, FastAPI's [background-task guidance](https://fastapi.tiangolo.com/tutorial/background-tasks/#caveat) describes when a separate worker system such as Celery is appropriate. Its [deployment concepts](https://fastapi.tiangolo.com/deployment/concepts/) cover HTTPS, restarts, worker replication and memory. The current app has not implemented these production facilities. + +## Priority 4: client data and release checks + +Add authentication, per-user access to results, private upload storage and defined deletion/retention. Load-test the largest supported images and concurrent jobs on the intended VM. Keep customer samples and research artifacts out of public static assets and container build context. Pin/version model weights and transformations. Establish rollback and regression tests on an approved real-image validation set. + +Production release remains blocked on real-data accuracy and these operational requirements. Better error presentation alone does not make the registration engine production-ready. diff --git a/hf_workspace/hf_workspace/RESEARCH.md b/hf_workspace/hf_workspace/RESEARCH.md new file mode 100644 index 0000000000000000000000000000000000000000..5fe1a17d53f6ae13e4577883e5f2c1f95662c655 --- /dev/null +++ b/hf_workspace/hf_workspace/RESEARCH.md @@ -0,0 +1,50 @@ +# Real-iris research iteration + +The learned pipeline is now available as an explicit experimental FastAPI/UI option. Standard mode still runs the original baseline. Experimental mode requires equally sized, centered square iris crops (400–3000px) and a confirmation checkbox. It is not an automatic full-frame iris detector. No production success or real-image subpixel accuracy is claimed. + +## Findings + +The original input handling included non-iris regions and had weak sensitivity for the actual iris detail. Manually centered iris masks and correspondence-only illumination normalization increased useful classical matches on five pairs. A learned matcher supplies broad initial correspondences on all six, but native patch checks reject most proposals on sample 1. A larger match count is not a correctness metric. + +Five pairs (2–6) now have research alignment candidates after patch verification and a regularized smooth mesh. Sample 1 remains rejected. The candidate gate (median automatic held-out disagreement under 4 px, p95 under 12 px and over 99% geometric validity in the approximate iris region) is an exploratory screening threshold, **not** the client's acceptance standard and not the synthetic subpixel threshold. Glare removal, independent landmark accuracy, automatic iris segmentation and finished composites remain unresolved. The mesh version deliberately outputs alignment diagnostics rather than an unvalidated blended result. + +Every experiment uses the same six development pairs; there is no untouched external validation set. Spatially held-out automatic matches are excluded from geometric fitting, but remain fallible model/patch labels from these images. The dense-flow experiment also sees the image areas containing held-out points; the metric is correspondence consistency, not independent test-image accuracy. We did not claim these measurements as anatomical ground truth. + +## Reproduce + +```sh +.venv/bin/pip install -r requirements-ml.txt +mkdir -p models +curl -fL https://huggingface.co/kornia/loftr/resolve/main/loftr_outdoor.ckpt -o models/loftr_outdoor.ckpt +.venv/bin/python scripts/evaluate_matchers.py +.venv/bin/python scripts/validate_matcher_patches.py +.venv/bin/python scripts/refine_client_research.py +.venv/bin/python scripts/evaluate_mesh.py +.venv/bin/python scripts/create_research_review.py +``` + +Requires native 2200px crops produced by `scripts/benchmark_client.py`. The annular mask assumes these manually centered square crops; it is not a general eye detector and should not be applied directly to arbitrary full-frame uploads. Masks and grayscale normalization are correspondence inputs only. Aligned outputs are sampled from the source color image once. The adjusted preview has a scalar exposure lift, and the raw aligned PNG is also retained. The original manual finished images never enter matching or transformation fitting. + +Model: [Kornia LoFTR official weights](https://huggingface.co/kornia/loftr), outdoor checkpoint (MIT model card). LoFTR was trained on general scene data, not these iris images. Evaluated locally on CPU; no client images were sent to an external inference service. Downloaded checkpoint SHA-256: `21f5bec5968178e8bc8b7633441836fe5de4f47d861dd2cd7dc38e271b0479ec`. Verify this hash to reproduce the evaluated weights because the download URL uses a moving main revision. Torch loads the checkpoint using `weights_only=True`. + +Private artifacts are in `private_benchmarks/research/`, excluded from git and outside the public benchmark static mount. Each matcher has separate cached correspondences and each experiment separate outputs. Original baseline artifacts are preserved. Do not publish the private directory as part of the VM deployment. + +## Review before promotion + +Open `private_benchmarks/research/index.html` for aligned images. `landmarks.html` shows only the two original crops, permitting a reviewer to mark distinctive corresponding structures without a predicted alignment overlay. Export one JSON per sample, then run: + +```sh +.venv/bin/python scripts/score_landmarks.py /path/to/iris-landmarks-2.json +``` + +This reports errors against human annotations, which have their own marking uncertainty. Spread 10–20 points around the iris and mark only visible, unambiguous structures. Do not use these evaluation annotations to refit the transform and then call the result independent validation. Review rejected and uncertain regions as well as good-looking crops. + +Next decisions: validate geometry on real landmarks, add explicit iris/eyelid/pupil/glare masks and a manual correction path for sample 1, then implement source selection for glare using verified neighboring geometry. Expand to new real pairs before deployment claims. Optional human landmark assistance is preferable to forcing an uncertain automated warp. + +## Integrated evaluation and UI (23 September) + +`backend/learned_registration.py` reuses the correspondence, native-patch and mesh modules. It evaluates spatially held-out automatic correspondences over five folds before fitting the final preview to the verified points. The preview gate remains exploratory (median under 4px and p95 under 12px, at least 60 verified points, geometry/coverage checks); it does not assert 95% accuracy. Reported percentages at 1/2/3/5px are automatic consistency on the patch-verified subset. Sample 1 has 29 verified matches and is not measurable; sample 5 is 93.93% within 5px. All six remain development data. + +Run `scripts/evaluate_all_pairs.py` to inventory originals separately from Photoshop references and evaluate cached correspondences. `--recompute-matches` reruns inference. Run `scripts/run_learned_batch.py` to exercise the same path as the API, then `scripts/create_learned_report.py` for the results-only PDF/HTML in `private_benchmarks/learned_batch`. The model is loaded lazily and its SHA-256 checked; `IRIS_MODEL_PATH` optionally overrides the checkpoint location. The API limits computation to one in-flight pair per process and returns 503/Retry-After when busy; this is not a persistent job queue. + +Accepted experimental previews export inverse-map metadata (global matrix, reference shape and residual mesh coefficients) for reproduction. They resample original RGB pixels once and restrict blending to geometry-valid, supported iris regions outside detected glare. This does not solve reflection removal or segmentation; rejected pairs return original images only. diff --git a/hf_workspace/hf_workspace/backend/experimental/__init__.py b/hf_workspace/hf_workspace/backend/experimental/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..74e6d1b737d62f1a85b256500b820c2d6dc4ecd4 --- /dev/null +++ b/hf_workspace/hf_workspace/backend/experimental/__init__.py @@ -0,0 +1 @@ +"""Research pipelines; not enabled in the production API.""" diff --git a/hf_workspace/hf_workspace/backend/experimental/evaluation.py b/hf_workspace/hf_workspace/backend/experimental/evaluation.py new file mode 100644 index 0000000000000000000000000000000000000000..1ccec7741eaaceb7903db121e88d31f67b657e48 --- /dev/null +++ b/hf_workspace/hf_workspace/backend/experimental/evaluation.py @@ -0,0 +1,58 @@ +"""Spatial cross-validation of automatic correspondences, not anatomical ground truth.""" +import cv2 +import numpy as np +from .mesh import fit_mesh, basis + + +def fit_geometry(reference_points, moving_points, shape, ransac_threshold=4): + if len(reference_points) < 24: + raise ValueError('At least 24 verified correspondences are needed for geometry fitting.') + matrix, inliers = cv2.findHomography(moving_points, reference_points, cv2.USAC_MAGSAC, ransac_threshold) + if matrix is None or inliers is None or not np.isfinite(matrix).all() or inliers.sum() < 12 or inliers.mean() < .3: + raise ValueError('Correspondences do not support stable geometry.') + h,w=shape + corners=np.float32([[0,0],[w,0],[w,h],[0,h]]) + denominator=(matrix @ np.c_[corners,np.ones(4)].T)[2] + projected=cv2.perspectiveTransform(corners[None],matrix)[0] + if np.any(denominator<=0) or not .5.7 + for index,(im,p) in enumerate([(reference,a),(moving,b)]): + mask=(iris_mask(im) if masks is None else masks[index])&~glare_mask(im) + x=np.clip(p[:,0].astype(int),0,im.shape[1]-1);y=np.clip(p[:,1].astype(int),0,im.shape[0]-1) + keep &= mask[y,x] + return a[keep],b[keep] diff --git a/hf_workspace/hf_workspace/backend/experimental/mesh.py b/hf_workspace/hf_workspace/backend/experimental/mesh.py new file mode 100644 index 0000000000000000000000000000000000000000..88a169d8b0b78f2b87a614f2117a6fa1f056de8e --- /dev/null +++ b/hf_workspace/hf_workspace/backend/experimental/mesh.py @@ -0,0 +1,75 @@ +"""Regularized bilinear correspondence mesh with robust residual fitting. + +Fits training correspondences only. Callers must validate held-out matches and +inspect image detail; estimated matches are not anatomical ground truth. +""" +import cv2 +import numpy as np + + +def basis(points,shape,side=9): + h,w=shape + q=points/np.float32([w-1,h-1])*(side-1) + q=np.clip(q,0,side-1) + ix=np.minimum(np.floor(q).astype(int),side-2);frac=q-ix + a=np.zeros((len(points),side*side),np.float64) + for dy,dx in [(0,0),(0,1),(1,0),(1,1)]: + weight=(frac[:,0] if dx else 1-frac[:,0])*(frac[:,1] if dy else 1-frac[:,1]) + a[np.arange(len(points)),(ix[:,1]+dy)*side+ix[:,0]+dx]=weight + return a + + +def fit_mesh(reference_points,moving_points,homography,shape,side=9): + if len(reference_points)<24:raise ValueError('Too few mesh constraints') + inverse=np.linalg.inv(homography) + prediction=cv2.perspectiveTransform(reference_points[None],inverse)[0] + residual=moving_points-prediction + a=basis(reference_points,shape,side) + # Penalize second differences, favoring smooth local motion over isolated bends. + penalties=[] + for y in range(side): + for x in range(side): + for dy,dx in [(0,1),(1,0)]: + if y+2*dy0)&np.isfinite(full_jac)&(mx>=0)&(mx=0)&(my.65)&(jac<1.5)&(strain<.45) + return np.stack([mx,my],-1),good,delta diff --git a/hf_workspace/hf_workspace/backend/experimental/patch_validation.py b/hf_workspace/hf_workspace/backend/experimental/patch_validation.py new file mode 100644 index 0000000000000000000000000000000000000000..c47e028238c944e52f919d02ae45a070a2ff468b --- /dev/null +++ b/hf_workspace/hf_workspace/backend/experimental/patch_validation.py @@ -0,0 +1,56 @@ +"""Validate coarse correspondences against native-resolution image patches.""" +import cv2 +import numpy as np +from .preprocessing import normalize + + +def validate_patches(reference,moving,ref_points,mov_points,multiscale=False): + a,b=normalize(reference),normalize(moving) + p=ref_points.astype(np.float32).reshape(-1,1,2) + guess=mov_points.astype(np.float32).reshape(-1,1,2) + if len(p)==0:return ref_points,mov_points + args=dict(winSize=(41,41),maxLevel=2,criteria=(cv2.TERM_CRITERIA_EPS|cv2.TERM_CRITERIA_COUNT,50,.005),flags=cv2.OPTFLOW_USE_INITIAL_FLOW) + q,ok,_=cv2.calcOpticalFlowPyrLK(a,b,p,guess.copy(),**args) + reverse,back,_=cv2.calcOpticalFlowPyrLK(b,a,q,p.copy(),**args) + fb=np.linalg.norm(reverse[:,0]-p[:,0],axis=1) + shift=np.linalg.norm(q[:,0]-guess[:,0],axis=1) + keep=ok.ravel().astype(bool)&back.ravel().astype(bool)&(fb<1)&(shift<12) + h,w=b.shape + margin=32 if multiscale else 25 + keep &= np.isfinite(q[:,0]).all(axis=1)&np.isfinite(reverse[:,0]).all(axis=1) + keep &= (q[:,0,0]>margin)&(q[:,0,0]margin)&(q[:,0,1]margin)&(p[:,0,0]margin)&(p[:,0,1].65 and min(scores)>(.4 if multiscale else .65) + return p[keep,0],q[keep,0] + + +def validate_geometry_patches(reference, moving, ref_points, mov_points, multiscale=True): + """Validate in a common viewpoint, then return original moving coordinates. + + Translation-only patches can reject correct matches after camera rotation. + This warp is an analysis copy, never a source for the delivered color image. + """ + from .evaluation import fit_geometry + try: + # Coarse matches initialize an analysis copy only. Final fitting retains + # its 4px RANSAC threshold and unchanged held-out/geometry gates. + matrix, _, _, _ = fit_geometry(ref_points, mov_points, reference.shape[:2], ransac_threshold=12) + except (ValueError, cv2.error, np.linalg.LinAlgError): + return np.empty((0, 2), np.float32), np.empty((0, 2), np.float32) + h, w = reference.shape[:2] + analysis_image = cv2.warpPerspective(moving, matrix, (w, h)) + guesses = cv2.perspectiveTransform(mov_points[None], matrix)[0] + a, b = validate_patches(reference, analysis_image, ref_points, guesses, multiscale=multiscale) + if not len(a): + return a, b + b = cv2.perspectiveTransform(b[None], np.linalg.inv(matrix))[0] + valid = np.isfinite(b).all(axis=1)&(b[:, 0]>32)&(b[:, 0]32)&(b[:, 1].16)&(radius<.40) + + +def glare_mask(image): + # Saturated near-white highlights; ordinary bright colored fibers are retained. + bright=(np.min(image,axis=2)>190)&(np.max(image,axis=2)>240) + size=max(3,round(min(image.shape[:2])*.009)) + return cv2.dilate(bright.astype(np.uint8),np.ones((size,size),np.uint8)).astype(bool) + + +def normalize(image): + gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY).astype(np.float32) + mean=cv2.GaussianBlur(gray,(0,0),7) + variance=cv2.GaussianBlur((gray-mean)**2,(0,0),7) + return np.clip(128+32*(gray-mean)/np.sqrt(variance+20),0,255).astype(np.uint8) diff --git a/hf_workspace/hf_workspace/backend/experimental/refinement.py b/hf_workspace/hf_workspace/backend/experimental/refinement.py new file mode 100644 index 0000000000000000000000000000000000000000..d7ba0e75a1cb8dc37845087b93329663ba28865d --- /dev/null +++ b/hf_workspace/hf_workspace/backend/experimental/refinement.py @@ -0,0 +1,38 @@ +"""Iris-only local refinement with illumination-normalized correspondence copies.""" +import cv2 +import numpy as np +from .preprocessing import iris_mask,glare_mask,normalize + + +def local_map(reference,moving,homography): + h,w=reference.shape[:2] + factor=min(1,1200/max(h,w));size=(round(w*factor),round(h*factor)) + global_image=cv2.warpPerspective(moving,homography,(w,h)) + a=cv2.resize(reference,size);b=cv2.resize(global_image,size) + na,nb=normalize(a),normalize(b) + valid=iris_mask(a)&~glare_mask(a)&~glare_mask(b) + def flow(x,y):return cv2.calcOpticalFlowFarneback(x,y,None,.5,5,35,6,7,1.5,0) + f=cv2.GaussianBlur(flow(na,nb),(0,0),2) + rev=flow(nb,na) + yy,xx=np.indices(na.shape,dtype=np.float32) + mx,my=xx+f[...,0],yy+f[...,1] + fb=np.linalg.norm(f+cv2.remap(rev,mx,my,cv2.INTER_LINEAR),axis=2) + uy,ux=np.gradient(f[...,0]);vy,vx=np.gradient(f[...,1]);jac=(1+ux)*(1+vy)-uy*vx + strain=np.sqrt(ux**2+uy**2+vx**2+vy**2) + aligned=cv2.remap(nb,mx,my,cv2.INTER_LINEAR) + err0=cv2.GaussianBlur(cv2.absdiff(na,nb).astype(np.float32),(0,0),2) + err1=cv2.GaussianBlur(cv2.absdiff(na,aligned).astype(np.float32),(0,0),2) + sampling_valid=cv2.remap(valid.astype(np.uint8),mx,my,cv2.INTER_NEAREST)>0 + trust=valid&sampling_valid&(fb<1)&(np.linalg.norm(f,axis=2)<18)&(jac>.65)&(jac<1.5)&(strain<.45)&(err1<18)&(err1<=err0+1) + trust=cv2.erode(trust.astype(np.uint8),np.ones((5,5),np.uint8)).astype(bool) + fraction=float(trust.sum()/max(valid.sum(),1)) + improvement=float(1-err1[trust].mean()/max(err0[trust].mean(),.01)) if trust.any() else 0 + # The same support and improvement gates as the original local stage. + apply=fraction>.45 and improvement>.15 + full=cv2.resize(f,(w,h))/factor if apply else np.zeros((h,w,2),np.float32) + trusted=cv2.resize(trust.astype(np.uint8),(w,h),interpolation=cv2.INTER_NEAREST).astype(bool) + y,x=np.indices((h,w),dtype=np.float32);x+=full[...,0];y+=full[...,1] + inv=np.linalg.inv(homography);den=inv[2,0]*x+inv[2,1]*y+inv[2,2] + mapx=((inv[0,0]*x+inv[0,1]*y+inv[0,2])/den).astype(np.float32) + mapy=((inv[1,0]*x+inv[1,1]*y+inv[1,2])/den).astype(np.float32) + return np.stack([mapx,mapy],-1),trusted,dict(applied=apply,trusted_iris_fraction=fraction,improvement=improvement),global_image diff --git a/hf_workspace/hf_workspace/backend/learned_registration.py b/hf_workspace/hf_workspace/backend/learned_registration.py new file mode 100644 index 0000000000000000000000000000000000000000..4c721dbb180a95a6873c9350c7efbda957c06e64 --- /dev/null +++ b/hf_workspace/hf_workspace/backend/learned_registration.py @@ -0,0 +1,91 @@ +"""Opt-in learned registration for explicitly confirmed, centered square iris crops.""" +import hashlib +import os +import time +from functools import lru_cache +from pathlib import Path +import cv2 +import numpy as np +from .common import RegistrationError +from .compositing import compose +from .experimental.matching import LearnedMatcher +from .experimental.patch_validation import validate_patches,validate_geometry_patches +from .experimental.settings import LearnedSettings +from .experimental.segmentation import adaptive_mask,geometry_overlay +from .experimental.preprocessing import iris_mask,glare_mask +from .experimental.evaluation import evaluate_correspondences,fit_geometry +from .experimental.mesh import dense_mesh + + +@lru_cache(maxsize=1) +def get_matcher(): + settings=LearnedSettings.from_env() + if settings.matcher=='lightglue': + try: + from .experimental.lightglue_matching import LightGlueMatcher + return LightGlueMatcher(os.environ.get('IRIS_WEIGHTS_DIR',str(Path(__file__).resolve().parents[1]/'models')),max_size=settings.max_size) + except (ImportError,FileNotFoundError) as exc: + raise RuntimeError('LightGlue dependencies or offline weights are not installed.') from exc + path=Path(os.environ.get('IRIS_MODEL_PATH',str(Path(__file__).resolve().parents[1]/'models/loftr_outdoor.ckpt'))) + if not path.is_file():raise RuntimeError('Learned matcher weights are not installed on this server.') + if hashlib.sha256(path.read_bytes()).hexdigest()!='21f5bec5968178e8bc8b7633441836fe5de4f47d861dd2cd7dc38e271b0479ec': + raise RuntimeError('Learned matcher checkpoint failed integrity verification.') + try:return LearnedMatcher(path,max_size=settings.max_size) + except ImportError as exc:raise RuntimeError('Learned matcher dependencies are not installed.') from exc + + +def register_learned(reference,moving,exposure=True,local=True): + started=time.perf_counter() + if not local:raise RegistrationError("The experimental learned engine requires local refinement.") + h,w=reference.shape[:2] + if reference.shape!=moving.shape or h!=w or not 400<=w<=3000: + raise RegistrationError('Experimental alignment needs equally sized, centered square iris crops between 400 and 3000 pixels.') + settings=LearnedSettings.from_env() + geometries=(None,None) + if settings.adaptive_mask: + (roi,ref_geometry),(source_roi,mov_geometry)=adaptive_mask(reference),adaptive_mask(moving) + geometries=(ref_geometry,mov_geometry) + raw_ref,raw_mov=get_matcher()(reference,moving,masks=(roi,source_roi)) + else: + roi,source_roi=iris_mask(reference),iris_mask(moving) + raw_ref,raw_mov=get_matcher()(reference,moving) + if settings.patches=='geometry': + ref,mov=validate_geometry_patches(reference,moving,raw_ref,raw_mov) + elif settings.patches=='multiscale': + ref,mov=validate_patches(reference,moving,raw_ref,raw_mov,multiscale=True) + else: + ref,mov=validate_patches(reference,moving,raw_ref,raw_mov) + evaluation=evaluate_correspondences(ref,mov,(h,w)) + metrics=dict(matches=len(raw_ref),verified_matches=len(ref),inliers=None,inlier_ratio=None, + patch_survival_percent=round(100*len(ref)/max(len(raw_ref),1),1),evaluation=evaluation, + engine='learned_experimental',settings=dict(matcher=settings.matcher,max_size=settings.max_size,patches=settings.patches,adaptive_mask=settings.adaptive_mask), + segmentation=[g.to_dict() if g is not None else None for g in geometries]) + # Preview eligibility is NOT a production accuracy or 95% success gate. + if evaluation['p95_px'] is None or evaluation['median_px']>=4 or evaluation['p95_px']>=12: + raise RegistrationError('The learned alignment did not pass correspondence validation. Reference preserved.',metrics) + try:matrix,coef,inliers,coverage=fit_geometry(ref,mov,(h,w)) + except ValueError as exc:raise RegistrationError(str(exc),metrics) from exc + metrics.update(inliers=int(inliers.sum()),inlier_ratio=float(inliers.mean()),matches=len(ref),match_coverage=float(coverage)) + if not local:coef=np.zeros_like(coef) + mapping,geometry_valid,delta=dense_mesh(coef,matrix,(h,w)) + if geometry_valid[roi].mean()<.99:raise RegistrationError('Local deformation exceeds the permitted geometry limits.',metrics) + # Exactly one interpolation of original color pixels for the delivered warp. + aligned=cv2.remap(moving,mapping[...,0],mapping[...,1],cv2.INTER_LINEAR) + moving_roi=cv2.remap(source_roi.astype(np.uint8),mapping[...,0],mapping[...,1],cv2.INTER_NEAREST)>0 + support=np.zeros((h,w),np.uint8) + # Only allow source contribution close to observed correspondence locations. + for point in ref:cv2.circle(support,tuple(np.rint(point).astype(int)),max(5,round(w*.04)),1,-1) + trusted=roi&moving_roi&geometry_valid&support.astype(bool)&~glare_mask(reference)&~glare_mask(aligned) + images,blend=compose(reference,aligned,geometry_valid,trusted,exposure) + images['local_confidence']=trusted.astype(np.uint8)*255 + images['deformation']=np.clip(np.linalg.norm(delta,axis=2)*12,0,255).astype(np.uint8) + if settings.adaptive_mask: + images['reference_geometry']=geometry_overlay(reference,geometries[0]) + images['moving_geometry']=geometry_overlay(moving,geometries[1]) + metrics.update(blend,fit_error_px=None,transform=matrix.tolist(),mesh_coefficients=coef.tolist(),reference_shape=[h,w],sampling_convention="inverse homography plus bilinear reference-grid residual",local={'applied':local}, + runtime_seconds=round(time.perf_counter()-started,3), + warning='Experimental alignment. Percentages describe automatic correspondence consistency, not anatomical accuracy. Glare and unknown regions remain reference-only. Global transform excludes the local mesh.', + geometry_valid_fraction=float(geometry_valid[roi].mean()), + raw_matches=len(raw_ref)) + images['metrics']=metrics + return images diff --git a/hf_workspace/hf_workspace/backend/review.py b/hf_workspace/hf_workspace/backend/review.py new file mode 100644 index 0000000000000000000000000000000000000000..12cfdc4849d1d657d2b66de1ba4bba2433809848 --- /dev/null +++ b/hf_workspace/hf_workspace/backend/review.py @@ -0,0 +1,49 @@ +"""A review result for every decodable pair; no fabricated confidence scores.""" +import time +from .registration import register +from .common import RegistrationError + + +SCORE_DESCRIPTION = ( + 'Percentage of proposed feature matches consistent with the global transform. ' + 'Not iris similarity, percentage of aligned fibers, or accuracy. ' + 'A high percentage can still accompany an unreliable transformation.' +) + + +def review_pair(reference, moving, exposure=True, local=True, engine="classical"): + started = time.perf_counter() + try: + if engine == "learned": + from .learned_registration import register_learned + result = register_learned(reference, moving, exposure=exposure, local=local) + elif engine == "classical": + result = register(reference, moving, exposure=exposure, local=local) + else: + raise ValueError("Unknown registration engine.") + metrics = result['metrics'] + metrics.update(status='review_required', status_label='Alignment preview — review required', + reason=None, suggestions=[ + 'Inspect corresponding fibers and crypts at 100% pixels before using the composite.', + 'Review glare and occluded regions separately; they may have no usable counterpart.' + ]) + except RegistrationError as exc: + # Original images only: never relabel a failed warp as an aligned result. + metrics = dict(exc.diagnostics) + metrics.update(status='unaligned', status_label='Not aligned — reference preserved', + reason=str(exc), transform=None, fit_error_px=None, + exposure_gain=1., blended_fraction=0., + local={'applied': False, 'reason': 'Alignment rejected'}, + runtime_seconds=round(time.perf_counter()-started, 3), + warning='No registered or merged output was produced. The reference is unchanged.', + suggestions=[ + 'Crop both originals tightly around the same iris, keeping the entire iris visible.', + 'Choose the clearest, better-exposed photograph as reference.', + 'If it still fails, use landmark-assisted review rather than forcing a merge.' + ]) + result = {'metrics': metrics} + result.update(reference=reference, moving=moving) + ratio = metrics.get('inlier_ratio') + metrics['match_support_percent'] = round(100 * ratio, 1) if ratio is not None else None + metrics['score_description'] = SCORE_DESCRIPTION + return result diff --git a/hf_workspace/hf_workspace/frontend/src/ReviewSummary.jsx b/hf_workspace/hf_workspace/frontend/src/ReviewSummary.jsx new file mode 100644 index 0000000000000000000000000000000000000000..ad51f696197ef59e3af480c680ec5d4ce5929a8d --- /dev/null +++ b/hf_workspace/hf_workspace/frontend/src/ReviewSummary.jsx @@ -0,0 +1,26 @@ +import React from 'react'; + +export default function ReviewSummary({metrics}) { + const score = metrics.match_support_percent; + return
+

{metrics.status_label}

+
{score == null ? 'Not measurable' : `${score.toFixed(1)}%`}Match support
+

{metrics.score_description}

+ {metrics.reason &&

{metrics.reason}

} + {metrics.evaluation &&

Automatic consistency

+

{metrics.evaluation.description}

+

Patch-verified matches: {metrics.verified_matches} / {metrics.raw_matches ?? metrics.matches}. Only this subset is evaluated; it is not the percentage of the iris aligned.

+ {metrics.evaluation.within_px_percent ? {Object.entries(metrics.evaluation.within_px_percent).map(([px,percent])=>)}
Pixel toleranceHeld-out matches within tolerance
{px} px{percent.toFixed(2)}%
:

{metrics.evaluation.reason}

} +
} +
+
Consistent / proposed matches
{metrics.inliers ?? '—'} / {metrics.matches ?? 0}
+ {metrics.fit_error_px != null && <>
Median fitting error (not independent accuracy)
{metrics.fit_error_px.toFixed(2)} px
} +
Processing time
{metrics.runtime_seconds.toFixed(2)} s
+
Output area including second-image pixels
{(metrics.blended_fraction * 100).toFixed(1)}%
+
+

{metrics.warning}

+

Next steps

+
    {metrics.suggestions.map(s =>
  • {s}
  • )}
+ Download review details +
; +} diff --git a/hf_workspace/hf_workspace/frontend/src/api.js b/hf_workspace/hf_workspace/frontend/src/api.js new file mode 100644 index 0000000000000000000000000000000000000000..0682d63c078e32ced254a5f13bccfd3516f2a8b5 --- /dev/null +++ b/hf_workspace/hf_workspace/frontend/src/api.js @@ -0,0 +1,9 @@ +export async function requestAlignment(data) { + const response = await fetch('/api/register', {method: 'POST', body: data}); + const body = await response.json().catch(() => null); + if (!response.ok) { + throw new Error(typeof body?.detail === 'string' ? body.detail : `The request could not be completed (${response.status}). Please retry.`); + } + if (!body?.images || !body?.metrics) throw new Error('The server returned an incomplete review. Please retry.'); + return body; +} diff --git a/hf_workspace/hf_workspace/hf_workspace/.dockerignore b/hf_workspace/hf_workspace/hf_workspace/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..9720ea0fa0e75caa90bcc6f4e19818bda71afc44 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/.dockerignore @@ -0,0 +1,12 @@ +.git +.github +.venv +__pycache__ +.pytest_cache +private_benchmarks +frontend/node_modules +frontend/dist +tests +scripts +benchmark.py +synthetic_cases.py diff --git a/hf_workspace/hf_workspace/hf_workspace/.gitignore b/hf_workspace/hf_workspace/hf_workspace/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8524e3d106138337e7a600f1ee69b41f704fe404 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/.gitignore @@ -0,0 +1,11 @@ + + +#Ignore vscode AI rules +.github/instructions/codacy.instructions.md +.venv/ +__pycache__/ +.pytest_cache/ +frontend/node_modules/ +frontend/dist/ +private_benchmarks/ +models/ diff --git a/hf_workspace/hf_workspace/hf_workspace/Dockerfile b/hf_workspace/hf_workspace/hf_workspace/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7fb7ef9cc64ee4ce5256f849be45ef03c10178a7 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/Dockerfile @@ -0,0 +1,22 @@ +FROM node:22-alpine AS frontend +WORKDIR /build +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +FROM python:3.12-slim +ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 +# opencv-python-headless still links libglib; libgomp backs numpy/opencv threading. +RUN apt-get update && apt-get install -y --no-install-recommends libglib2.0-0 libgomp1 \ + && rm -rf /var/lib/apt/lists/* +RUN useradd -m -u 1000 user +WORKDIR /app +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt +COPY --chown=user:user backend/ ./backend/ +COPY --chown=user:user reports/ ./reports/ +COPY --from=frontend --chown=user:user /build/dist ./frontend/dist +USER user +EXPOSE 7860 +CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"] diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/__init__.py b/hf_workspace/hf_workspace/hf_workspace/backend/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/__init__.py @@ -0,0 +1 @@ + diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/app.py b/hf_workspace/hf_workspace/hf_workspace/backend/app.py new file mode 100644 index 0000000000000000000000000000000000000000..599933c00fd0550fa6a9fe783ae379d275a5017c --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/app.py @@ -0,0 +1,81 @@ +import base64 +import io +import warnings +from threading import BoundedSemaphore +from typing import Literal + +import cv2 +import numpy as np +from fastapi import FastAPI, File, Form, HTTPException, UploadFile +from fastapi.staticfiles import StaticFiles +from fastapi.responses import JSONResponse +from pathlib import Path +from PIL import Image, ImageOps + +from .review import review_pair + +app = FastAPI(title='Iris registration POC') +Image.MAX_IMAGE_PIXELS = 30_000_000 +processing_slots = BoundedSemaphore(1) + + +def decode(data): + try: + with warnings.catch_warnings(): + warnings.simplefilter('error', Image.DecompressionBombWarning) + with Image.open(io.BytesIO(data)) as image: + if image.width * image.height > 30_000_000 or min(image.size) < 64: + raise ValueError('Image must be at least 64px per side and at most 30 megapixels.') + image = ImageOps.exif_transpose(image).convert('RGB') + return cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) + except Exception as exc: + raise ValueError('Invalid or oversized image. Use JPEG or PNG up to 30 megapixels.') from exc + + +@app.get('/api/health') +def health(): + return {'status': 'ok'} + + +@app.post('/api/register') +def registration(reference: UploadFile = File(...), moving: UploadFile = File(...), exposure: bool = Form(True), local: bool = Form(True), engine: Literal['classical', 'learned'] = Form('classical'), iris_crop_confirmed: bool = Form(False)): + if engine == 'learned' and not iris_crop_confirmed: + raise HTTPException(status_code=422, detail='Confirm both images are equally sized square crops centered on the iris before using experimental alignment.') + if not processing_slots.acquire(blocking=False): + raise HTTPException(status_code=503, detail='Another pair is being processed. Please retry shortly.', headers={'Retry-After':'10'}) + try: + return process_pair(reference, moving, exposure, local, engine) + finally: + processing_slots.release() + + +def process_pair(reference, moving, exposure, local, engine): + try: + images = [] + for upload in (reference, moving): + data = upload.file.read(25_000_001) + if len(data) > 25_000_000: + raise ValueError('Each upload must be under 25 MB.') + images.append(decode(data)) + result = review_pair(*images, exposure=exposure, local=local, engine=engine) + encoded = {} + for key, value in result.items(): + if key != 'metrics': + ok, buf = cv2.imencode('.png', value) + if not ok: + raise ValueError('Could not encode output.') + encoded[key] = 'data:image/png;base64,' + base64.b64encode(buf).decode() + return JSONResponse({'images': encoded, 'metrics': result['metrics']}) + except RuntimeError as exc: + raise HTTPException(status_code=503, detail=str(exc)) from exc + except (ValueError, cv2.error) as exc: + raise HTTPException(status_code=422, detail=str(exc)) from exc + + +root = Path(__file__).resolve().parents[1] +reports = root / 'reports' +if reports.exists(): + app.mount('/benchmark', StaticFiles(directory=reports, html=True), name='benchmark') +dist = root / 'frontend' / 'dist' +if dist.exists(): + app.mount('/', StaticFiles(directory=dist, html=True), name='frontend') diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/common.py b/hf_workspace/hf_workspace/hf_workspace/backend/common.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7e79b0e7f8c07537ac01a30b7e17500382179e --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/common.py @@ -0,0 +1,11 @@ +import cv2 + + +class RegistrationError(ValueError): + def __init__(self, message, diagnostics=None): + super().__init__(message) + self.diagnostics = diagnostics or {} + + +def gray(image): + return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/compositing.py b/hf_workspace/hf_workspace/hf_workspace/backend/compositing.py new file mode 100644 index 0000000000000000000000000000000000000000..4c21025950c8a5f93ef6ca3f5640166ed42e4c65 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/compositing.py @@ -0,0 +1,22 @@ +"""Conservative source-only compositing and review images.""" +import cv2 +import numpy as np +from .common import gray + + +def compose(reference, aligned, valid, trusted, exposure): + h, w = reference.shape[:2] + rg, ag = gray(reference), gray(aligned) + usable = valid & (rg > 25) & (rg < 230) & (ag > 15) & (ag < 230) + gain = float(np.clip(np.median(rg[usable] / np.maximum(ag[usable], 1)), 1, 2.5)) if exposure and usable.any() else 1. + adjusted = np.clip(aligned.astype(np.float32) * gain, 0, 255).astype(np.uint8) + # Photometric agreement is a heuristic, NOT proof of anatomical correspondence. + discrepancy = cv2.GaussianBlur(cv2.absdiff(gray(adjusted), rg).astype(np.float32), (0, 0), 2) + safe = usable & trusted & (discrepancy < 12) & (gray(adjusted) < 245) + safe = cv2.erode(safe.astype(np.uint8), np.ones((5, 5), np.uint8)) + weight = .5 * cv2.GaussianBlur(safe.astype(np.float32), (0, 0), 2) * safe + composite = np.rint(reference * (1-weight[..., None]) + adjusted * weight[..., None]).astype(np.uint8) + overlay = cv2.addWeighted(reference, .5, adjusted, .5, 0) + yy, xx = np.indices((h, w), dtype=np.int32) + checker = np.where((((xx//64 + yy//64) % 2 == 0) & valid)[..., None], adjusted, reference) + return dict(aligned=aligned, adjusted=adjusted, composite=composite, overlay=overlay, checkerboard=checker, contribution=np.rint(weight*255).astype(np.uint8), difference=cv2.absdiff(reference, adjusted)), dict(exposure_gain=gain, overlap_fraction=float(valid.mean()), blended_fraction=float((weight > 0).mean())) diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/global_alignment.py b/hf_workspace/hf_workspace/hf_workspace/backend/global_alignment.py new file mode 100644 index 0000000000000000000000000000000000000000..80e80cd241c69843198193824e302994e95a9123 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/global_alignment.py @@ -0,0 +1,49 @@ +"""Robust feature-based global initialization.""" +import cv2 +import numpy as np +from .common import gray, RegistrationError + + +def estimate_global(reference, moving, allow_local=False): + evidence = dict(matches=0, inliers=None, inlier_ratio=None, match_coverage=None) + # Independently resize for matching; map the estimate back to original pixels. + def features(image): + scale = min(1., 1400 / max(image.shape[:2])) + small = cv2.resize(image, None, fx=scale, fy=scale) + g = gray(small) + mask = ((g > 12) & (g < 245)).astype(np.uint8) * 255 + keypoints, descriptors = cv2.SIFT_create(nfeatures=7000).detectAndCompute(g, mask) + return keypoints, descriptors, scale + + kr, dr, sr = features(reference) + km, dm, sm = features(moving) + if dr is None or dm is None or min(len(dr), len(dm)) < 12: + raise RegistrationError('Not enough visible detail to estimate alignment.', evidence) + pairs = cv2.BFMatcher().knnMatch(dm, dr, k=2) + good = [p[0] for p in pairs if len(p) == 2 and p[0].distance < .72 * p[1].distance] + evidence['matches'] = len(good) + if len(good) < 12: + raise RegistrationError('Too few reliable feature matches. Try tighter iris crops.', evidence) + source = np.float32([km[m.queryIdx].pt for m in good]) / sm + target = np.float32([kr[m.trainIdx].pt for m in good]) / sr + matrix, inliers = cv2.findHomography(source, target, cv2.RANSAC, (10 if allow_local else 3) / sr) + if inliers is not None: + evidence.update(inliers=int(inliers.sum()), inlier_ratio=float(inliers.mean())) + if matrix is None or not np.isfinite(matrix).all() or inliers.sum() < 12 or inliers.mean() < .3: + raise RegistrationError('Matches do not support a reliable global transformation.', evidence) + selected = inliers.ravel().astype(bool) + h, w = reference.shape[:2] + # Require evidence distributed over a meaningful part of the image. + coverage = cv2.contourArea(cv2.convexHull(target[selected])) / (h * w) + evidence['match_coverage'] = float(coverage) + if coverage < .08: + raise RegistrationError('Matches are too concentrated to trust the transformation.', evidence) + mh, mw = moving.shape[:2] + corners = np.float32([[0, 0], [mw, 0], [mw, mh], [0, mh]]) + denominators = (matrix @ np.c_[corners, np.ones(4)].T)[2] + warped_corners = cv2.perspectiveTransform(corners[None], matrix)[0] + area = cv2.contourArea(warped_corners, oriented=True) + if np.any(denominators <= 0) or not .15 < area / (h*w) < 6: + raise RegistrationError('Implausible or flipped transformation rejected.', evidence) + error = np.linalg.norm(cv2.perspectiveTransform(source[selected, None], matrix)[:, 0] - target[selected], axis=1) + return matrix, dict(matches=len(good), inliers=int(selected.sum()), inlier_ratio=float(selected.mean()), match_coverage=float(coverage), fit_error_px=float(np.median(error))) diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/local_alignment.py b/hf_workspace/hf_workspace/hf_workspace/backend/local_alignment.py new file mode 100644 index 0000000000000000000000000000000000000000..932458d3dd244c17baf68ee1d318eac9cdb39dd3 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/local_alignment.py @@ -0,0 +1,56 @@ +"""Bounded bidirectional optical flow on a capped working resolution. + +Maps point from reference coordinates into the globally aligned moving image. +Confidence is heuristic; no claim of anatomical validation is made. +""" +import cv2 +import numpy as np +from .common import gray + + +def refine_local(reference, global_image, valid): + h, w = reference.shape[:2] + scale = min(1., 1200 / max(h, w)) + size = (round(w * scale), round(h * scale)) + a = cv2.resize(gray(reference), size) + b = cv2.resize(gray(global_image), size) + overlap = cv2.resize(valid.astype(np.uint8), size, interpolation=cv2.INTER_NEAREST).astype(bool) + usable = overlap & (a > 25) & (a < 230) & (b > 15) & (b < 240) + gain = float(np.clip(np.median(a[usable] / np.maximum(b[usable], 1)), .4, 2.5)) if usable.any() else 1. + b = np.clip(b.astype(np.float32) * gain, 0, 255).astype(np.uint8) + # Stable neutral normalization is for correspondence only, never output pixels. + def flow(first, second): + return cv2.calcOpticalFlowFarneback(first, second, None, .5, 5, 31, 5, 7, 1.5, 0) + forward = cv2.GaussianBlur(flow(a, b), (0, 0), 1.2) + reverse = flow(b, a) + yy, xx = np.indices(a.shape, dtype=np.float32) + mx, my = xx + forward[..., 0], yy + forward[..., 1] + back = cv2.remap(reverse, mx, my, cv2.INTER_LINEAR) + fb = np.linalg.norm(forward + back, axis=2) + displacement = np.linalg.norm(forward, axis=2) + ux_y, ux_x = np.gradient(forward[..., 0]) + uy_y, uy_x = np.gradient(forward[..., 1]) + determinant = (1 + ux_x) * (1 + uy_y) - ux_y * uy_x + strain = np.sqrt(ux_x**2 + ux_y**2 + uy_x**2 + uy_y**2) + warped = cv2.remap(b, mx, my, cv2.INTER_LINEAR) + before = cv2.GaussianBlur(cv2.absdiff(a, b).astype(np.float32), (0, 0), 2) + after = cv2.GaussianBlur(cv2.absdiff(a, warped).astype(np.float32), (0, 0), 2) + target_valid = cv2.remap(usable.astype(np.uint8), mx, my, cv2.INTER_NEAREST).astype(bool) + trusted = usable & target_valid & (fb < 1.) & (displacement < 18.) & (determinant > .65) & (determinant < 1.5) & (strain < .45) & (after < 15) & (after <= before + 1) + trusted = cv2.erode(trusted.astype(np.uint8), np.ones((5, 5), np.uint8)).astype(bool) + support = float(trusted.sum() / max(usable.sum(), 1)) + improvement = float(1 - np.mean(after[trusted]) / max(np.mean(before[trusted]), .01)) if trusted.any() else 0. + motion = float(np.median(displacement[trusted])) if trusted.any() else 0. + accepted = support > .45 and improvement > .15 and motion > .3 + info = dict(applied=accepted, trusted_fraction=support, photometric_improvement=improvement, + median_displacement_working_px=motion, working_scale=scale, + reason='Accepted constrained optical flow' if accepted else 'No reliable material improvement; kept global alignment') + if not accepted: + return None, np.ones((h,w), bool), info + # Keep the smooth map continuous; gate source contribution, not the field, + # at uncertain pixels to avoid discontinuities caused by zeroing local flow. + dense = cv2.resize(forward, (w,h)) + dense[..., 0] *= w / size[0] + dense[..., 1] *= h / size[1] + confidence = cv2.resize(trusted.astype(np.uint8), (w,h), interpolation=cv2.INTER_NEAREST).astype(bool) + return dense, confidence, info diff --git a/hf_workspace/hf_workspace/hf_workspace/backend/registration.py b/hf_workspace/hf_workspace/hf_workspace/backend/registration.py new file mode 100644 index 0000000000000000000000000000000000000000..38ca54f0b53247f855b4a39fda7985bab06034d3 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/backend/registration.py @@ -0,0 +1,58 @@ +"""Orchestrate global alignment, optional local refinement, and compositing.""" +import time +import cv2 +import numpy as np +from .common import RegistrationError +from .global_alignment import estimate_global +from .local_alignment import refine_local +from .compositing import compose + + +def register(reference, moving, exposure=True, local=True, return_maps=False): + started = time.perf_counter() + # Prefer the strict estimate; only retry a broader residual tolerance when + # local refinement is enabled. A coarse fallback must pass local validation. + coarse = False + try: + matrix, metrics = estimate_global(reference, moving) + except RegistrationError: + if not local: + raise + matrix, metrics = estimate_global(reference, moving, allow_local=True) + coarse = True + h, w = reference.shape[:2] + mh, mw = moving.shape[:2] + global_image = cv2.warpPerspective(moving, matrix, (w,h)) + valid = cv2.warpPerspective(np.ones((mh,mw), np.uint8), matrix, (w,h), flags=cv2.INTER_NEAREST) + valid = cv2.erode(valid, np.ones((5,5), np.uint8)).astype(bool) + if valid.mean() < .4: + raise RegistrationError('Insufficient overlap between the photographs.', metrics) + field, trusted, info = (None, np.ones((h,w), bool), dict(applied=False, reason='Disabled')) + if local: + field, trusted, info = refine_local(reference, global_image, valid) + if coarse and field is None: + raise RegistrationError('Coarse global alignment could not be verified by local refinement.', metrics) + yy, xx = np.indices((h,w), dtype=np.float32) + if field is not None: + xx += field[...,0] + yy += field[...,1] + # Compose inverse homography with local backward flow, then sample ORIGINAL + # moving pixels once. Avoid serial warping of the delivered output. + inverse = np.linalg.inv(matrix) + denominator = inverse[2,0]*xx + inverse[2,1]*yy + inverse[2,2] + map_x = ((inverse[0,0]*xx + inverse[0,1]*yy + inverse[0,2]) / denominator).astype(np.float32) + map_y = ((inverse[1,0]*xx + inverse[1,1]*yy + inverse[1,2]) / denominator).astype(np.float32) + valid = np.isfinite(map_x) & np.isfinite(map_y) & (map_x >= 2) & (map_x < mw-3) & (map_y >= 2) & (map_y < mh-3) + aligned = cv2.remap(moving, map_x, map_y, cv2.INTER_LINEAR) + outputs, blend_metrics = compose(reference, aligned, valid, trusted, exposure) + outputs['global_aligned'] = global_image + outputs['local_confidence'] = trusted.astype(np.uint8)*255 + outputs['deformation'] = np.zeros((h,w), np.uint8) if field is None else np.clip(np.linalg.norm(field,axis=2)*12,0,255).astype(np.uint8) + metrics.update(blend_metrics) + metrics.update(transform=matrix.tolist(), local=info, coarse_initialization=coarse, + runtime_seconds=round(time.perf_counter()-started,3), + warning='Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation.') + outputs['metrics'] = metrics + if return_maps: + outputs['sampling_map'] = np.stack([map_x,map_y],axis=-1) + return outputs diff --git a/hf_workspace/hf_workspace/hf_workspace/benchmark.py b/hf_workspace/hf_workspace/hf_workspace/benchmark.py new file mode 100644 index 0000000000000000000000000000000000000000..9869fbcd025a3e873e1d0550e7a4e85832fd80a3 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/benchmark.py @@ -0,0 +1,34 @@ +"""Generate deterministic test pairs and a browsable report; run from repo root.""" +from pathlib import Path +import html +import json +import cv2 +import numpy as np +from backend.registration import register, RegistrationError +from synthetic_cases import CASE_NAMES, make_case, mapping_errors + +out = Path('reports') +out.mkdir(exist_ok=True) +ref = cv2.resize(cv2.imread('fixtures/synthetic-iris.png'), (1000, 1000)) +cv2.imwrite(str(out/'reference.png'), ref) +rows = [] +cards = [] +for name in CASE_NAMES: + moving, truth_points, moving_points = make_case(ref, name) + cv2.imwrite(str(out/f'{name}-moving.jpg'), moving) + try: + result = register(ref, moving, return_maps=True) + errors = mapping_errors(result['sampling_map'], truth_points, moving_points) + row = dict(case=name, median_error_px=float(np.median(errors)), p95_error_px=float(np.percentile(errors,95)), + status='PASS' if np.percentile(errors,95)<1 else 'LIMITATION', **result['metrics']) + for key, img in result.items(): + if key not in ('metrics', 'sampling_map'): + cv2.imwrite(str(out/f'{name}-{key}.png'), img) + cards.append(f'

{name}: {row["status"]}

Independent grid error: median {row["median_error_px"]:.3f}px · p95 {row["p95_error_px"]:.3f}px

'+''.join(f'
{key}
' for key,ext in [('moving','jpg'),('global_aligned','png'),('overlay','png'),('composite','png')])+'
') + except RegistrationError as exc: + row = dict(case=name, status='REJECTED', reason=str(exc)) + cards.append(f'

{name}: REJECTED

{html.escape(str(exc))} No composite produced.

Moving image with known local distortion
Reference
') + rows.append(row) +(out/'metrics.json').write_text(json.dumps(rows, indent=2)) +(out/'index.html').write_text('Synthetic registration benchmark

Synthetic iris registration benchmark

One AI-generated fixture, deterministic transformations. These are not real client photographs. Error is measured in moving-image pixels using the complete backward sampling map at independent known-coordinate iris grid points, not fitting matches. PASS means p95 < 1 pixel at 1000 × 1000. Click images for full resolution.

Reference image · Full measurements'+''.join(cards)) +print(json.dumps([{k:r[k] for k in ['case','status','median_error_px','p95_error_px'] if k in r} for r in rows], indent=2)) diff --git a/hf_workspace/hf_workspace/hf_workspace/fixtures/prompt.txt b/hf_workspace/hf_workspace/hf_workspace/fixtures/prompt.txt new file mode 100644 index 0000000000000000000000000000000000000000..9559b9cc9ab6a27d36fcad4bb159a0578687d97d --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/fixtures/prompt.txt @@ -0,0 +1 @@ +Create one photorealistic macro image of a human iris for a SYNTHETIC computer vision test fixture, square 1024x1024. Straight-on circular hazel/green iris centered precisely, complete outer iris visible with margin, round black pupil, densely detailed naturally irregular radial iris fibers and crypts, subtle brown inner ring, plain subdued sclera outside. Flat diffuse neutral illumination, no specular glare, no eyelids covering the iris, no text, no graphics, no sharpening halos. This is fictional test imagery, not a medical reference. diff --git a/hf_workspace/hf_workspace/hf_workspace/fixtures/synthetic-iris.png b/hf_workspace/hf_workspace/hf_workspace/fixtures/synthetic-iris.png new file mode 100644 index 0000000000000000000000000000000000000000..246d1e9bfd85d2c4c5baa26e98d49d9b650508c2 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/fixtures/synthetic-iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90cbf161544761b04fc2fc00557a885d934c1807f4da4690236237d77516b651 +size 2360599 diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/index.html b/hf_workspace/hf_workspace/hf_workspace/frontend/index.html new file mode 100644 index 0000000000000000000000000000000000000000..c67696e13e2bccc21c06b9bf429aeb2184ce1b21 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/index.html @@ -0,0 +1 @@ +Iris registration lab
diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/package-lock.json b/hf_workspace/hf_workspace/hf_workspace/frontend/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..e1e9e4fbcd114f8e8e5e84552d6cec1385a32c86 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/package-lock.json @@ -0,0 +1,1153 @@ +{ + "name": "iris-registration-poc", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "iris-registration-poc", + "version": "0.1.0", + "dependencies": { + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "devDependencies": { + "vite": "^6.0.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.4.tgz", + "integrity": "sha512-I+BSHzTAhKN2n7ZwGZsegGcZjDpLqFOMAtJz/u6uFGe0pUFbq56dEHjqJV/ZUdRJtNXNxA+hREUatZBvMR3Oiw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.4.tgz", + "integrity": "sha512-pu3BdjS2LtEzRu2elmGzS3fIeWSZy4BMDIaLNwjorO76+k2d0LMluijhsDx3KQyQBQ/lLUZCQA9/s6csvUfuhw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.4.tgz", + "integrity": "sha512-xfSrj9MHnWK9GaSqT9U0ImHtH/N8WZlHLx4cZHiuLcqs640hvZ3hLPd5UR2AZS57FaE8HrRUSpltbZdWRxHiDA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.4.tgz", + "integrity": "sha512-bqU99PLJb/dqb3S0GIMdeuyAEETSUgZBoqXYd3Sd+WCsV+MmPhnN6JrotWyir31+QgH7EvvE5/mwGJlEoci8Fw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.4.tgz", + "integrity": "sha512-JinsFZ5G40oXQb+sUuiA5x689vhr6dDYK0H0NL+rwKdL6CqnmYN8PE4ZwfRSoIjrCxqTQG/SLfTtSvHeGxoVlw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.4.tgz", + "integrity": "sha512-GAdA4UxpiNm27cLHr2GqXBpAD0x9FqwYBY7/YSP0Ss0/PNi4k8gbviqpIpYbVSRBaS2ZcegXEzgTQMbRNCwxCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.4.tgz", + "integrity": "sha512-qDd6NoA1znaLjp4jR5U/KWCdLAKDJNB8W9ChbbDaKbo0xA+Atln5HK6LFCZ4oJQpemtRZA288DCirFRjrspptw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.4.tgz", + "integrity": "sha512-WtB5Tz5KTNINb8ZA+8sQ7bmjuS1JrRT7YverYIhUGdWWDlpzVWmIwuZE+jidkEXUn1l0zrEkaIMa8dHF3NGcsA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.4.tgz", + "integrity": "sha512-VcQ3L1tjnkKzWjryAVaFhHEWcqOfICX9uxVVoDzm2t0DpgKRHd2zOpVrJc0xsWeBZcBFyYROCIBdyR/fS174pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.4.tgz", + "integrity": "sha512-6+ZQX6P5s0cMDN2Ypb8Lbm2+/sZYmZjdaYny992ujUU9UKi/4CWoJWsl1pNvjWJHNHGK51m+jKGLlh1ylb2ifQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.4.tgz", + "integrity": "sha512-D72ZnvkFkBXOfzMMQLcwfPLyGkKb7HZ9/mf97B7v6/P5Lbv4oFOtSY/uHbS8lH6uKUOxoKiuokdb50XZSzzbJw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.4.tgz", + "integrity": "sha512-piU6BxeqA3O9KSu3kRCIQQtNqFFaTu21SEV4FwaRZowpnj3bLaWPZHw+xFqCs0XlJ+aOH3PTRWGoglH+mKA/OA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.4.tgz", + "integrity": "sha512-/5PGpHwqt2EEEOUs1XwzubE/ucr0dWDQ+to3zqi4Ds7EWpwtQ79wXc4JBoxqj/OwpawTsKWzJxHfSuBOq3DrWA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.4.tgz", + "integrity": "sha512-cX3beZDLWt7G2oJF+nhChiT+qtaihs+S2xi7ziGmVB+2pwPng6D0Ed0HmElQOgv2UsUmSJJLGwpBao/3TDx3VA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.4.tgz", + "integrity": "sha512-1uz2mGWHyptR7DgHHrlbdRAjXK7v7elGZ9lMja910/RP+ZYbX6xAmCiU9UZSX4hqmgtHMv6lr5l3kq1HIOpcag==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.4.tgz", + "integrity": "sha512-nLS8topojxyz7SRpKR2IODRpQ0XPZ+xaOXvT3+hqK/Uy8Lo5HFgkkIBiIrCu5tL5YqzTvgovGw55PwpahTAGig==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.4.tgz", + "integrity": "sha512-gs7DRKotr3l3q+jGPQBjH0ng1FjlEDm5ueQrkw5JtQvtLyEIcLASqAEaor56BhkKRzk+IcQzrcanBdb/bBQn8g==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.4.tgz", + "integrity": "sha512-791ET7W17NnScOZM7h4dX5hYspxE28htPFsb1awY/NRR8+PRNkS53e475rDdxXXDrP+kwnCcNWg9CX5ztn/Aqw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.4.tgz", + "integrity": "sha512-iwZQRcmj7g88g3tzefIrQY7qvmuA/cfYwhrDtTBhsmukO4U2huVO5W+86XacUMRvdSFVAc6kZUZy21JaRwiB9w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.4.tgz", + "integrity": "sha512-dVHFp9gRWrdTpnqQuGfCwd7hOQDatK1VCP2iWhLY/cGrOQs/ucFzJ6A5SRqbXX12ZDI8EUuejSM5kwg+ja7Png==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.4.tgz", + "integrity": "sha512-t3NlauOW6gxZVVFcBEnO62Cb4wbyDFL416gTg1uFI/2tgqYQlf69FbSE115Ajre9I+c26Lk4mcmdFUsS/DGifQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.4.tgz", + "integrity": "sha512-xWuIaSye5FWZF8+UYtVEcHtRJDN5kN9Kfgxx3Kq8XIov9KSKbc1fiqQCm90SKrgQbUXZelbnUhnlUJmfSE7P9A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.4.tgz", + "integrity": "sha512-9ALJJUOg/ZflMJepVo2PlgsGxSaxN7SQ4Z8GoZfVlarWr6r3rkHUNsd/zAio7p4YMtChSMXPionxej4Hkf6CXQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.4.tgz", + "integrity": "sha512-blj9z5qx/Pv4WU0W1NMFDB97e0JH5ed+aZGywW8WCvp/NhWX/4PFAq5uu6Q0AebNn+Vo6KzUYDT++JzTT5ojlQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.4.tgz", + "integrity": "sha512-Erx822VRBwLa124shbj+wNXe//BOgMEctDV0m1aqTQdNO1S69DgNUCFKC1RCeZfixs1J31l6igk1ziyXErbigQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.19", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", + "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.18", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz", + "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.0" + } + }, + "node_modules/rollup": { + "version": "4.63.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.4.tgz", + "integrity": "sha512-4U0liVayNIoLp3GFl1FcI8561WepLnZ1rqfraGh7S9B3Ur5F9S283y8Futii7RUU2C/97tOBmBy7nYvhoiOpbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.4", + "@rollup/rollup-android-arm64": "4.63.4", + "@rollup/rollup-darwin-arm64": "4.63.4", + "@rollup/rollup-darwin-x64": "4.63.4", + "@rollup/rollup-freebsd-arm64": "4.63.4", + "@rollup/rollup-freebsd-x64": "4.63.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.4", + "@rollup/rollup-linux-arm-musleabihf": "4.63.4", + "@rollup/rollup-linux-arm64-gnu": "4.63.4", + "@rollup/rollup-linux-arm64-musl": "4.63.4", + "@rollup/rollup-linux-loong64-gnu": "4.63.4", + "@rollup/rollup-linux-loong64-musl": "4.63.4", + "@rollup/rollup-linux-ppc64-gnu": "4.63.4", + "@rollup/rollup-linux-ppc64-musl": "4.63.4", + "@rollup/rollup-linux-riscv64-gnu": "4.63.4", + "@rollup/rollup-linux-riscv64-musl": "4.63.4", + "@rollup/rollup-linux-s390x-gnu": "4.63.4", + "@rollup/rollup-linux-x64-gnu": "4.63.4", + "@rollup/rollup-linux-x64-musl": "4.63.4", + "@rollup/rollup-openbsd-x64": "4.63.4", + "@rollup/rollup-openharmony-arm64": "4.63.4", + "@rollup/rollup-win32-arm64-msvc": "4.63.4", + "@rollup/rollup-win32-ia32-msvc": "4.63.4", + "@rollup/rollup-win32-x64-gnu": "4.63.4", + "@rollup/rollup-win32-x64-msvc": "4.63.4", + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "license": "MIT" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/vite": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.3.tgz", + "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + } + } +} diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/package.json b/hf_workspace/hf_workspace/hf_workspace/frontend/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3e8c926130f177819bf65be1f1ef22c4ac22d12c --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/package.json @@ -0,0 +1 @@ +{"name":"iris-registration-poc","version":"0.1.0","private":true,"type":"module","scripts":{"dev":"vite --host 127.0.0.1","build":"vite build"},"dependencies":{"react":"^19.0.0","react-dom":"^19.0.0"},"devDependencies":{"vite":"^6.0.0"}} diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/src/main.jsx b/hf_workspace/hf_workspace/hf_workspace/frontend/src/main.jsx new file mode 100644 index 0000000000000000000000000000000000000000..c65982c4c61829dea30efd9b8321549845fd1bf2 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/src/main.jsx @@ -0,0 +1,38 @@ +import React, {useState} from 'react'; +import {createRoot} from 'react-dom/client'; +import './style.css'; +import ReviewSummary from './ReviewSummary'; +import {requestAlignment} from './api'; + +function App(){ + const [result,setResult]=useState(null), [busy,setBusy]=useState(false), [error,setError]=useState(''); + const [view,setView]=useState('overlay'), [native,setNative]=useState(false); + const [engine,setEngine]=useState('classical'); + async function submit(e){ + e.preventDefault(); const data=new FormData(e.currentTarget); + data.set('exposure',data.get('exposure') ? 'true' : 'false'); + data.set('local',engine === 'learned' || data.get('local') ? 'true' : 'false'); + data.set('iris_crop_confirmed',data.get('iris_crop_confirmed') ? 'true' : 'false'); + setBusy(true);setError('');setResult(null); + try{const body=await requestAlignment(data);setResult(body);setView(body.metrics.status === 'unaligned' ? 'reference' : 'overlay');} + catch(err){setError(err.message);}finally{setBusy(false);} + } + return
COMPUTER VISION / REGISTRATION REVIEW

Iris registration lab

Align source photographs. Inspect the detail. Keep the reference in control.

+
{result && Download PNG}
+ {result?.metrics.status === 'unaligned' &&
Reference original
Reference — unchanged
Second original, not aligned
Second original — not aligned
} +
{result?{view+':
◎

Make the structures match.

Upload two photographs to inspect alignment overlays and source-only output.

Synthetic tests establish code behavior, not real-eye accuracy.
}
+

Overlay: doubled fibers indicate misalignment. Contribution: black = reference only, lighter areas include the moving photograph (maximum 50%). Composite is experimental. Local confidence: white = eligible for blending, not verified anatomy. Deformation: brightness shows local movement (12 levels per pixel).

; +} +createRoot(document.getElementById('root')).render(); diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/src/style.css b/hf_workspace/hf_workspace/hf_workspace/frontend/src/style.css new file mode 100644 index 0000000000000000000000000000000000000000..27f5583e077de280f3c91cf26cec04437efe4b50 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/src/style.css @@ -0,0 +1,5 @@ +*{box-sizing:border-box}body{margin:0;background:#0c1217;color:#e1e9ed;font:15px system-ui,sans-serif}main{max-width:1500px;margin:auto;padding:40px}header{margin-bottom:32px}header span{font-size:11px;letter-spacing:2px;color:#70d5b4}h1{font-size:38px;letter-spacing:-1.3px;margin:10px 0}p{line-height:1.65;color:#99aab5}h2{font-size:18px}.layout{display:grid;grid-template-columns:320px 1fr;gap:24px}aside,.workspace{background:#141e26;border:1px solid #2a3943;border-radius:14px;padding:24px}label{display:block;margin:24px 0 12px;font-size:13px}input[type=file]{display:block;max-width:100%;margin-top:12px;font-size:12px}input::file-selector-button,select{background:#253641;border:1px solid #40525d;color:#e1e9ed;padding:9px;border-radius:6px}button{background:#70d5b4;color:#0c2822;font-weight:700;border:0;border-radius:7px;padding:14px;width:100%;margin-top:20px;cursor:pointer}button:disabled{opacity:.5;cursor:wait}.check{display:flex;align-items:center;gap:8px;margin:0}.note{font-size:12px}.toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:20px}.canvas{height:620px;overflow:auto;background:#090e12;border-radius:8px;display:flex;align-items:center;justify-content:center}.canvas img{max-width:100%;max-height:100%;object-fit:contain}.canvas.native{display:block}.canvas.native img{max-width:none;max-height:none;display:block}.empty{text-align:center;max-width:360px;padding:20px}.empty>div{font-size:90px;color:#70d5b4}.empty small{color:#778b98}a{color:#70d5b4;font-size:12px}dt{color:#99aab5;font-size:12px}dd{margin:4px 0 14px}.error{color:#ffb4a8}@media(max-width:850px){main{padding:20px}.layout{grid-template-columns:1fr}.canvas{height:450px}.toolbar{flex-wrap:wrap}} + +.review-summary{border-top:1px solid #40525d;margin-top:24px;padding-top:12px}.score{font-size:32px;color:#70d5b4;font-weight:700}.score small{display:block;font-size:13px;font-weight:400;color:#a9bcc7}.review-summary ul{padding-left:18px;font-size:13px;color:#b7c8d2;line-height:1.6}.review-summary li{margin:10px 0}.originals{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:20px}.originals figure{margin:0}.originals img{width:100%;max-height:230px;object-fit:contain}.originals figcaption{font-size:12px;color:#b7c8d2;text-align:center} + +.review-summary table{width:100%;font-size:12px;border-collapse:collapse}.review-summary th,.review-summary td{text-align:left;border-bottom:1px solid #40525d;padding:8px 4px}form select{display:block;width:100%;margin-top:8px} diff --git a/hf_workspace/hf_workspace/hf_workspace/frontend/vite.config.js b/hf_workspace/hf_workspace/hf_workspace/frontend/vite.config.js new file mode 100644 index 0000000000000000000000000000000000000000..f649ddca1627ef267fc4454e6354701c5e29265d --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/frontend/vite.config.js @@ -0,0 +1,2 @@ +import {defineConfig} from 'vite'; +export default defineConfig({server:{proxy:{'/api':'http://127.0.0.1:8000','/benchmark':'http://127.0.0.1:8000'}}}); diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..57cb93534fedfdaacc43c4f52f1f3000cba14224 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:976fadb9695433b0c0bc1f8aa6cfa0454d948e848042349d16b80f3b2ca31064 +size 1573997 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..57cb93534fedfdaacc43c4f52f1f3000cba14224 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:976fadb9695433b0c0bc1f8aa6cfa0454d948e848042349d16b80f3b2ca31064 +size 1573997 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..cfe449f534ed3b651e6216e309964aa503ddba52 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7c9ff7327286adf1a1dfdce3eb3b92ab0c742bab7f8d059cc7a792cae45ba49 +size 1609572 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..6cad4f7dc79bf6fedfdd0fda15bcc08f064abdc4 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59b6bde8b9b9f21b4992781cc1f6c62271d0c4f7564610f5ee4a18b55c4da501 +size 1608650 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..eb4a4ee8d14681ef65a5c3918a2ac017612b34ff --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7dad5e3291cdd9d0fd2ec5af99e6402134b2925197784315e8899c1e6a30d43 +size 21715 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..dd1d3c60994bfb8080a64a7d1263f7c82c9edafa --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc7924c30a309b32dc16913c75f3ab0249044ce1d4f1511ec2cbe9d72b057a19 +size 2703 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..0d486c4514312e0ce5f376cd554b9b5f010d0db2 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a849efba6d2aca11c539cec9be5db806bbecdd5e3afafa3b36c9726eea6e71ad +size 1080540 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..b08f409d01b482c277712254ba3ae1f9d40299b7 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:858002b9b8df5c63b561402ac27eb83acfbf60e1ece378d33c4645d1a7628949 +size 1573997 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..796b850a0b81ef779073958689e4cd34ca7a4965 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c809139ef812c1d66961cf433f370e9d50d14e9054e4cfdd617263e9cc6ca8b1 +size 3204 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/identity-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d4ddbc59d6e72e50c8570efd46312ded96d2e57b --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89daecd490f0b05c480a1ebcf435ad395cf1e8a1cac6e01426f4509e462c6cad +size 306751 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/identity-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/identity-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..f012693615118f65c107d6a607252deb6fe36bee --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/identity-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9dfb5986329a3dfb878090749e4d41e73cdce22972110944a3cbfb632b45881b +size 1597711 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/index.html b/hf_workspace/hf_workspace/hf_workspace/reports/index.html new file mode 100644 index 0000000000000000000000000000000000000000..41b96c17cd7b4a44e6107fab0f30402193249dc0 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/index.html @@ -0,0 +1 @@ +Synthetic registration benchmark

Synthetic iris registration benchmark

One AI-generated fixture, deterministic transformations. These are not real client photographs. Error is measured in moving-image pixels using the complete backward sampling map at independent known-coordinate iris grid points, not fitting matches. PASS means p95 < 1 pixel at 1000 × 1000. Click images for full resolution.

Reference image · Full measurements

identity: PASS

Independent grid error: median 0.003px · p95 0.008px

moving
global_aligned
overlay
composite

rotation_scale: PASS

Independent grid error: median 0.075px · p95 0.081px

moving
global_aligned
overlay
composite

perspective_dark: PASS

Independent grid error: median 0.083px · p95 0.127px

moving
global_aligned
overlay
composite

reflection: PASS

Independent grid error: median 0.075px · p95 0.081px

moving
global_aligned
overlay
composite

local_warp: PASS

Independent grid error: median 0.227px · p95 0.567px

moving
global_aligned
overlay
composite

local_dark: PASS

Independent grid error: median 0.221px · p95 0.557px

moving
global_aligned
overlay
composite

local_perspective: PASS

Independent grid error: median 0.270px · p95 0.896px

moving
global_aligned
overlay
composite
\ No newline at end of file diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..fe4e37e5cc6da5fea2509cdb39c887f13e9392f8 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fc7020d297746ea6c8c974b4af600b8606a5324ae4c238bd8f0b0cfafd8e291 +size 1394527 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..a8913ac889db7d04d05941c42d072bb38e56ed05 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:563f887dec2dc6d1721c3fac0a8e3dd0af6f1c4f2d3655687d57490a9a51ec7d +size 1155741 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..379f7ec66b4bfd58c01e687aead2865e81772a02 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b94abb53657ece6addb59d6709357afbf103b86b46e595cb52b8887d2fd80dad +size 1544155 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..15e9655e628c461f5444558d6b7cd0fd6a2dc018 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:819b88b2402aa604452d104abc65c4fcd0ab8e87fea35a8ac8297bd32987b312 +size 1553369 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..e8baddc8e7b31b3f9119ec624362b5db7828e2c0 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08358a6f0e6feb9e6d013dcc971336d77c6fb396114dcd5d43b9dc66dd54e97c +size 37807 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..8480d500405092bf4419f157ee2489de0cf43979 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:393acfac087f0f665060ebb28d1c811c2664e3f16e78c20631e4b387e895995f +size 203606 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..9833e9f71b233da9465081a20e1e4b283cb91122 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a428d67659f40bc2baeb2e62d312b28dec67274d2ff25b427ca9d66b75d148c8 +size 1312031 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..4a62d4e3feb80910986a98c1501f7da7dc89cc82 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29f1975269c1322feac1fc6464fc9929e122eb8ef7292bbfc94b111b74783c48 +size 1146921 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..7f20bf135ec41ee7ca2e0ca3d7b352a094e19545 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08f2c3c086f070c3a59217604019b140d2247f28e2d34bb8e1178c0e14e6a76f +size 9851 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8a4c8e899062f017c9111abafdb8a468e6840bed --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bde5bbecf41b8e1995a7814f9107103216ecee3a7c7c7dfd40efdd1b4546882 +size 214372 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..6acb3ebfa01535164a71790cee5569df17a11e8f --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_dark-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f6aa2d037860832a9463074393caac5fcb1ddeeb6a1f6f4f5374694a1b10b6a +size 1543407 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..61468fd474cfb3a04362f6db43326597650ce9b7 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fabbe2ee97c22596db3008535cbdb0a9ce090b9b8cf55b149c7e0d76a3b219bf +size 1337424 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..eae6752cfee4ba9ceb8d4fdfb1b8febde2d78f54 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f214c6942cc364624c743dfafda1ea52203ff57a00248634e4451ad79870d43 +size 1103456 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..d6274a23ccbf9b827899f6738343fd2c60d1928a --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00d537683b51999e0056385f6b5a16e0c17d10911c506a9830fe6010158d9545 +size 1535837 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..85e4b2e5976efbc7e74cc952da975e5e1414d245 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2969ae490a882b7422e670db21bd859e6469a8d65763735f1d0e4f1906c83230 +size 1579604 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..07ed68e4d2614e808238d0bfe48e6e0dce8f709b --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20409377032c311e559f6b8ec03ae542071dfa0e79852376688175776d3ba5d4 +size 51018 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..9f6d1486eca01e5c3eceaf2b75fdefae5b8c6a99 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8f24ee0569e1064b6c68345f27e6317f0c26e43ff000a085a94d22afcb5feaf +size 205616 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..9b09fba6a19dc4bf11a2730a231ee8d506af55ba --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be1687f7044aa6d0ae35486db6ef147a91a35e25d93a4f962dac96ea0f71af4d +size 1395487 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..a40d8142377f51f900069a7bde3de8d43ed2c4a5 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fed038b5b74ad7d011cc48960d320c73db639358442a16b5d77901505b6a3f83 +size 1084436 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..a14889b9f1f8e80131a237915a8c3b7b046cc438 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9b413c3352fca189cec1811f7403acaff502d606442fbe8e52458e305b1ec19 +size 11469 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..116123662f709f0bfe4d428f015dd08197eba900 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5a8ee68b14638ee545ae60e747b45024ee9d8cb8d87700888ade970a556f3c9 +size 187411 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..06cac566f8690bf240f65747f4cc8ab2f0496f33 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_perspective-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40427ef43e436b4b0523d5e75015b885739dcf5beafdcc00775f9ff777391020 +size 1514337 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..66fa83ee56aa305bf17a01fe85552cc9e26e3ba8 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:721ea0986743d607f474ddaa0bb55ea2099079324b99eb46d739ffe55af4a809 +size 1476215 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..66fa83ee56aa305bf17a01fe85552cc9e26e3ba8 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:721ea0986743d607f474ddaa0bb55ea2099079324b99eb46d739ffe55af4a809 +size 1476215 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..5c8f546afccee276f5ba552871f9434df173aadf --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:738b196ff393597cc5f12e008fe2bce2cc42f1966b2d5a339423b4f7e13b8bdf +size 1566549 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..2627dd1edff148aee08a60c4dcef1d4ddcb2931d --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87fa0f21e31f10b1fb09e7f1e4d0b8b46c90a44b6673a194d89b22256c14115e +size 1555348 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..d148f96ff0bdd2be51f711b4ab4256f0c69c8f68 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef85c4044469aa9af22ed68170ca41728663e517f77428c29aff1bcc4f169a63 +size 46449 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..2ccaea788c2987b3e3e5b764cb56d888b2c74647 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33ad5af2676853576aec3ba0c29f6d793c0c21eae9070a0a29438e902614ebfd +size 214961 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..b6744174d1eb85578257e3a6fe62f9a34f700da2 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f71f861ee2240187ac19106042d41194c2bd4fef91bf05f83cceaf829e197197 +size 1267124 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..cd63ed3778811a5737adec336e365cda4b9665a1 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84f6fdc2d7c88494ce4b2ade5d4af68a9b1f844675455800e3b93aa1cbe39dd9 +size 1457014 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..fdbf82db9524f39bfea851dd7fd747ef347b4e89 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e62810887b12d304281ef1c3c96f32cb3082dd003a176e03d82c441720a70844 +size 9994 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3d8974873107a05589340d3195285a169da2b58c --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f05e7caba36678f7d7d4687b92cc4e864bed2bed2cced10a49e2d55ee2f34b05 +size 286902 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..7c50e157f86d63ff9ebd4455606474f3173df8eb --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/local_warp-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0474e6a6595770ddd36a89879688ea924f6f3666bace1fc82e6323f361fc528 +size 1533988 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/metrics.json b/hf_workspace/hf_workspace/hf_workspace/reports/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..aa6d501ceb0f0d4ab773c27037a459a2fc92c514 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/metrics.json @@ -0,0 +1,296 @@ +[ + { + "case": "identity", + "median_error_px": 0.0032628830522298813, + "p95_error_px": 0.00813120137900114, + "status": "PASS", + "matches": 3792, + "inliers": 3792, + "inlier_ratio": 1.0, + "match_coverage": 0.6368272886234096, + "fit_error_px": 0.04402020573616028, + "exposure_gain": 1.0, + "overlap_fraction": 0.989752, + "blended_fraction": 0.922955, + "transform": [ + [ + 1.0000302132204786, + 1.6312473162624423e-05, + -0.012088504197586298 + ], + [ + 9.207838785408665e-06, + 1.0000258090816536, + -0.009040374686938574 + ], + [ + 1.843029640406857e-08, + 2.3795797278570176e-08, + 1.0 + ] + ], + "local": { + "applied": false, + "trusted_fraction": 0.9975166668433157, + "photometric_improvement": -0.00023567676544189453, + "median_displacement_working_px": 0.0063288104720413685, + "working_scale": 1.0, + "reason": "No reliable material improvement; kept global alignment" + }, + "coarse_initialization": false, + "runtime_seconds": 1.017, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "rotation_scale", + "median_error_px": 0.07453365623950958, + "p95_error_px": 0.0813852921128273, + "status": "PASS", + "matches": 2896, + "inliers": 2894, + "inlier_ratio": 0.9993093922651933, + "match_coverage": 0.6278077334566132, + "fit_error_px": 0.11196421831846237, + "exposure_gain": 1.0, + "overlap_fraction": 0.960531, + "blended_fraction": 0.898221, + "transform": [ + [ + 1.0443387178787544, + -0.20296201905564595, + 52.751244294627966 + ], + [ + 0.2030236417139578, + 1.044355539728675, + -109.39631820621322 + ], + [ + 3.4005028744338376e-08, + 6.015363783914279e-08, + 1.0 + ] + ], + "local": { + "applied": false, + "trusted_fraction": 0.9628629647933963, + "photometric_improvement": -0.023240208625793457, + "median_displacement_working_px": 0.07784821838140488, + "working_scale": 1.0, + "reason": "No reliable material improvement; kept global alignment" + }, + "coarse_initialization": false, + "runtime_seconds": 0.891, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "perspective_dark", + "median_error_px": 0.08336350321769714, + "p95_error_px": 0.12747210264205933, + "status": "PASS", + "matches": 136, + "inliers": 136, + "inlier_ratio": 1.0, + "match_coverage": 0.4596168421963287, + "fit_error_px": 0.13107699155807495, + "exposure_gain": 1.8181818181818181, + "overlap_fraction": 0.961039, + "blended_fraction": 0.89831, + "transform": [ + [ + 1.0499845573632398, + -0.20198464519308473, + 52.6374997856307 + ], + [ + 0.2109220363768879, + 1.0461207583047898, + -109.48206272023926 + ], + [ + -5.381811582242528e-05, + 5.339369631368793e-05, + 1.0 + ] + ], + "local": { + "applied": false, + "trusted_fraction": 0.9607533586280701, + "photometric_improvement": -0.002014636993408203, + "median_displacement_working_px": 0.08880702406167984, + "working_scale": 1.0, + "reason": "No reliable material improvement; kept global alignment" + }, + "coarse_initialization": false, + "runtime_seconds": 0.613, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "reflection", + "median_error_px": 0.07483996450901031, + "p95_error_px": 0.08137565851211548, + "status": "PASS", + "matches": 2815, + "inliers": 2814, + "inlier_ratio": 0.9996447602131439, + "match_coverage": 0.6267397556954262, + "fit_error_px": 0.11089639365673065, + "exposure_gain": 1.0, + "overlap_fraction": 0.960527, + "blended_fraction": 0.880712, + "transform": [ + [ + 1.0443391673086686, + -0.20295806959536838, + 52.75112266925735 + ], + [ + 0.20302230603223206, + 1.0443748174795708, + -109.40186360847281 + ], + [ + 3.1112445638130264e-08, + 7.604228354052506e-08, + 1.0 + ] + ], + "local": { + "applied": false, + "trusted_fraction": 0.9493633039629257, + "photometric_improvement": -0.02317953109741211, + "median_displacement_working_px": 0.0779489129781723, + "working_scale": 1.0, + "reason": "No reliable material improvement; kept global alignment" + }, + "coarse_initialization": false, + "runtime_seconds": 0.67, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "local_warp", + "median_error_px": 0.2268940508365631, + "p95_error_px": 0.5670187473297119, + "status": "PASS", + "matches": 2871, + "inliers": 2408, + "inlier_ratio": 0.8387321490769767, + "match_coverage": 0.6018083684969627, + "fit_error_px": 4.391671180725098, + "exposure_gain": 1.0, + "overlap_fraction": 0.982543, + "blended_fraction": 0.797974, + "transform": [ + [ + 1.0650556118564847, + 0.018958663781206517, + -12.578934654629196 + ], + [ + 0.01704897012486039, + 1.0715034243210528, + -14.462766975906524 + ], + [ + 4.9941098134764165e-05, + 5.396135000594826e-05, + 1.0 + ] + ], + "local": { + "applied": true, + "trusted_fraction": 0.8965461267725353, + "photometric_improvement": 0.7585453987121582, + "median_displacement_working_px": 4.203385353088379, + "working_scale": 1.0, + "reason": "Accepted constrained optical flow" + }, + "coarse_initialization": true, + "runtime_seconds": 0.867, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "local_dark", + "median_error_px": 0.2211986780166626, + "p95_error_px": 0.5572080612182617, + "status": "PASS", + "matches": 134, + "inliers": 41, + "inlier_ratio": 0.30597014925373134, + "match_coverage": 0.3993538428987651, + "fit_error_px": 1.8134156465530396, + "exposure_gain": 1.81651376146789, + "overlap_fraction": 0.988034, + "blended_fraction": 0.845814, + "transform": [ + [ + 1.0238797149911114, + 0.006181002370084625, + 0.04936646842971212 + ], + [ + 0.0017756844725353854, + 1.0325488363532345, + -2.371990340438794 + ], + [ + 1.735626962622825e-05, + 2.814643891109321e-05, + 1.0 + ] + ], + "local": { + "applied": true, + "trusted_fraction": 0.934589880937545, + "photometric_improvement": 0.755242645740509, + "median_displacement_working_px": 4.174908638000488, + "working_scale": 1.0, + "reason": "Accepted constrained optical flow" + }, + "coarse_initialization": false, + "runtime_seconds": 0.643, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + }, + { + "case": "local_perspective", + "median_error_px": 0.2697524130344391, + "p95_error_px": 0.8960479497909546, + "status": "PASS", + "matches": 95, + "inliers": 31, + "inlier_ratio": 0.3263157894736842, + "match_coverage": 0.162543097835324, + "fit_error_px": 0.9741072058677673, + "exposure_gain": 1.8194444444444444, + "overlap_fraction": 0.972302, + "blended_fraction": 0.496348, + "transform": [ + [ + 1.0480601490876433, + -0.1351890063002856, + 10.468673932405855 + ], + [ + 0.2014033953852853, + 1.0198076088046337, + -92.30038032162444 + ], + [ + -6.282926663853163e-05, + 3.75256295401497e-05, + 1.0 + ] + ], + "local": { + "applied": true, + "trusted_fraction": 0.5873944752683226, + "photometric_improvement": 0.6752087473869324, + "median_displacement_working_px": 3.307561159133911, + "working_scale": 1.0, + "reason": "Accepted constrained optical flow" + }, + "coarse_initialization": false, + "runtime_seconds": 0.64, + "warning": "Confidence and blend masks are heuristic. Inspect real fibers. Global fit error is not independent accuracy; the homography excludes local deformation." + } +] \ No newline at end of file diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..7afa96d62fe0ed9ad836fcafb83c2cdfdcbea5c9 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfea150698861a627597c8136852dc66d493f69bd109d26d413a25a3ffded1de +size 1365203 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..250bbaf6835b9afdff9b70e0a1045278ee5e6f85 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dc63a3ef29c97a8b60a71a542ca073f5ee2e0883db0dc09ecc0417962cc4880 +size 1130793 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..a06549fe9e538c16e4e7b44bc4fff7de0c42c4b0 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ca17f519e70d6dd03027ce379d588128b463a47a8c95976af31548c0c61a956 +size 1546690 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..324ff719ca0276a458b05daa6e981013bb6149d0 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd9bf26c91b99508727d9583ed4d48dd0e66a7a96dad39be60af1adf06e84983 +size 1557333 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..21af5cfe94675115b9b29c85fc4ec26eb3dc44d1 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff36a42bd7ee0d0f3572080871e858161c3011967c4cdf35e1d814cc6c4c9dad +size 17040 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..dd1d3c60994bfb8080a64a7d1263f7c82c9edafa --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc7924c30a309b32dc16913c75f3ab0249044ce1d4f1511ec2cbe9d72b057a19 +size 2703 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..c1de5477b61fdec3ad93a02919b57c657771f4c2 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:287dbaba5ae25e45cd9e7933db73f3d80aad633e01cbfcf519ba1f4b237203d3 +size 1271139 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..6236c7882edfbc523120d36963f8bdc33e77d6a9 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76152e39a1af8c47bc3dc973df887caa88d083954804684031aa1480377dc2ff +size 1130787 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..796b850a0b81ef779073958689e4cd34ca7a4965 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c809139ef812c1d66961cf433f370e9d50d14e9054e4cfdd617263e9cc6ca8b1 +size 3204 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2f4ab0571519e7b95566fd68feeeba41958ef9c4 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d58d3b5c7b834b5492fde29713b148d76ca0f2859402229d116d71e0008a367 +size 196728 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..91ef26d48f4f10ad4adb15f016271e4bc18d25a7 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/perspective_dark-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d80865b4537b7d7f9dfa546918a6122886cfcc21fb7753da5a31a9bac159270 +size 1543634 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reference.png b/hf_workspace/hf_workspace/hf_workspace/reports/reference.png new file mode 100644 index 0000000000000000000000000000000000000000..d6be147b84aa7f25154a0e9fac0fa39d71c67e55 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6b662a16831c2ddec1e08b59c14d73bbcd185b2ff554b880e2e64c8d1d7e6a7 +size 1638451 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..fc60eaee8060be570e4747efd69d58b433f280e9 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf3d00407a04db2e96a58fb1d59e68ecfeac3d217e87811a9c5a3ca0ca8b8a74 +size 1437056 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..fc60eaee8060be570e4747efd69d58b433f280e9 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf3d00407a04db2e96a58fb1d59e68ecfeac3d217e87811a9c5a3ca0ca8b8a74 +size 1437056 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..b220342a512627c8f183893cfbdf47fddf265fe0 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6620e8b5536376ffb0e146998709f03d0030bf804c1d76af28184f1eafc7563c +size 1561046 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..3ee4e5fb77f5ce43f011eccab536ca0971185ecb --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43296779ed4995e585841d7ac572a4a78f44a6bafddf7df183887bccd42eea5e +size 1560026 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..c0d27f69f031b1119a87cd603776903216d7f96a --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d1dbadaf5469bdcde83dc7f494f3828dd7a5763a07776b1aef0d20a31a4451e +size 20741 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..dd1d3c60994bfb8080a64a7d1263f7c82c9edafa --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc7924c30a309b32dc16913c75f3ab0249044ce1d4f1511ec2cbe9d72b057a19 +size 2703 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..370937eef42554c38860fbc6759a14e08a019e64 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0eac6b28c7662154467222d33ab8da84dcf2db84bb5772b3e32c479c7ff78bc +size 1207142 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..13f9d1a7ae8aca758cebf375035d158c983190f6 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9e1e69a07865a5f70c15d94c06d1b655170baf94d42e6b2b926addf0fe9842b +size 1437055 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..796b850a0b81ef779073958689e4cd34ca7a4965 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c809139ef812c1d66961cf433f370e9d50d14e9054e4cfdd617263e9cc6ca8b1 +size 3204 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..28f9331ac10e7d636ac5fb433d29f3a008bf9f3a --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ccd0ffa28ae3c65c9d85958dda40142c1aa2f5680b572639c159e5f96bbd4f6 +size 264248 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/reflection-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..6f4f28bdefeb0b74679ee9bf2ad68904cb760534 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/reflection-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22c892478320dc336e2ce64e9e99e0fa698454a21fff76e6c10cc6945f16cf46 +size 1543889 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-adjusted.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-adjusted.png new file mode 100644 index 0000000000000000000000000000000000000000..37cebe8a8a9af894fa5c5234eee39251daa67a79 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-adjusted.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed492d4ce1469438dcf51593128e93d0580941c76f400116e7caaa8fa01cf435 +size 1451841 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..37cebe8a8a9af894fa5c5234eee39251daa67a79 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed492d4ce1469438dcf51593128e93d0580941c76f400116e7caaa8fa01cf435 +size 1451841 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-checkerboard.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..3147d6ee194e861b0ff4649db490273047984900 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-checkerboard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81392500de8df1cb11e43ea5466d624f8935559ffa1cc793e19732f4327738a3 +size 1567085 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-composite.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-composite.png new file mode 100644 index 0000000000000000000000000000000000000000..298f9302609cc4cf52716f20969627fdb473a33e --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-composite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b17d75bd106b325d9ddfc63f25df71fc1de69974d6211a592e809472783c2382 +size 1557294 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-contribution.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-contribution.png new file mode 100644 index 0000000000000000000000000000000000000000..20cfb67891e809939b2c373a886145ce0841fe85 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-contribution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a57a92824dbe7753696d74e6cacdc72048399053e4730acbeea9376b640549ff +size 17686 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-deformation.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-deformation.png new file mode 100644 index 0000000000000000000000000000000000000000..dd1d3c60994bfb8080a64a7d1263f7c82c9edafa --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-deformation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc7924c30a309b32dc16913c75f3ab0249044ce1d4f1511ec2cbe9d72b057a19 +size 2703 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-difference.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-difference.png new file mode 100644 index 0000000000000000000000000000000000000000..6478edd1f07e5f1d38ab8d23724e18466aa269a6 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-difference.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c85f5685c9951eb46e0df01b62ae45b843b57b34c924b61b564924f3b7330e4 +size 1189736 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-global_aligned.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-global_aligned.png new file mode 100644 index 0000000000000000000000000000000000000000..c547faecc04707616acbcd3e410f041532a817ba --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-global_aligned.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34f91984d516e85340e10285230237fa603c903ac32a9566e43eebab71dd4099 +size 1451836 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-local_confidence.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-local_confidence.png new file mode 100644 index 0000000000000000000000000000000000000000..796b850a0b81ef779073958689e4cd34ca7a4965 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-local_confidence.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c809139ef812c1d66961cf433f370e9d50d14e9054e4cfdd617263e9cc6ca8b1 +size 3204 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-moving.jpg b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-moving.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b8ee5ad4b426d5264986d34cc916ce16fb3e9c36 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-moving.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3fbfed304d736d18dbc6b305fa939a8e156bdb4428a05839854b0827df71cb1 +size 266016 diff --git a/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-overlay.png b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..0f5944b9e64593fbf01872eab7e58b896b182ead --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/reports/rotation_scale-overlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49ca9389b7618a374ef0ee84d86d3f08737cce4300601c2277cd72c80593cc96 +size 1544899 diff --git a/hf_workspace/hf_workspace/hf_workspace/requirements.txt b/hf_workspace/hf_workspace/hf_workspace/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..787b58dd17733786e4d41055dcb6344cc7d7ddec --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/requirements.txt @@ -0,0 +1,8 @@ +numpy==2.5.3 +opencv-python-headless==5.0.0.93 +fastapi==0.141.1 +uvicorn==0.53.0 +python-multipart==0.0.32 +pillow==12.3.0 +pytest==9.1.1 +httpx==0.28.1 diff --git a/hf_workspace/hf_workspace/hf_workspace/scripts/benchmark_client.py b/hf_workspace/hf_workspace/hf_workspace/scripts/benchmark_client.py new file mode 100644 index 0000000000000000000000000000000000000000..918b299623ddedf1b43ecbfdcee4904eaa4f6098 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/scripts/benchmark_client.py @@ -0,0 +1,65 @@ +"""Native-resolution, manually cropped client evaluation. No reference-result pixels enter processing.""" +import sys +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import json,time +import cv2 +import numpy as np +from PIL import Image,ImageOps +from backend.registration import register,RegistrationError + +ROOT=Path(__file__).resolve().parents[1] +SOURCE=Path('/Users/tstore/Desktop/iris test files') +OUT=ROOT/'private_benchmarks/client_iris' +PAIRS=[ +('1','AYD04756.JPG',(2800,2100),'AYD04769.JPG',(2960,2050),'AYD04755.jpg'), +('2','DSC03085.JPG',(2580,2000),'DSC03087.JPG',(2630,2000),'DSC03084.JPG'), +('3','DSC03094.JPG',(2440,1910),'DSC03096.JPG',(2560,1900),'DSC03092.JPG'), +('4','AYD04652.JPG',(2610,2110),'AYD04662.JPG',(2720,2180),'AYD04650.JPG'), +('5','AYD04703.JPG',(1850,2375),'AYD04720.JPG',(3120,2535),'AYD04702.jpg'), +('6','AYD04725.JPG',(2300,2420),'AYD04727.JPG',(2090,2400),'AYD04724.JPG'), +] + +def read(p): + with Image.open(p) as image:return cv2.cvtColor(np.array(ImageOps.exif_transpose(image).convert('RGB')),cv2.COLOR_RGB2BGR) + +def save(p,a): + cv2.imwrite(str(p),a) + +def crop(image,center): + x,y=center + return image[y-1100:y+1100,x-1100:x+1100].copy(),[x-1100,y-1100,x+1100,y+1100] + +def brightness(image): + y,x=np.indices(image.shape[:2]);r=np.hypot(x-1100,y-1100) + g=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) + mask=(r>350)&(r<800)&(g>15)&(g<230) + return float(np.median(g[mask])) + +rows=[] +for sample,a,ac,b,bc,finished in PAIRS: + folder=OUT/sample;folder.mkdir(parents=True,exist_ok=True) + ia,ba=crop(read(SOURCE/sample/a),ac) + ib,bb=crop(read(SOURCE/sample/b),bc) + if brightness(ib)>brightness(ia):a,b,ia,ib,ba,bb=b,a,ib,ia,bb,ba + row=dict(sample=sample,reference=a,moving=b,manual_result=finished,reference_crop=ba,moving_crop=bb,resolution=list(ia.shape[1::-1]),reference_brightness=brightness(ia),moving_brightness=brightness(ib)) + save(folder/'reference.png',ia);save(folder/'moving.png',ib) + save(folder/'manual_result.png',read(SOURCE/sample/finished)) + save(folder/'before_overlay.png',cv2.addWeighted(ia,.5,ib,.5,0)) + try: + result=register(ia,ib,return_maps=True) + row['status']='OUTPUT PRODUCED - VISUAL REVIEW REQUIRED';row['metrics']=result['metrics'] + for k,v in result.items(): + if k not in ('metrics','sampling_map'):save(folder/(k+'.png'),v) + np.savez_compressed(folder/'sampling_map.npz',map=result['sampling_map']) + # Native detail crop at the same reference position, for inspection only. + for k in ('reference','moving','before_overlay','overlay','composite','adjusted','global_aligned'): + im=cv2.imread(str(folder/(k+'.png'))) + save(folder/(k+'-detail.png'),im[500:1000,1100:1600]) + except RegistrationError as exc: + row.update(status='REJECTED',reason=str(exc)) + rows.append(row) + (OUT/'metrics.json').write_text(json.dumps(rows,indent=2)) + print(json.dumps(row),flush=True) + del ia,ib + if 'result' in locals():del result diff --git a/hf_workspace/hf_workspace/hf_workspace/scripts/create_benchmark_pdf.py b/hf_workspace/hf_workspace/hf_workspace/scripts/create_benchmark_pdf.py new file mode 100644 index 0000000000000000000000000000000000000000..254fe6ae1319428246aa48c6efd837c28a8c6092 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/scripts/create_benchmark_pdf.py @@ -0,0 +1,104 @@ +"""Build a client-shareable report from saved benchmark measurements and images. + +Optional report dependency: pip install reportlab +Run from any directory: python scripts/create_benchmark_pdf.py +""" +import json +from pathlib import Path +from reportlab.pdfgen import canvas +from reportlab.lib import colors +from reportlab.lib.utils import ImageReader +from reportlab.platypus import Paragraph, Table, TableStyle +from reportlab.lib.styles import ParagraphStyle + +ROOT = Path(__file__).resolve().parents[1] +REPORTS = ROOT / 'reports' +OUTPUT = REPORTS / 'Iris_Registration_Benchmark.pdf' +ROWS = json.loads((REPORTS / 'metrics.json').read_text()) +BY_NAME = {row['case']: row for row in ROWS} +W, H = 595.28, 841.89 +M = 43 +INK = colors.HexColor('#172D37') +MUTED = colors.HexColor('#536873') +TEAL = colors.HexColor('#087E80') +PALE = colors.HexColor('#EAF5F3') +LINE = colors.HexColor('#D8E4E8') +c = canvas.Canvas(str(OUTPUT), pagesize=(W,H), pageCompression=1) +c.setTitle('Iris Registration | Synthetic Benchmark') +c.setAuthor('Iris Registration POC') +c.setSubject('Controlled synthetic evaluation; real-client validation pending') +style = ParagraphStyle('body', fontName='Helvetica', fontSize=10, leading=15, textColor=MUTED) + + +def para(text,x,y,width=W-2*M,size=10,color=MUTED): + st = ParagraphStyle('custom', parent=style, fontSize=size, leading=size*1.45,textColor=color) + p = Paragraph(text, st) + _, height = p.wrap(width,H) + p.drawOn(c,x,y-height) + return y-height + + +def label(text,x,y,size=10,color=INK,bold=False): + c.setFillColor(color) + c.setFont('Helvetica-Bold' if bold else 'Helvetica',size) + c.drawString(x,y,text) + + +def page(title,sub,page_no): + c.setFillColor(TEAL);c.rect(0,H-8,W,8,fill=1,stroke=0) + label('IRIS REGISTRATION / PROOF OF CONCEPT',M,H-43,9,TEAL,True) + label('22 SEPTEMBER 2026',W-155,H-43,8,MUTED) + label(title,M,H-87,25,INK,True) + para(sub,M,H-105,size=10) + c.setStrokeColor(LINE);c.line(M,47,W-M,47) + label('SYNTHETIC BENCHMARK - REAL-PHOTO VALIDATION PENDING',M,31,7,MUTED) + label(f'{page_no} / 3',W-M-22,31,8,MUTED) + + +def picture(path,x,top,size,caption): + c.drawImage(ImageReader(str(REPORTS/path)),x,top-size,width=size,height=size,mask='auto') + para(caption,x,top-size-9,width=size,size=9) + + +page('Registration benchmark','Alignment results and visual comparisons from controlled synthetic tests.',1) +y=H-157 +c.setFillColor(PALE);c.roundRect(M,y-81,W-2*M,81,8,fill=1,stroke=0) +label('7 / 7 synthetic cases passed',M+16,y-27,19,TEAL,True) +para('Every case achieved a 95th-percentile correspondence error below 1 pixel at 1000 x 1000 resolution.',M+16,y-41,W-2*M-32,10,INK) +y-=106 +names={'identity':'Identity / JPEG roundtrip','rotation_scale':'Rotation + scale','perspective_dark':'Perspective + darker exposure','reflection':'Rotation + scale + reflection','local_warp':'Local distortion','local_dark':'Local distortion + darker exposure','local_perspective':'Local distortion + perspective + darker exposure'} +head=['Test case','Median (px)','95th pct. (px)','Result'] +data=[head] +for row in ROWS: + data.append([Paragraph(names[row['case']],ParagraphStyle('cell',parent=style,fontSize=9,leading=12,textColor=INK)),f"{row['median_error_px']:.3f}",f"{row['p95_error_px']:.3f}",row['status']]) +t=Table(data,colWidths=[266,79,88,76],rowHeights=[29]+[37]*7) +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),9),('ROWBACKGROUNDS',(0,1),(-1,-1),[colors.white,colors.HexColor('#F3F7F8')]),('TEXTCOLOR',(1,1),(-1,-1),INK),('TEXTCOLOR',(-1,1),(-1,-1),TEAL),('LINEBELOW',(0,-1),(-1,-1),.5,LINE)])) +_,th=t.wrap(W-2*M,H);t.drawOn(c,M,y-th);y-=th+24 +label('What this demonstrates',M,y,12,INK,True) +y=para('The prototype achieved subpixel alignment across all seven controlled test cases. The 95th-percentile error means that 95% of evaluated points had an error at or below the reported value. Lower values indicate closer alignment; this is not a percentage-accuracy score.',M,y-12) +y-=21 +label('What is still unverified',M,y,12,INK,True) +para('These seven cases are variations of one synthetic iris, not seven real eyes. They do not establish accuracy on customer photographs, anatomical fidelity, or a production success rate. The next milestone is review of 3-5 real image pairs at native resolution.',M,y-12) +c.showPage() + + +def case_page(name,title,sub,num): + row=BY_NAME[name] + page(title,sub,num) + y=H-159 + label(f"Median {row['median_error_px']:.3f} px | 95th percentile {row['p95_error_px']:.3f} px | PASS",M,y,11,TEAL,True) + size=235;gap=39;top=y-22 + picture('reference.png',M,top,size,'01 / Reference - synthetic test fixture') + picture(f'{name}-moving.jpg',M+size+gap,top,size,'02 / Input with known simulated changes') + top-=size+58 + picture(f'{name}-overlay.png',M,top,size,'03 / Alignment overlay') + picture(f'{name}-composite.png',M+size+gap,top,size,'04 / Processed output using source-image detail') + bottom=top-size-45 + para("The processed output uses information from the supplied test images; no new iris texture is generated during processing. Differences at the overlay borders include areas outside the shared image coverage.",M,bottom,size=9) + c.showPage() + +case_page('local_warp','Local distortion recovered','Alignment results for an input with simulated local geometric differences.',2) +case_page('local_perspective','Combined changes recovered','Local distortion, rotation, scale, perspective and reduced exposure in one test.',3) + +c.save() +print(OUTPUT) diff --git a/hf_workspace/hf_workspace/hf_workspace/scripts/create_client_report.py b/hf_workspace/hf_workspace/hf_workspace/scripts/create_client_report.py new file mode 100644 index 0000000000000000000000000000000000000000..49012962b215c0d0d32e061940e171d692b8c432 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/scripts/create_client_report.py @@ -0,0 +1,92 @@ +"""Results-only report of the real client baseline; no algorithm disclosures.""" +import io,json,html +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 Paragraph,Table,TableStyle +from reportlab.lib.styles import ParagraphStyle + +ROOT=Path(__file__).resolve().parents[1] +OUT=ROOT/'private_benchmarks/client_iris' +rows=json.loads((OUT/'metrics.json').read_text()) +PDF=OUT/'Client_Iris_Benchmark.pdf' +W,H=595.28,841.89;M=42;INK=colors.HexColor('#172D37');GRAY=colors.HexColor('#536873');TEAL=colors.HexColor('#087E80');RED=colors.HexColor('#9D422F') +c=canvas.Canvas(str(PDF),pagesize=(W,H));c.setTitle('Client Iris Samples - Initial Benchmark');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,color=GRAY): + p=Paragraph(s,ParagraphStyle('p',parent=style,fontSize=size,leading=size*1.45,textColor=color));_,height=p.wrap(width,800);p.drawOn(c,x,y-height);return y-height + +def label(s,x,y,size=12,color=INK): + c.setFillColor(color);c.setFont('Helvetica-Bold',size);c.drawString(x,y,s) + +def page(title,subtitle,n): + c.setFillColor(TEAL);c.rect(0,H-8,W,8,fill=1,stroke=0) + label('CLIENT IRIS SAMPLES / INITIAL EVALUATION',M,H-43,9,TEAL) + label(title,M,H-87,25) + text(subtitle,M,H-105) + c.setStrokeColor(colors.HexColor('#D8E4E8'));c.line(M,47,W-M,47) + text('REAL CLIENT IMAGES - PRELIMINARY RESULTS / 22 SEPTEMBER 2026',M,36,size=7) + text(f'{n} / 7',W-65,36,width=30,size=8) + +def image(path,x,top,size,caption): + with Image.open(path) as im: + im=ImageOps.contain(im.convert('RGB'),(1100,1100)) + 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-7,width=size,size=9) + +page('Real-image benchmark','Six client-supplied pairs evaluated using the current prototype.',1) +y=H-158 +label('3 pairs produced review outputs. 3 were rejected.',M,y,17,TEAL) +y=text('Output generation is an operational result, not an accuracy pass. None of these pairs has an independently verified pixel-accuracy score.',M,y-15)-25 +head=['Sample','Result','Finished target matched?'] +data=[head]+[[r['sample'],'Review output produced' if 'metrics' in r else 'Rejected - no output','Not validated' if 'metrics' in r else 'No'] for r in rows] +t=Table(data,colWidths=[60,245,206],rowHeights=[30]+[32]*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),10),('VALIGN',(0,0),(-1,-1),'MIDDLE'),('LEFTPADDING',(0,0),(-1,-1),10),('ROWBACKGROUNDS',(0,1),(-1,-1),[colors.white,colors.HexColor('#F0F5F6')])])) +_,height=t.wrap(511,800);t.drawOn(c,M,y-height);y-=height+28 +for title,body in [ +('Scope of this test','Each sample includes two 6000 x 4000 originals and one Photoshop-finished reference. Original photographs were manually cropped to 2200 x 2200 pixels around the iris without resizing. The brighter iris crop was used as the reference. Finished client images were used only for visual comparison, never as processing inputs.'), +('What the outputs show','Samples 2, 5 and 6 produced partial review results. Remaining glare, occlusions and some fine-detail mismatch are visible. The outputs do not reproduce the client\'s isolated, finished iris presentation. Samples 1, 3 and 4 were rejected because a sufficiently reliable alignment could not be established.'), +('Accuracy and next milestone','The real pairs have no supplied ground-truth correspondence map. An honest pixel-accuracy claim requires separately checked matching landmarks and native-resolution review. These findings show that the earlier synthetic results do not establish readiness on real photographs. Further development and client review are required.')]: + label(title,M,y,12);y=text(body,M,y-12,size=9.5)-21 +c.showPage() + +reasons={'1':'Too few dependable correspondences to produce an alignment.','3':'The initial alignment could not be verified reliably.','4':'The photographs did not support a sufficiently reliable alignment.'} +cards=[] +for idx,r in enumerate(rows,2): + n=r['sample'];folder=OUT/n;ok='metrics' in r + status='Review output produced - not accuracy-validated' if ok else 'Rejected - no processed output' + page('Sample '+n,status,idx) + text(f"Reference: {r['reference']}
Second original: {r['moving']}
Client-finished reference: {r['manual_result']}",M,H-151,size=9) + size=160;gap=15;top=H-222 + image(folder/'reference.png',M,top,size,'Reference original / native crop') + image(folder/'moving.png',M+size+gap,top,size,'Second original / native crop') + image(folder/'manual_result.png',M+2*(size+gap),top,size,'Client-finished reference / separate framing') + top-=215 + if ok: + image(folder/'before_overlay.png',M,top,size,'Overlay before registration') + image(folder/'overlay.png',M+size+gap,top,size,'Overlay after registration') + image(folder/'composite.png',M+2*(size+gap),top,size,'Prototype output / incomplete finish') + y=top-size-53 + label('Review finding',M,y,12) + y=text('Registration produced an output, but glare and differences in fine structures remain. The client-finished image is shown at its own framing and scale; it is a visual target, not a pixel-for-pixel accuracy reference.',M,y-12,size=9.5)-19 + label('Detail comparison',M,y,11) + # Detail images have matching reference coordinates. Link to lossless originals in HTML. + text('A 500 x 500 native-resolution detail comparison is included in the accompanying local HTML report. The original PNG outputs remain available for full-resolution inspection. No generated iris texture was introduced during processing.',M,y-12,size=9) + else: + label('No output issued',M,top-12,15,RED) + y=text(reasons[n],M,top-27,size=11)-23 + label('Review finding',M,y,12) + text('This pair is a current limitation of the prototype. No substitute or generated result is presented. The original crops and client-finished reference are included for a complete record of the test.',M,y-13,size=10) + c.showPage() + pics=['reference','moving','manual_result']+(['before_overlay','overlay','composite'] if ok else []) + panels=''.join(f'
{html.escape(k.replace("_"," "))}
' for k in pics) + details='' + if ok: + details='

Native detail: same reference position, 500 x 500 pixels

'+''.join(f'
{k.replace("_"," ")}
' for k in ['reference','adjusted','overlay'])+'
' + cards.append(f'

Sample {n}: {status}

Reference: {r["reference"]} | Second original: {r["moving"]} | Finished reference: {r["manual_result"]}

{panels}
{details}

{"Glare and fine-detail differences remain; finished target not validated." if ok else reasons[n]}

') +c.save() +(OUT/'index.html').write_text('Client iris benchmark

Real client iris benchmark

Six real pairs. Three review outputs, three rejected. No independently verified pixel-accuracy scores. Native-resolution 2200 x 2200 manually selected crops; client-finished images used only for comparison. Click any image for its full-resolution PNG.

These results do not reproduce the finished client targets. Glare and some fine-detail misalignment remain. No generative texture processing was used.

Download results PDF'+''.join(cards)+'') +print(PDF) diff --git a/hf_workspace/hf_workspace/hf_workspace/synthetic_cases.py b/hf_workspace/hf_workspace/hf_workspace/synthetic_cases.py new file mode 100644 index 0000000000000000000000000000000000000000..b21546f7d013af56cef27bf6bae3734e65343045 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/synthetic_cases.py @@ -0,0 +1,44 @@ +"""Deterministic synthetic pairs with correspondence ground truth.""" +import cv2 +import numpy as np + +CASE_NAMES = ['identity', 'rotation_scale', 'perspective_dark', 'reflection', + 'local_warp', 'local_dark', 'local_perspective'] + + +def make_case(reference, name): + h, w = reference.shape[:2] + yy, xx = np.indices((h,w), dtype=np.float32) + step = max(1, round(w/50)) + grid = np.stack([xx[::step,::step], yy[::step,::step]], -1).reshape(-1,2) + radius = np.linalg.norm((grid-[w/2,h/2]) / [w,h], axis=1) + grid = grid[(radius>.17)&(radius<.43)] + matrix = np.eye(3) + if name != 'identity' and not name.startswith('local_') or name == 'local_perspective': + matrix[:2] = cv2.getRotationMatrix2D((w/2,h/2),11,.94) + matrix[:2,2] += [.022*w,-.018*h] + if name in ('perspective_dark', 'local_perspective'): + matrix[2,:2] = [.06/w, -.04/h] + if name.startswith('local_'): + r = np.hypot(xx/w-.5, yy/h-.5) + dx = .009*w*np.sin(yy/(.09*h))*np.exp(-((r-.3)/.18)**2) + dy = .007*h*np.sin(xx/(.11*w))*np.exp(-((r-.3)/.18)**2) + moving = cv2.remap(reference, xx+dx, yy+dy, cv2.INTER_LINEAR) + gx, gy = grid[:,0].astype(int), grid[:,1].astype(int) + truth_points = grid + np.stack([dx[gy,gx],dy[gy,gx]],-1) + else: + moving = reference + truth_points = grid + moving = cv2.warpPerspective(moving,matrix,(w,h)) + moving_points = cv2.perspectiveTransform(grid[None],matrix)[0] + if name in ('perspective_dark','local_dark','local_perspective'): + moving = np.rint(moving*.55).astype(np.uint8) + if name == 'reflection': + cv2.circle(moving,(round(.69*w),round(.32*h)),round(.065*w),(255,255,255),-1) + moving = cv2.imdecode(cv2.imencode('.jpg',moving,[cv2.IMWRITE_JPEG_QUALITY,93])[1],cv2.IMREAD_COLOR) + return moving, truth_points.astype(np.float32), moving_points + + +def mapping_errors(mapping, reference_points, moving_points): + predicted = cv2.remap(mapping,reference_points[:,0,None],reference_points[:,1,None],cv2.INTER_LINEAR)[:,0] + return np.linalg.norm(predicted-moving_points,axis=1) diff --git a/hf_workspace/hf_workspace/hf_workspace/tests/test_registration.py b/hf_workspace/hf_workspace/hf_workspace/tests/test_registration.py new file mode 100644 index 0000000000000000000000000000000000000000..350edac990039621aed333ac2e805b19e5ae4611 --- /dev/null +++ b/hf_workspace/hf_workspace/hf_workspace/tests/test_registration.py @@ -0,0 +1,87 @@ +import cv2 +import numpy as np +import pytest +from fastapi.testclient import TestClient +from backend.app import app +from backend.registration import register, RegistrationError + + +@pytest.fixture +def iris(): + return cv2.resize(cv2.imread('fixtures/synthetic-iris.png'), (800, 800)) + + +@pytest.mark.parametrize('angle,scale,gain', [(0, 1, 1), (12, .92, 1), (-8, 1.04, .55)]) +def test_known_transform(iris, angle, scale, gain): + transform = np.vstack([cv2.getRotationMatrix2D((400, 400), angle, scale), [0, 0, 1]]) + transform[:2, 2] += [16, -12] + moving = np.clip(cv2.warpPerspective(iris, transform, (800, 800))*gain, 0, 255).astype(np.uint8) + result = register(iris, moving) + pts = np.float32([[[200, 200], [600, 200], [600, 600], [200, 600]]]) + recovered = cv2.perspectiveTransform(cv2.perspectiveTransform(pts, transform), np.array(result['metrics']['transform'])) + assert np.max(np.linalg.norm(recovered-pts, axis=2)) < 1 + assert np.array_equal(result['composite'][result['contribution'] == 0], iris[result['contribution'] == 0]) + + +def test_blank_rejected(): + with pytest.raises(RegistrationError): + register(np.zeros((400,400,3), np.uint8), np.zeros((400,400,3), np.uint8)) + + +def test_unrelated_rejected(iris): + noise = np.random.default_rng(91).integers(0, 256, iris.shape, dtype=np.uint8) + with pytest.raises(RegistrationError): + register(iris, noise) + + +def test_api(iris): + client = TestClient(app) + assert client.get('/api/health').status_code == 200 + assert client.post('/api/register', files={'reference': ('x.jpg', b'bad'), 'moving': ('y.jpg', b'bad')}).status_code == 422 + data = cv2.imencode('.jpg', iris)[1].tobytes() + response = client.post('/api/register', files={'reference': ('x.jpg', data), 'moving': ('y.jpg', data)}) + assert response.status_code == 200 + assert response.json()['images']['aligned'].startswith('data:image/png;base64,') + + +def test_exposure_disabled_and_different_sizes(iris): + moving = cv2.resize(iris, (640, 640)) + result = register(iris, moving, exposure=False) + assert result['metrics']['exposure_gain'] == 1 + assert result['aligned'].shape == iris.shape + + +@pytest.mark.parametrize('case,size', [('local_warp',1000), ('local_dark',1000), ('local_perspective',1000), ('local_warp',1600)]) +def test_local_known_correspondences(case, size): + from synthetic_cases import make_case, mapping_errors + reference = cv2.resize(cv2.imread('fixtures/synthetic-iris.png'),(size,size)) + moving, truth, source = make_case(reference,case) + result = register(reference,moving,return_maps=True) + assert result['metrics']['local']['applied'] + errors = mapping_errors(result['sampling_map'],truth,source) + # Threshold scales with image size; independent coordinates never fit flow. + assert np.percentile(errors,95) < size/1000 + assert np.array_equal(result['composite'][result['contribution']==0],reference[result['contribution']==0]) + assert np.all(result['contribution'][result['local_confidence']==0] == 0) + # Actual output must be one resample of original pixels, not a warped intermediate. + expected = cv2.remap(moving,result['sampling_map'][...,0],result['sampling_map'][...,1],cv2.INTER_LINEAR) + assert np.array_equal(result['aligned'],expected) + + +@pytest.mark.parametrize('case', ['identity','rotation_scale','perspective_dark','reflection']) +def test_local_does_not_degrade_global(case): + from synthetic_cases import make_case + reference = cv2.resize(cv2.imread('fixtures/synthetic-iris.png'),(1000,1000)) + moving, _, _ = make_case(reference,case) + baseline = register(reference,moving,local=False,return_maps=True) + refined = register(reference,moving,local=True,return_maps=True) + assert not refined['metrics']['local']['applied'] + assert np.array_equal(baseline['sampling_map'],refined['sampling_map']) + + +def test_local_disabled_still_rejects_nonlinear_pair(): + from synthetic_cases import make_case + reference = cv2.resize(cv2.imread('fixtures/synthetic-iris.png'),(1000,1000)) + moving, _, _ = make_case(reference,'local_warp') + with pytest.raises(RegistrationError): + register(reference,moving,local=False) diff --git a/hf_workspace/hf_workspace/requirements-ml.txt b/hf_workspace/hf_workspace/requirements-ml.txt new file mode 100644 index 0000000000000000000000000000000000000000..356ac255aebfaeab7c559ff5dbce6ce30490f6fb --- /dev/null +++ b/hf_workspace/hf_workspace/requirements-ml.txt @@ -0,0 +1,3 @@ +-r requirements.txt +torch==2.14.0 +kornia==0.8.3 diff --git a/hf_workspace/hf_workspace/scripts/create_learned_report.py b/hf_workspace/hf_workspace/scripts/create_learned_report.py new file mode 100644 index 0000000000000000000000000000000000000000..38ccfa325b8485d71da3ed0eb66d6353fb01a2dd --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/create_learned_report.py @@ -0,0 +1,74 @@ +"""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(''+s+'' for s in values[0]);body=''.join(''+''.join(''+str(v)+'' for v in r)+'' 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'
{key.replace("_"," ")}
' for key in keys) + sections.append(f'

Sample {n} — {"review required" if ok else "not aligned"}

{row["reference"]} + {row["moving"]}

{panels}
') +(OUT/'index.html').write_text('Real iris evaluation

Real iris evaluation

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.

Download PDF · Independent landmark review

'+headers+''+body+'
'+''.join(sections)+'') +print(OUT/'Real_Iris_Evaluation.pdf') diff --git a/hf_workspace/hf_workspace/scripts/create_research_review.py b/hf_workspace/hf_workspace/scripts/create_research_review.py new file mode 100644 index 0000000000000000000000000000000000000000..73d6779fd5d025f1723fde5f59c20a2d1cafd3af --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/create_research_review.py @@ -0,0 +1,23 @@ +"""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'''

Sample {n} · research candidate

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.

Reference
Aligned second photograph, exposure adjusted
Overlay — examine fibers, not glare

Download aligned source before exposure adjustment

''') +(OUT/'index.html').write_text('''Iris research review

Real iris alignment — research iteration

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.

Mark independent corresponding landmarks · Original baseline report

Sample 1 — unresolved

The candidate still disagrees with the image evidence. It is not included as a successful result.

'''+''.join(cards)+'') +(OUT/'landmarks.html').write_text(r'''Independent iris landmarks

Mark matching real structures

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.

Reference original

Second original

Back to review

''') +print(OUT/'index.html') diff --git a/hf_workspace/hf_workspace/scripts/evaluate_all_pairs.py b/hf_workspace/hf_workspace/scripts/evaluate_all_pairs.py new file mode 100644 index 0000000000000000000000000000000000000000..73b4c8764ef41cad00826d29b1b960401b311bc8 --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/evaluate_all_pairs.py @@ -0,0 +1,54 @@ +"""Repeatable evaluation of all discovered client groups and cached research matches. + +Finished Photoshop references are never counted as additional source photographs. +Use --recompute-matches to run inference again from the saved native crops. +""" +import argparse,hashlib,itertools,json,sys +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from PIL import Image +import numpy as np +from backend.experimental.evaluation import evaluate_correspondences + +ROOT=Path(__file__).resolve().parents[1] +p=argparse.ArgumentParser();p.add_argument('--source',type=Path,default=Path('/Users/tstore/Desktop/iris test files'));p.add_argument('--recompute-matches',action='store_true');args=p.parse_args() +out=ROOT/'private_benchmarks/evaluation';out.mkdir(exist_ok=True) +manifest=[];results=[];matcher=None +for folder in sorted(x for x in args.source.iterdir() if x.is_dir()): + originals=[];finished=[] + for file in sorted(folder.iterdir()): + if file.suffix.lower() not in ['.jpg','.jpeg','.png']:continue + with Image.open(file) as im: + software=str(im.getexif().get(305,''));entry=dict(file=file.name,size=list(im.size),sha256=hashlib.sha256(file.read_bytes()).hexdigest()) + (finished if 'Photoshop' in software else originals).append(entry) + pairs=list(itertools.combinations(originals,2)) + manifest.append(dict(group=folder.name,originals=originals,finished_references=finished,original_pair_count=len(pairs))) + # Current crop manifest explicitly identifies reference/moving originals. + base=json.loads((ROOT/'private_benchmarks/client_iris/metrics.json').read_text()) + known=next((r for r in base if r['sample']==folder.name),None) + for a,b in pairs: + row=dict(sample=folder.name,originals=[a['file'],b['file']]) + if known is None or set(row['originals'])!={known['reference'],known['moving']}: + row.update(status='needs native crop preparation');results.append(row);continue + cropdir=ROOT/'private_benchmarks/client_iris'/folder.name + row.update(reference=known['reference'],moving=known['moving'],reference_crop=known['reference_crop'],moving_crop=known['moving_crop']) + if args.recompute_matches: + import cv2 + from backend.experimental.matching import LearnedMatcher + from backend.experimental.patch_validation import validate_patches + if matcher is None:matcher=LearnedMatcher(ROOT/'models/loftr_outdoor.ckpt') + ref=cv2.imread(str(cropdir/'reference.png'));mov=cv2.imread(str(cropdir/'moving.png')) + rawref,rawmov=matcher(ref,mov);rp,mp=validate_patches(ref,mov,rawref,rawmov) + raw_count=len(rawref) + np.savez_compressed(out/f'{folder.name}-correspondences.npz',reference=rp,moving=mp) + else: + cached=ROOT/'private_benchmarks/research' + matches=np.load(cached/f'{folder.name}-loftr_patch-matches.npz');rp,mp=matches['reference'],matches['moving'] + raw_count=len(np.load(cached/f'{folder.name}-loftr-matches.npz')['reference']) + row.update(raw_matches=raw_count,verified_matches=len(rp),patch_survival_percent=round(100*len(rp)/max(raw_count,1),2)) + row['evaluation']=evaluate_correspondences(rp,mp,(2200,2200)) + row['status']='evaluated — needs independent validation' if row['evaluation']['p95_px'] is not None else 'insufficient evidence' + results.append(row);print(json.dumps(row),flush=True) +(out/'inventory.json').write_text(json.dumps(manifest,indent=2)) +(out/'cross_validation.json').write_text(json.dumps(results,indent=2)) +print('Discovered original pairs:',sum(m['original_pair_count'] for m in manifest)) diff --git a/hf_workspace/hf_workspace/scripts/evaluate_matchers.py b/hf_workspace/hf_workspace/scripts/evaluate_matchers.py new file mode 100644 index 0000000000000000000000000000000000000000..b7b7b07c4fe91d379478f77cebc6e4dbca4b5c74 --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/evaluate_matchers.py @@ -0,0 +1,23 @@ +"""Compare matchers using spatially held-out AUTOMATIC matches, not human ground truth.""" +import sys,json,time +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import cv2,numpy as np +from backend.experimental.matching import sift_matches,LearnedMatcher +ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/research';OUT.mkdir(exist_ok=True) +matcher=LearnedMatcher(ROOT/'models/loftr_outdoor.ckpt') +rows=[] +for name,fn in [('iris_sift',sift_matches),('loftr',matcher)]: + for sample in range(1,7): + folder=ROOT/'private_benchmarks/client_iris'/str(sample) + a=cv2.imread(str(folder/'reference.png'));b=cv2.imread(str(folder/'moving.png'));start=time.perf_counter() + dst,src=fn(a,b) + row=dict(sample=sample,method=name,matches=len(src),seconds=round(time.perf_counter()-start,2)) + np.savez_compressed(OUT/f'{sample}-{name}-matches.npz',reference=dst,moving=src) + if len(src)>=16: + hold=((dst[:,0]//150+dst[:,1]//150).astype(int)%5)==0 + h,ins=cv2.findHomography(src[~hold],dst[~hold],cv2.USAC_MAGSAC,4) + if h is not None and hold.any(): + pred=cv2.perspectiveTransform(src[hold,None],h)[:,0];err=np.linalg.norm(pred-dst[hold],axis=1) + row.update(train_inliers=int(ins.sum()),train_count=int((~hold).sum()),test_count=int(hold.sum()),heldout_median=float(np.median(err)),heldout_p95=float(np.percentile(err,95)),matrix=h.tolist()) + rows.append(row);(OUT/'matchers.json').write_text(json.dumps(rows,indent=2));print(json.dumps(row),flush=True) diff --git a/hf_workspace/hf_workspace/scripts/evaluate_mesh.py b/hf_workspace/hf_workspace/scripts/evaluate_mesh.py new file mode 100644 index 0000000000000000000000000000000000000000..20789d9901a178a233115edfab27a531e7388e82 --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/evaluate_mesh.py @@ -0,0 +1,29 @@ +import sys,json +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import cv2,numpy as np +from backend.experimental.mesh import fit_mesh,dense_mesh +from backend.experimental.preprocessing import iris_mask,glare_mask +ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/research' +rows=[] +for rec in json.loads((OUT/'matchers-patch.json').read_text()): + if rec['method'] not in ('loftr','loftr_patch') or 'matrix' not in rec:continue + n,method=rec['sample'],rec['method'];pairs=np.load(OUT/f'{n}-{method}-matches.npz');dst,src=pairs['reference'],pairs['moving'] + hold=((dst[:,0]//150+dst[:,1]//150).astype(int)%5)==0 + coeff=fit_mesh(dst[~hold],src[~hold],np.array(rec['matrix']),(2200,2200)) + mapping,good,delta=dense_mesh(coeff,np.array(rec['matrix']),(2200,2200)) + pred=cv2.remap(mapping,dst[hold,0,None],dst[hold,1,None],cv2.INTER_LINEAR)[:,0];errors=np.linalg.norm(pred-src[hold],axis=1) + row=dict(sample=n,method=method+'_mesh',matches=rec['matches'],test_count=rec['test_count'],global_median=rec['heldout_median'],global_p95=rec['heldout_p95'],mesh_median=float(np.median(errors)),mesh_p95=float(np.percentile(errors,95))) + path=ROOT/'private_benchmarks/client_iris'/str(n);a=cv2.imread(str(path/'reference.png'));b=cv2.imread(str(path/'moving.png')) + aligned=cv2.remap(b,mapping[...,0],mapping[...,1],cv2.INTER_LINEAR) + roi=iris_mask(a);clean=roi&~glare_mask(a)&~glare_mask(aligned) + row['geometry_valid_fraction']=float(good[roi].mean()) + row['status']='candidate - needs human validation' if row['mesh_median']<4 and row['mesh_p95']<12 and row['geometry_valid_fraction']>.99 else 'rejected' + ga=cv2.cvtColor(a,cv2.COLOR_BGR2GRAY);gb=cv2.cvtColor(aligned,cv2.COLOR_BGR2GRAY);usable=clean&(ga>20)&(gb>20) + gain=float(np.clip(np.median(ga[usable]/np.maximum(gb[usable],1)),1,2.5)) + adjusted=np.clip(aligned.astype(np.float32)*gain,0,255).astype(np.uint8) + folder=OUT/f'{n}-{method}_mesh';folder.mkdir(exist_ok=True) + cv2.imwrite(str(folder/'aligned.png'),aligned);cv2.imwrite(str(folder/'adjusted.png'),adjusted);cv2.imwrite(str(folder/'overlay.png'),cv2.addWeighted(a,.5,adjusted,.5,0));cv2.imwrite(str(folder/'geometry_valid.png'),good.astype(np.uint8)*255) + # No composite until image-space confidence and manual review are established. + np.savez_compressed(folder/'mapping.npz',map=mapping) + rows.append(row);print(json.dumps(row),flush=True);(OUT/'mesh.json').write_text(json.dumps(rows,indent=2)) diff --git a/hf_workspace/hf_workspace/scripts/refine_client_research.py b/hf_workspace/hf_workspace/scripts/refine_client_research.py new file mode 100644 index 0000000000000000000000000000000000000000..6cf1dc3e5933c8c9bc1ddd2f5d6496d9f01b07ba --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/refine_client_research.py @@ -0,0 +1,47 @@ +"""Evaluate both matchers plus masked local refinement. Research only.""" +import sys,json,time +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import cv2,numpy as np +from backend.experimental.refinement import local_map +from backend.experimental.preprocessing import iris_mask,glare_mask +ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/research' +rows=[] +for rec in json.loads((OUT/'matchers.json').read_text()): + n,method=rec['sample'],rec['method'];folder=OUT/f'{n}-{method}';folder.mkdir(exist_ok=True) + row=dict(rec) + if 'matrix' not in rec or rec.get('train_inliers',0)<12 or rec['train_inliers']/rec['train_count']<.3 or rec['test_count']<8: + row['status']='insufficient evidence';rows.append(row);continue + source=ROOT/'private_benchmarks/client_iris'/str(n) + a=cv2.imread(str(source/'reference.png'));b=cv2.imread(str(source/'moving.png')) + matrix=np.array(rec['matrix']);h,w=a.shape[:2] + # Reject implausible global geometry before attempting to produce a preview. + corners=np.float32([[0,0],[w,0],[w,h],[0,h]]) + wc=cv2.perspectiveTransform(corners[None],matrix)[0] + area=cv2.contourArea(wc,oriented=True)/(h*w) + if not .520)&(gb>20) + gain=float(np.clip(np.median(ga[clean]/np.maximum(gb[clean],1)),1,2.5)) + adjusted=np.clip(aligned.astype(np.float32)*gain,0,255).astype(np.uint8) + weight=(trust&clean).astype(np.float32)*.35 + # Conservative baseline composite; no speculative reflection removal here. + composite=np.rint(a*(1-weight[...,None])+adjusted*weight[...,None]).astype(np.uint8) + outputs=dict(aligned=aligned,adjusted=adjusted,overlay=cv2.addWeighted(a,.5,adjusted,.5,0),composite=composite,confidence=trust.astype(np.uint8)*255,global_aligned=global_image) + for key,value in outputs.items():cv2.imwrite(str(folder/(key+'.png')),value) + np.savez_compressed(folder/'mapping.npz',map=mapping) + row['exposure_gain']=gain + rows.append(row);(OUT/'refinement.json').write_text(json.dumps(rows,indent=2));print(json.dumps(row),flush=True) +(OUT/'refinement.json').write_text(json.dumps(rows,indent=2)) diff --git a/hf_workspace/hf_workspace/scripts/run_learned_batch.py b/hf_workspace/hf_workspace/scripts/run_learned_batch.py new file mode 100644 index 0000000000000000000000000000000000000000..2433cf6c22e3f50e5165a36c3c47e0bdce0bb0c9 --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/run_learned_batch.py @@ -0,0 +1,17 @@ +"""Run the same learned review path used by the API on all prepared client pairs.""" +import json,sys +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import cv2 +from backend.review import review_pair +ROOT=Path(__file__).resolve().parents[1];SOURCE=ROOT/'private_benchmarks/client_iris';OUT=ROOT/'private_benchmarks/learned_batch';OUT.mkdir(exist_ok=True) +rows=[] +for entry in json.loads((SOURCE/'metrics.json').read_text()): + sample=entry['sample'];folder=OUT/sample;folder.mkdir(exist_ok=True) + reference=cv2.imread(str(SOURCE/sample/'reference.png'));moving=cv2.imread(str(SOURCE/sample/'moving.png')) + result=review_pair(reference,moving,engine='learned') + for name,value in result.items(): + if name!='metrics':cv2.imwrite(str(folder/(name+'.png')),value) + row=dict(sample=sample,reference=entry['reference'],moving=entry['moving'],metrics=result['metrics']) + rows.append(row);(OUT/'results.json').write_text(json.dumps(rows,indent=2)) + print(json.dumps(dict(sample=sample,status=result['metrics']['status'],evaluation=result['metrics'].get('evaluation'))),flush=True) diff --git a/hf_workspace/hf_workspace/scripts/score_landmarks.py b/hf_workspace/hf_workspace/scripts/score_landmarks.py new file mode 100644 index 0000000000000000000000000000000000000000..a0896906b8ad094c7e72389d0ddb27a37ef97a0b --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/score_landmarks.py @@ -0,0 +1,18 @@ +"""Score independently human-marked landmarks against a saved research mapping.""" +import argparse,json +from pathlib import Path +import cv2,numpy as np +p=argparse.ArgumentParser();p.add_argument('annotations',type=Path);args=p.parse_args() +data=json.loads(args.annotations.read_text());sample=str(data['sample']) +if sample not in list('123456') or data.get('coordinate_frame')!='native_2200_crop':raise ValueError('Unsupported sample or coordinate frame') +points=data['points'] +if len(points)<6:raise ValueError('At least six completed landmarks are required') +ref=np.float32([x['reference'] for x in points]);mov=np.float32([x['moving'] for x in points]) +if ref.shape!=(len(points),2) or mov.shape!=ref.shape or not np.isfinite(ref).all() or not np.isfinite(mov).all() or np.any(ref<0) or np.any(ref>2199) or np.any(mov<0) or np.any(mov>2199):raise ValueError('Invalid landmark coordinates') +root=Path(__file__).resolve().parents[1]/'private_benchmarks/research' +method='loftr_mesh' if sample=='1' else 'loftr_patch_mesh' +mapping=np.load(root/f'{sample}-{method}'/'mapping.npz')['map'] +pred=cv2.remap(mapping,ref[:,0,None],ref[:,1,None],cv2.INTER_LINEAR)[:,0] +error=np.linalg.norm(pred-mov,axis=1) +result=dict(sample=sample,count=len(points),median_px=float(np.median(error)),p95_px=float(np.percentile(error,95)),max_px=float(error.max()),errors_px=error.tolist(),note='Measured against human-marked coordinates; annotation uncertainty applies. Sample 1 remains a rejected research candidate.') +output=args.annotations.with_suffix('.score.json');output.write_text(json.dumps(result,indent=2));print(json.dumps(result,indent=2)) diff --git a/hf_workspace/hf_workspace/scripts/validate_matcher_patches.py b/hf_workspace/hf_workspace/scripts/validate_matcher_patches.py new file mode 100644 index 0000000000000000000000000000000000000000..62e46225b2bade2889962f0a6282518ae9c9b115 --- /dev/null +++ b/hf_workspace/hf_workspace/scripts/validate_matcher_patches.py @@ -0,0 +1,24 @@ +import sys,json +from pathlib import Path +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +import cv2,numpy as np +from backend.experimental.patch_validation import validate_patches +ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'private_benchmarks/research' +rows=json.loads((OUT/'matchers.json').read_text()) +for name in ['iris_sift','loftr']: + for n in range(1,7): + path=ROOT/'private_benchmarks/client_iris'/str(n) + a=cv2.imread(str(path/'reference.png'));b=cv2.imread(str(path/'moving.png')) + pairs=np.load(OUT/f'{n}-{name}-matches.npz') + dst,src=validate_patches(a,b,pairs['reference'],pairs['moving']) + method=name+'_patch';np.savez_compressed(OUT/f'{n}-{method}-matches.npz',reference=dst,moving=src) + row=dict(sample=n,method=method,matches=len(src),input_matches=len(pairs['reference'])) + if len(src)>=16: + hold=((dst[:,0]//150+dst[:,1]//150).astype(int)%5)==0 + if hold.sum()>=8: + h,ins=cv2.findHomography(src[~hold],dst[~hold],cv2.USAC_MAGSAC,4) + if h is not None: + err=np.linalg.norm(cv2.perspectiveTransform(src[hold,None],h)[:,0]-dst[hold],axis=1) + row.update(train_inliers=int(ins.sum()),train_count=int((~hold).sum()),test_count=int(hold.sum()),heldout_median=float(np.median(err)),heldout_p95=float(np.percentile(err,95)),matrix=h.tolist()) + rows.append(row);print(json.dumps(row),flush=True) +(OUT/'matchers-patch.json').write_text(json.dumps(rows,indent=2)) diff --git a/hf_workspace/hf_workspace/tests/test_experimental_mesh.py b/hf_workspace/hf_workspace/tests/test_experimental_mesh.py new file mode 100644 index 0000000000000000000000000000000000000000..be6f7aecdc61bf440313b32e6bec2e91634b8a5b --- /dev/null +++ b/hf_workspace/hf_workspace/tests/test_experimental_mesh.py @@ -0,0 +1,33 @@ +import cv2 +import numpy as np +import pytest +from backend.experimental.mesh import fit_mesh,dense_mesh + + +def test_mesh_recovers_smooth_displacement_on_unseen_points(): + h=w=600 + y,x=np.mgrid[40:560:20,40:560:20] + points=np.stack([x.ravel(),y.ravel()],-1).astype(np.float32) + def truth(p):return p+np.stack([4*np.sin(p[:,1]/200),3*np.sin(p[:,0]/180)],-1) + coef=fit_mesh(points,truth(points),np.eye(3),(h,w)) + mapping,good,_=dense_mesh(coef,np.eye(3),(h,w)) + unseen=np.random.default_rng(7).uniform(80,520,(150,2)).astype(np.float32) + prediction=cv2.remap(mapping,unseen[:,0,None],unseen[:,1,None],cv2.INTER_LINEAR)[:,0] + assert np.percentile(np.linalg.norm(prediction-truth(unseen),axis=1),95)<.5 + assert good[80:520,80:520].all() + + +def test_mesh_marks_excessive_movement_untrusted(): + coef=np.full((9,9,2),50,np.float32) + _,good,_=dense_mesh(coef,np.eye(3),(200,200)) + assert not good.any() + + +def test_mesh_rejects_inadequate_constraints(): + with pytest.raises(ValueError):fit_mesh(np.zeros((4,2),np.float32),np.zeros((4,2),np.float32),np.eye(3),(200,200)) + + +def test_mesh_rejects_folded_total_mapping(): + h=np.array([[-1,0,199],[0,1,0],[0,0,1]],dtype=np.float64) + _,good,_=dense_mesh(np.zeros((9,9,2),np.float32),h,(200,200)) + assert not good.any() diff --git a/hf_workspace/hf_workspace/tests/test_learned_evaluation.py b/hf_workspace/hf_workspace/tests/test_learned_evaluation.py new file mode 100644 index 0000000000000000000000000000000000000000..a04be192a4b48d83e04af288d9c73dcb36988bc4 --- /dev/null +++ b/hf_workspace/hf_workspace/tests/test_learned_evaluation.py @@ -0,0 +1,73 @@ +import cv2 +import numpy as np +from fastapi.testclient import TestClient +from backend.app import app,processing_slots +from backend.experimental.evaluation import evaluate_correspondences +from backend.review import review_pair + + +def test_cross_validation_smooth_known_motion(): + y,x=np.mgrid[80:520:15,80:520:15] + a=np.stack([x.ravel(),y.ravel()],-1).astype(np.float32) + b=a+np.stack([3*np.sin(a[:,1]/180),2*np.sin(a[:,0]/160)],-1) + result=evaluate_correspondences(a,b,(600,600)) + assert result['scored_count']==len(a) + assert not result['failed_folds'] + assert result['within_px_percent']['1']>95 + assert result['p95_px']<1 + + +def test_insufficient_correspondences_not_assigned_percentage(): + result=evaluate_correspondences(np.zeros((29,2),np.float32),np.zeros((29,2),np.float32),(600,600)) + assert result['within_px_percent'] is None + assert result['p95_px'] is None + + +def test_unscored_folds_count_against_percentage(): + a=np.tile(np.array([[200,200]],np.float32),(80,1)) + result=evaluate_correspondences(a,a,(600,600)) + assert result['p95_px'] is None + assert result['within_px_percent']['5']==0 + + +def test_learned_requires_crop_confirmation(): + data=cv2.imencode('.png',np.zeros((400,400,3),np.uint8))[1].tobytes() + response=TestClient(app).post('/api/register',data={'engine':'learned'},files={'reference':('a.png',data),'moving':('b.png',data)}) + assert response.status_code==422 + assert 'Confirm' in response.json()['detail'] + + +def test_learned_invalid_shape_preserves_originals_without_loading_model(): + a=np.zeros((500,600,3),np.uint8) + result=review_pair(a,a,engine='learned') + assert result['metrics']['status']=='unaligned' + assert np.array_equal(result['reference'],a) + + +def test_busy_service_returns_retry_not_a_false_review(): + data=cv2.imencode('.png',np.zeros((100,100,3),np.uint8))[1].tobytes() + processing_slots.acquire() + try: + response=TestClient(app).post('/api/register',files={'reference':('a.png',data),'moving':('b.png',data)}) + assert response.status_code==503 + assert response.headers['retry-after']=='10' + finally:processing_slots.release() + + +def test_learned_output_is_one_sample_of_original_and_preserves_untrusted_pixels(monkeypatch): + from backend.learned_registration import register_learned + from backend.experimental.mesh import dense_mesh + image=cv2.resize(cv2.imread('fixtures/synthetic-iris.png'),(600,600)) + y,x=np.mgrid[90:520:15,90:520:15] + points=np.stack([x.ravel(),y.ravel()],-1).astype(np.float32) + r=np.linalg.norm(points-300,axis=1);points=points[(r>100)&(r<235)] + monkeypatch.setattr('backend.learned_registration.get_matcher',lambda:lambda a,b:(points,points+np.float32([8,-6]))) + monkeypatch.setattr('backend.learned_registration.validate_patches',lambda a,b,p,q:(p,q)) + moving=cv2.warpAffine(image,np.float32([[1,0,8],[0,1,-6]]),(600,600)) + result=register_learned(image,moving,exposure=False) + m=result['metrics'];mapping,_,_=dense_mesh(np.array(m['mesh_coefficients'],np.float32),np.array(m['transform']),(600,600)) + expected=cv2.remap(moving,mapping[...,0],mapping[...,1],cv2.INTER_LINEAR) + assert np.array_equal(result['aligned'],expected) + untouched=result['contribution']==0 + assert np.array_equal(result['composite'][untouched],image[untouched]) + assert m['exposure_gain']==1 diff --git a/hf_workspace/hf_workspace/tests/test_review.py b/hf_workspace/hf_workspace/tests/test_review.py new file mode 100644 index 0000000000000000000000000000000000000000..a399826a8be7b96b10decda0989c346eabb1db12 --- /dev/null +++ b/hf_workspace/hf_workspace/tests/test_review.py @@ -0,0 +1,50 @@ +import base64 +import cv2 +import numpy as np +from fastapi.testclient import TestClient +from backend.app import app +from backend.common import RegistrationError +from backend.review import review_pair + + +def test_low_information_pair_returns_originals_without_fake_score(): + reference=np.full((120,160,3),80,np.uint8) + moving=np.full((160,120,3),90,np.uint8) + result=review_pair(reference,moving) + assert result['metrics']['status']=='unaligned' + assert result['metrics']['match_support_percent'] is None + assert result['metrics']['transform'] is None + assert set(result)=={'metrics','reference','moving'} + assert np.array_equal(result['reference'],reference) + assert np.array_equal(result['moving'],moving) + + +def test_high_inlier_ratio_cannot_override_geometry_rejection(monkeypatch): + def reject(*args,**kwargs): + raise RegistrationError('Matches are too concentrated.',dict(matches=100,inliers=95,inlier_ratio=.95)) + monkeypatch.setattr('backend.review.register',reject) + result=review_pair(np.zeros((100,100,3),np.uint8),np.zeros((100,100,3),np.uint8)) + assert result['metrics']['match_support_percent']==95 + assert result['metrics']['status']=='unaligned' + assert 'composite' not in result + assert result['metrics']['blended_fraction']==0 + + +def test_failed_registration_api_is_a_review_not_a_422(): + im=np.full((128,128,3),70,np.uint8);data=cv2.imencode('.png',im)[1].tobytes() + response=TestClient(app).post('/api/register',files={'reference':('a.png',data),'moving':('b.png',data)}) + assert response.status_code==200 + body=response.json() + assert body['metrics']['status']=='unaligned' + decoded=cv2.imdecode(np.frombuffer(base64.b64decode(body['images']['reference'].split(',')[1]),np.uint8),cv2.IMREAD_COLOR) + assert np.array_equal(decoded,im) + + +def test_supported_registration_still_requires_review(): + im=cv2.resize(cv2.imread('fixtures/synthetic-iris.png'),(400,400)) + result=review_pair(im,im) + assert result['metrics']['status']=='review_required' + assert result['metrics']['match_support_percent']==100 + assert result['metrics']['inliers']==result['metrics']['matches'] + assert 'accuracy' in result['metrics']['score_description'] + assert 'composite' in result diff --git a/hf_workspace/scripts/benchmark_improvements.py b/hf_workspace/scripts/benchmark_improvements.py new file mode 100644 index 0000000000000000000000000000000000000000..ac69da5a79a126aaded3c9d3f398b9a5a48339c1 --- /dev/null +++ b/hf_workspace/scripts/benchmark_improvements.py @@ -0,0 +1,123 @@ +"""Reproducible ablations on private crops; no client images leave this machine.""" +import argparse +import hashlib +import json +import sys +import time +from pathlib import Path +import cv2 +import numpy as np +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from backend.experimental.matching import LearnedMatcher +from backend.experimental.patch_validation import validate_patches +from backend.experimental.preprocessing import iris_mask +from backend.experimental.segmentation import adaptive_mask, geometry_overlay +from backend.experimental.evaluation import evaluate_correspondences, fit_geometry, predict_points +from backend.experimental.radial import fit_radial_mesh +from backend.experimental.mesh import dense_mesh +from backend.experimental.native_refinement import refine_native + +ROOT = Path(__file__).resolve().parents[1] + + +def common_evaluation(a, b, anchors_a, anchors_b, shape, geometry=None): + """Same automatic target points for every candidate; never fit those locations. + + A 32px exclusion neighborhood also removes overlapping validation patches. + These labels remain automatic, not anatomical ground truth. + """ + errors = np.full(len(anchors_a), np.inf) + cell = max(shape)/2200*150 + folds = lambda p: ((p[:, 0]//cell+p[:, 1]//cell).astype(int)%5) + if len(anchors_a) >= 60: + for fold in range(5): + test = folds(anchors_a)==fold + train = folds(a)!=fold + if test.sum() < 6: + continue + # Chunk distances to bound memory for dense feature sets. + heldout = anchors_a[test] + for start in range(0, len(a), 256): + near = np.linalg.norm(a[start:start+256, None]-heldout[None], axis=2).min(axis=1) < 32 + train[start:start+256] &= ~near + try: + if geometry is None: + matrix, coef, _, _ = fit_geometry(a[train], b[train], shape) + prediction = predict_points(heldout, matrix, coef, shape) + else: + prediction = fit_radial_mesh(a[train], b[train], shape, geometry).predict(heldout) + errors[test] = np.linalg.norm(prediction-anchors_b[test], axis=1) + except (ValueError, cv2.error, np.linalg.LinAlgError): + pass + return dict(count=len(errors), scored_count=int(np.isfinite(errors).sum()), + median_px=float(np.median(errors)) if np.isfinite(errors).all() and len(errors) else None, + p95_px=float(np.percentile(errors, 95)) if np.isfinite(errors).all() and len(errors) else None, + within_px_percent={str(t): round(float((errors<=t).mean()*100), 2) if len(errors) else None for t in (1, 2, 3, 5)}, + description='Fixed baseline automatic correspondences; five spatial folds with 32px training exclusion. Not anatomical ground truth. Unscored points count as failures.') + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--variants', nargs='+', default=['loftr800', 'loftr1024', 'lightglue1600']) + parser.add_argument('--samples', nargs='+', type=int, default=list(range(1, 7))) + parser.add_argument('--output', type=Path, default=ROOT/'private_benchmarks/improvements') + args = parser.parse_args() + args.output.mkdir(parents=True, exist_ok=True) + rows = [] + for variant in args.variants: + if variant not in {'loftr800', 'loftr1024', 'lightglue1600'}: + parser.error('Unknown variant') + matcher = None + for sample in args.samples: + started = time.perf_counter() + folder = ROOT/'private_benchmarks/client_iris'/str(sample) + ref, mov = (cv2.imread(str(folder/f'{n}.png')) for n in ('reference', 'moving')) + dest = args.output/f'{sample}-{variant}' + dest.mkdir(exist_ok=True) + masks, geometries = zip(*(adaptive_mask(im) for im in (ref, mov))) + for name, im, g, mask in zip(('reference', 'moving'), (ref, mov), geometries, masks): + cv2.imwrite(str(dest/f'{name}-geometry.jpg'), geometry_overlay(im, g)) + cv2.imwrite(str(dest/f'{name}-mask.png'), mask.astype(np.uint8)*255) + cache = dest/'raw.npz' + if cache.exists(): + with np.load(cache) as data: + raw_a, raw_b = data['reference'], data['moving'] + else: + if matcher is None: + if variant.startswith('loftr'): + matcher = LearnedMatcher(ROOT/'models/loftr_outdoor.ckpt', max_size=int(variant[5:])) + else: + from backend.experimental.lightglue_matching import LightGlueMatcher + matcher = LightGlueMatcher(ROOT/'models', max_size=1600) + # Broad mask permits a fair fixed/adaptive mask comparison without reinference. + broad = tuple(iris_mask(im) | mask for im, mask in zip((ref, mov), masks)) + raw_a, raw_b = matcher(ref, mov, masks=broad) + np.savez_compressed(cache, reference=raw_a, moving=raw_b) + baseline = np.load(ROOT/f'private_benchmarks/research/{sample}-loftr_patch-matches.npz') + anchors_a, anchors_b = baseline['reference'], baseline['moving'] + for adaptive in (False, True): + selected = masks if adaptive else (iris_mask(ref), iris_mask(mov)) + keep = np.ones(len(raw_a), bool) + for points, mask in zip((raw_a, raw_b), selected): + xy = points.astype(int) + keep &= mask[xy[:, 1], xy[:, 0]] + for multiscale in (False, True): + a, b = validate_patches(ref, mov, raw_a[keep], raw_b[keep], multiscale=multiscale) + name = f'{"adaptive" if adaptive else "fixed"}-{"multi" if multiscale else "single"}' + np.savez_compressed(dest/f'{name}.npz', reference=a, moving=b) + row = dict(sample=sample, variant=variant, adaptive=adaptive, multiscale=multiscale, + raw_matches=int(keep.sum()), verified_matches=len(a), + geometries=[g.to_dict() if g else None for g in geometries], + self_evaluation=evaluate_correspondences(a, b, ref.shape[:2]), + common_evaluation=common_evaluation(a, b, anchors_a, anchors_b, ref.shape[:2])) + if adaptive and geometries[0] is not None: + row['radial_common_evaluation'] = common_evaluation(a, b, anchors_a, anchors_b, ref.shape[:2], geometries[0]) + rows.append(row) + (args.output/'results.json').write_text(json.dumps(rows, indent=2)) + print(json.dumps({k: row[k] for k in ['sample', 'variant', 'adaptive', 'multiscale', 'verified_matches', 'self_evaluation', 'common_evaluation']}), flush=True) + print(f'Finished {sample} {variant}: {time.perf_counter()-started:.1f}s', flush=True) + del matcher + + +if __name__ == '__main__': + main() diff --git a/hf_workspace/scripts/benchmark_refinements.py b/hf_workspace/scripts/benchmark_refinements.py new file mode 100644 index 0000000000000000000000000000000000000000..b12909e970e00c455c13758410a498325f8eb5eb --- /dev/null +++ b/hf_workspace/scripts/benchmark_refinements.py @@ -0,0 +1,68 @@ +"""Compare viewpoint patch validation, radial prior and native flow on cached matches.""" +import json +import sys +from pathlib import Path +import cv2 +import numpy as np +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from scripts.benchmark_improvements import common_evaluation +from backend.experimental.patch_validation import validate_geometry_patches +from backend.experimental.evaluation import evaluate_correspondences, fit_geometry +from backend.experimental.mesh import dense_mesh +from backend.experimental.native_refinement import refine_native +from backend.experimental.preprocessing import iris_mask, glare_mask +from backend.experimental.segmentation import adaptive_mask +from backend.compositing import compose + +ROOT = Path(__file__).resolve().parents[1] +OUT = ROOT/'private_benchmarks/refinement_ablation' + + +def main(): + OUT.mkdir(exist_ok=True) + rows = [] + for sample in range(1, 7): + ref, mov = (cv2.imread(str(ROOT/f'private_benchmarks/client_iris/{sample}/{name}.png')) for name in ('reference', 'moving')) + original = np.load(ROOT/f'private_benchmarks/research/{sample}-loftr-matches.npz') + anchors = np.load(ROOT/f'private_benchmarks/research/{sample}-loftr_patch-matches.npz') + dest = OUT/str(sample) + dest.mkdir(exist_ok=True) + a, b = validate_geometry_patches(ref, mov, original['reference'], original['moving']) + np.savez_compressed(dest/'verified.npz', reference=a, moving=b) + row = dict(sample=sample, verified_matches=len(a), self_evaluation=evaluate_correspondences(a, b, ref.shape[:2]), + common_evaluation=common_evaluation(a, b, anchors['reference'], anchors['moving'], ref.shape[:2])) + _, geometry = adaptive_mask(ref) + if geometry is not None: + row['radial_common_evaluation'] = common_evaluation(a, b, anchors['reference'], anchors['moving'], ref.shape[:2], geometry) + ev = row['self_evaluation'] + if ev['p95_px'] is not None and ev['p95_px'] < 12 and ev['median_px'] < 4: + matrix, coefficients, _, _ = fit_geometry(a, b, ref.shape[:2]) + mapping, valid, _ = dense_mesh(coefficients, matrix, ref.shape[:2]) + support = np.zeros(ref.shape[:2], np.uint8) + for point in a: + cv2.circle(support, tuple(np.rint(point).astype(int)), round(ref.shape[1]*.04), 1, -1) + support = support.astype(bool)&iris_mask(ref)&valid + aligned = cv2.remap(mov, mapping[..., 0], mapping[..., 1], cv2.INTER_LINEAR) + support &= cv2.remap(iris_mask(mov).astype(np.uint8), mapping[..., 0], mapping[..., 1], cv2.INTER_NEAREST).astype(bool) + trusted = support&~glare_mask(ref)&~glare_mask(aligned) + refined, diagnostics = refine_native(ref, mov, mapping, trusted) + row['native_refinement'] = diagnostics + # Compare displacement at fixed labels, but do not label in-sample flow as CV accuracy. + for label, map_ in [('mesh', mapping), ('native', refined)]: + ap, bp = anchors['reference'], anchors['moving'] + prediction = cv2.remap(map_, ap[:, 0:1].astype(np.float32), ap[:, 1:2].astype(np.float32), cv2.INTER_LINEAR)[:, 0] + error = np.linalg.norm(prediction-bp, axis=1) + row[label+'_anchor_disagreement'] = dict(median_px=float(np.median(error)), p95_px=float(np.percentile(error, 95)), description='Diagnostic on full-image fit, NOT held-out accuracy.') + if valid[iris_mask(ref)].mean() >= .99: + images, _ = compose(ref, aligned, valid, trusted, True) + for name, image in images.items(): + cv2.imwrite(str(dest/f'{name}.png'), image) + np.savez_compressed(dest/'mapping.npz', mapping=mapping) + cv2.imwrite(str(dest/'native-candidate.png'), cv2.remap(mov, refined[..., 0], refined[..., 1], cv2.INTER_LINEAR)) + rows.append(row) + (OUT/'results.json').write_text(json.dumps(rows, indent=2)) + print(json.dumps(row), flush=True) + + +if __name__ == '__main__': + main() diff --git a/hf_workspace/tests/test_improvements.py b/hf_workspace/tests/test_improvements.py new file mode 100644 index 0000000000000000000000000000000000000000..a22c4fb5b0b0db68b3d4ac4a6e62b4cfe3873426 --- /dev/null +++ b/hf_workspace/tests/test_improvements.py @@ -0,0 +1,79 @@ +import cv2 +import numpy as np +import pytest +from backend.experimental.segmentation import IrisGeometry, detect_geometry, adaptive_mask +from backend.experimental.radial import radial_vectors, fit_radial_mesh +from backend.experimental.native_refinement import refine_native +from backend.experimental.patch_validation import validate_patches +from backend.experimental.mesh import dense_mesh +from backend.experimental.evaluation import predict_points + + +def test_uncertain_segmentation_falls_back_without_inventing_geometry(): + image = np.full((600, 600, 3), 100, np.uint8) + mask, geometry = adaptive_mask(image) + assert geometry is None + assert mask.dtype == bool + assert not mask[300, 300] + + +def test_detect_offcenter_pupil_and_limbus(): + image = np.full((600, 600, 3), 210, np.uint8) + cv2.circle(image, (325, 280), 230, (85, 100, 120), -1) + cv2.circle(image, (325, 280), 65, (15, 15, 15), -1) + geometry = detect_geometry(image) + assert geometry is not None + assert np.linalg.norm(np.array(geometry.center)-[325, 280]) < 5 + assert abs(geometry.pupil_radius-65) < 5 + assert abs(geometry.iris_radius-230) < 8 + + +def test_radial_fit_recovers_unseen_dilation(): + geometry = IrisGeometry((300, 300), 80, 250, 1) + y, x = np.mgrid[60:540:12, 60:540:12] + a = np.column_stack([x.ravel(), y.ravel()]).astype(np.float32) + radius = np.linalg.norm(a-300, axis=1) + a = a[(radius>90)&(radius<240)] + b = a+8*radial_vectors(a, np.eye(3), geometry) + train = np.arange(len(a))%5 != 0 + model = fit_radial_mesh(a[train], b[train], (600, 600), geometry) + error = np.linalg.norm(model.predict(a[~train])-b[~train], axis=1) + assert np.percentile(error, 95) < 1 + + +def test_radial_prior_zero_at_limbus_and_center(): + geometry = IrisGeometry((300, 300), 80, 250, 1) + p = np.float32([[300, 300], [550, 300], [580, 300], [380, 300]]) + v = radial_vectors(p, np.eye(3), geometry) + assert np.allclose(v[:3], 0) + assert np.allclose(v[3], [1, 0]) + + +def test_native_flow_without_support_preserves_map(): + rng = np.random.default_rng(1) + im = rng.integers(0, 180, (160, 160, 3), dtype=np.uint8) + y, x = np.indices(im.shape[:2], dtype=np.float32) + mapping = np.stack([x, y], -1) + result, metrics = refine_native(im, np.roll(im, 2, axis=1), mapping, np.zeros(im.shape[:2], bool)) + assert not metrics['applied'] + assert np.array_equal(result, mapping) + + +def test_multiscale_preserves_identity_and_rejects_borders(): + rng = np.random.default_rng(2) + im = rng.integers(0, 200, (200, 200, 3), dtype=np.uint8) + points = np.float32([[80, 80], [120, 120], [5, 5]]) + p, q = validate_patches(im, im, points, points, multiscale=True) + assert len(p) == 2 + assert np.allclose(p, q, atol=.01) + + +def test_dense_mesh_matches_evaluated_coordinates_without_grid_quantization(): + y,x=np.mgrid[:9,:9] + coefficients=np.stack([20*np.sin(y/3),15*np.cos(x/3)],-1).astype(np.float32) + mapping,valid,_=dense_mesh(coefficients,np.eye(3),(600,600)) + py,px=np.mgrid[40:560:7,40:560:11] + points=np.stack([px.ravel(),py.ravel()],-1).astype(np.float32) + expected=predict_points(points,np.eye(3),coefficients,(600,600)) + assert np.max(np.linalg.norm(expected-mapping[py.ravel(),px.ravel()],axis=1))<.0001 + assert valid[40:560,40:560].all() diff --git a/scripts/benchmark_improvements.py b/scripts/benchmark_improvements.py index ac69da5a79a126aaded3c9d3f398b9a5a48339c1..e92f2a4528ab9c78ec3498cf356d8852cfe42723 100644 --- a/scripts/benchmark_improvements.py +++ b/scripts/benchmark_improvements.py @@ -79,7 +79,10 @@ def main(): cv2.imwrite(str(dest/f'{name}-geometry.jpg'), geometry_overlay(im, g)) cv2.imwrite(str(dest/f'{name}-mask.png'), mask.astype(np.uint8)*255) cache = dest/'raw.npz' - if cache.exists(): + broad = tuple(iris_mask(im) | mask for im, mask in zip((ref, mov), masks)) + signature = hashlib.sha256(ref.tobytes()+mov.tobytes()+b''.join(m.tobytes() for m in broad)+variant.encode()).hexdigest() + manifest = dest/'cache.json' + if cache.exists() and manifest.exists() and json.loads(manifest.read_text()).get('signature')==signature: with np.load(cache) as data: raw_a, raw_b = data['reference'], data['moving'] else: @@ -90,9 +93,9 @@ def main(): from backend.experimental.lightglue_matching import LightGlueMatcher matcher = LightGlueMatcher(ROOT/'models', max_size=1600) # Broad mask permits a fair fixed/adaptive mask comparison without reinference. - broad = tuple(iris_mask(im) | mask for im, mask in zip((ref, mov), masks)) raw_a, raw_b = matcher(ref, mov, masks=broad) np.savez_compressed(cache, reference=raw_a, moving=raw_b) + manifest.write_text(json.dumps(dict(signature=signature,variant=variant),indent=2)) baseline = np.load(ROOT/f'private_benchmarks/research/{sample}-loftr_patch-matches.npz') anchors_a, anchors_b = baseline['reference'], baseline['moving'] for adaptive in (False, True): @@ -110,7 +113,7 @@ def main(): geometries=[g.to_dict() if g else None for g in geometries], self_evaluation=evaluate_correspondences(a, b, ref.shape[:2]), common_evaluation=common_evaluation(a, b, anchors_a, anchors_b, ref.shape[:2])) - if adaptive and geometries[0] is not None: + if adaptive and geometries[0] is not None and geometries[0].limbus_detected: row['radial_common_evaluation'] = common_evaluation(a, b, anchors_a, anchors_b, ref.shape[:2], geometries[0]) rows.append(row) (args.output/'results.json').write_text(json.dumps(rows, indent=2)) diff --git a/scripts/benchmark_refinements.py b/scripts/benchmark_refinements.py index b12909e970e00c455c13758410a498325f8eb5eb..8b8c187e592fe0f50d874cf4be5abd95741503c4 100644 --- a/scripts/benchmark_refinements.py +++ b/scripts/benchmark_refinements.py @@ -32,7 +32,7 @@ def main(): row = dict(sample=sample, verified_matches=len(a), self_evaluation=evaluate_correspondences(a, b, ref.shape[:2]), common_evaluation=common_evaluation(a, b, anchors['reference'], anchors['moving'], ref.shape[:2])) _, geometry = adaptive_mask(ref) - if geometry is not None: + if geometry is not None and geometry.limbus_detected: row['radial_common_evaluation'] = common_evaluation(a, b, anchors['reference'], anchors['moving'], ref.shape[:2], geometry) ev = row['self_evaluation'] if ev['p95_px'] is not None and ev['p95_px'] < 12 and ev['median_px'] < 4: