#!/usr/bin/env bash # v12 training — Fix score collapse + wet_press concept grounding. # # Changes vs v11: # T17 — L_deg applied to ALL datasets (SD302 + FVC + PolyU), not FVC-only. # Root cause of v11 score collapse: 95% of SD302 images stuck at ~58.3 # because they had no ordinal grounding from L_deg. Synthetic degradation # on SD302 is artificial but necessary to prevent collapse on majority data. # T18 — MorphologicalDilator fixed: cv2.erode instead of cv2.dilate. # NIST fingerprints have DARK ridges. Erode expands dark ridges (wet smear). # Previous dilate shrank ridges → paradoxically increased clarity score. # Fixes wet_press → clarity = +0.219 (wrong) → should be negative. # T19 — DegradationRankingLoss gamma: 0.5 → 1.0 (stronger concept supervision). # Occlusion block coverage: 30% → 40% at level 3. # Fixes jpeg/occlusion concept signal near zero (rho ≈ -0.05, -0.03 in v11). # # Training: resume from v11 last.pt (model weights only, not optimizer). # --spread-weight 5.0 (up from 2.0) to force wider score distribution. # --deg-every-n-steps 4 (up from 2) to keep compute balanced since L_deg # now processes full batch (96 images) instead of ~15 FVC images. # # Expected improvements: # Track 2 mean_KS: 0.5566 → < 0.15 (SD302 images should spread, less sensor clustering) # Track 4 wet_press → clarity: +0.219 (❌) → negative (✓) # Track 4 occlusion → minutiae: -0.032 (weak) → < -0.2 (strong) set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" source "${REPO_ROOT}/.venv/bin/activate" python "${REPO_ROOT}/sifq/scripts/train_sifq.py" \ --root-302a "${REPO_ROOT}/dataset/302a/images/challengers" \ --root-302b "${REPO_ROOT}/dataset/302b/images/baseline" \ --root-302d "${REPO_ROOT}/dataset/nist_302d/images/auxiliary" \ --root-fvc2002 "${REPO_ROOT}/dataset/FVC_Dataset/FVC2002" \ --root-fvc2004 "${REPO_ROOT}/dataset/FVC_Dataset/FVC2004" \ --root-polyu "${REPO_ROOT}/dataset/PolyU" \ --mdgt-checkpoint "${REPO_ROOT}/pad/TRAM-downstream/checkpoint/checkpoints_dinov2_tram/best_eer.pt" \ --resume "${REPO_ROOT}/sifq/checkpoints_full_v11/last.pt" \ --epochs 80 \ --batch-size 96 \ --image-size 224 \ --lr 1e-4 \ --spread-mode uniform \ --spread-weight 5.0 \ --deg-every-n-steps 4 \ --deg-max-images 32 \ --max-train-samples -1 \ --num-workers 8 \ --gpus 0,1 \ --save-dir "${REPO_ROOT}/sifq/checkpoints_full_v12"