File size: 4,352 Bytes
cfc7a54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
# v20 training β€” T35: full prototypes + L_deg on SD302.
#
# Root cause analysis (v19 failure β€” same collapse as v15–v18):
#
#   v19 was supposed to reproduce v14 exactly but STILL collapsed (q_stdβ‰ˆ0.01
#   at inference, all scores 53.1x). This means the "v14 hyperparameter diff"
#   explanation (spread-weight and deg-every-n-steps) was wrong. Two deeper root
#   causes identified by analysing every code change since v14:
#
#   Root cause 1 β€” Truncated prototypes (T35a):
#     v14's code had NO --proto-max-batches cap; prototypes were computed on the
#     full dataset (42,683 images, ~334 batches). When this parameter was added
#     (default 150 batches = ~19,200 images, 45% of data), SD302 identities went
#     from having full 19-sensor multi-sensor prototypes to 2–3 sensor partial
#     prototypes.
#       Full prototype  β†’ raw cosine varies with image quality across all sensors
#                        (quality-discriminative, sensor-invariant).
#       Partial proto   β†’ raw cosine correlated with which sensors are in the
#                        prototype window (sensor-biased, quality-agnostic) β†’
#                        no per-image quality gradient for SD302 β†’ collapse.
#
#   Root cause 2 β€” FVC-only L_deg (T27, unchanged since v13):
#     T27 reverted T17 (L_deg on all images) because clean SD302 images anchored
#     at ~28 when there was no per-dataset spread. T27 itself introduced
#     per-dataset L_spread_ds. Now that L_spread_ds forces SD302 to span [10,90],
#     re-enabling full L_rank for SD302 is safe: L_spread_ds prevents the
#     anchoring, and L_rank orders SD302 images by their synthetic degradation
#     response (a proxy for ridge clarity / quality). This gives the ONLY stable
#     per-image quality signal for SD302 at inference.
#
# v20 fixes (T35):
#   T35a β€” --proto-max-batches 0: Compute prototypes on the full training set.
#           Full multi-sensor prototypes restore per-image L_mat quality signal
#           for SD302 (raw cosine varies with quality, not sensor).
#           Cost: ~10–15 extra minutes at epoch 0 for prototype computation.
#
#   T35b β€” --deg-include-sd302: Apply full L_deg (L_rank + L_concept) to SD302
#           images in addition to FVC. L_spread_ds (present since v13) prevents
#           score anchoring at ~28. Provides robust per-image ordinal quality
#           grounding for SD302 independent of root cause 1.
#
# All other settings kept from v19 (which correctly reproduced v14 hyperparams):
#   --spread-weight 3.0  --deg-every-n-steps 2  --no-mat-stats
#   --concept-deg-gamma 0.5  --sd302-concept-weight 0.0
#   --batch-size 128  --gpus 0  --epochs 60
#
# Expected improvements vs v19:
#   q_std (inference)  : >12  (v19: ~0.01)
#   Score range        : 10–90 (v19: 53.10–53.16)
#   Track 2 mean_KS    : ≀0.27 real  (v19: 0.3706 with collapsed distributions)
#   Track 2 Pearson    : β‰₯0.25  (v19: -0.0123)

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
export PATH="/home/aiserver/miniconda3/bin:$PATH"

VERSION="v20"
SAVE_DIR="${REPO_ROOT}/sifq/checkpoints/${VERSION}"
LOG_FILE="${REPO_ROOT}/sifq/logs/train_${VERSION}.log"
EVAL_SCRIPT="${REPO_ROOT}/sifq/scripts/run_eval_${VERSION}.sh"

mkdir -p "${REPO_ROOT}/sifq/logs"

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" \
  --exclude-sensor "R_1000_slap,R_500_slap,S_500_slap" \
  --mdgt-checkpoint "${REPO_ROOT}/pad/TRAM-downstream/checkpoint/checkpoints_dinov2_tram/best_eer.pt" \
  --epochs 60 \
  --batch-size 128 \
  --image-size 224 \
  --lr 1e-4 \
  --spread-mode uniform \
  --spread-weight 3.0 \
  --concept-deg-gamma 0.5 \
  --sd302-concept-weight 0.0 \
  --deg-every-n-steps 2 \
  --deg-include-sd302 \
  --no-mat-stats \
  --proto-max-batches 0 \
  --max-train-samples -1 \
  --num-workers 8 \
  --gpus 0 \
  --save-dir "${SAVE_DIR}"

echo "[auto-eval] Training done. Starting eval ${VERSION}..."
bash "${EVAL_SCRIPT}" >> "${LOG_FILE}" 2>&1