Spaces:
Paused
Paused
File size: 2,172 Bytes
f65c627 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Choose a refinement only with improvement on the same automatic anchor set.
These scores select a candidate; they are not an independent final accuracy test.
No sample IDs, client references, or manually finished images enter the decision.
"""
from .evaluation import common_evaluation, evaluate_correspondences
def improves(baseline, candidate):
if baseline['p95_px'] is None or candidate['p95_px'] is None:
return False
return (candidate['scored_count'] == candidate['count']
and candidate['count'] == baseline['count']
and candidate['p95_px'] < baseline['p95_px'] - max(.15, baseline['p95_px']*.03)
and candidate['median_px'] <= baseline['median_px']*1.05)
def select_correspondences(baseline, candidate, shape):
a, b = baseline
ca, cb = candidate
base_evaluation = evaluate_correspondences(a, b, shape)
candidate_evaluation = evaluate_correspondences(ca, cb, shape)
diagnostics = dict(selected='single', reason='Baseline retained; alternative must improve common-point predictions.',
candidate_verified_matches=len(ca), candidate_evaluation=candidate_evaluation,
description='Automatic model-selection diagnostics, not an independent accuracy test.')
# With insufficient baseline evidence we cannot claim a comparable improvement.
if base_evaluation['p95_px'] is None or candidate_evaluation['p95_px'] is None or len(ca) < .8*len(a):
return a, b, base_evaluation, diagnostics
base_common = common_evaluation(a, b, a, b, shape)
candidate_common = common_evaluation(ca, cb, a, b, shape)
diagnostics.update(baseline_common=base_common, candidate_common=candidate_common)
if (candidate_evaluation['p95_px'] < 12 and candidate_evaluation['median_px'] < 4
and improves(base_common, candidate_common)):
diagnostics.update(selected='geometry', reason='Viewpoint correction improved tail error on the same held-out automatic points without worsening median error or losing substantial support.')
return ca, cb, candidate_evaluation, diagnostics
return a, b, base_evaluation, diagnostics
|