| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -euo pipefail |
|
|
| REPO="$(cd "$(dirname "$0")/.." && pwd)" |
| cd "$REPO" |
| source .venv/bin/activate |
| export SSL_CERT_FILE="$(python -c 'import certifi; print(certifi.where())')" |
| export DYLD_LIBRARY_PATH="$(python -c 'import torch, os; print(os.path.join(os.path.dirname(torch.__file__),"lib"))')" |
|
|
| mkdir -p logs |
| TS="$(date -u +%Y-%m-%dT%H-%M-%S)" |
| LOG="logs/extend_${TS}.log" |
| LOG_ID="logs/extend_identifier_${TS}.log" |
| LOG_DET="logs/extend_detector_${TS}.log" |
|
|
| banner() { |
| echo |
| echo "==========================================================" |
| echo "[$(date -u +%H:%M:%S)] $*" |
| echo "==========================================================" |
| } |
|
|
| latest_run_id() { |
| local variant="$1" |
| local dir |
| dir="$(ls -td "checkpoints/${variant}"/run_* 2>/dev/null | head -1)" |
| [[ -n "$dir" ]] || { echo "no runs for $variant" >&2; return 1; } |
| basename "$dir" | sed 's/^run_//' |
| } |
|
|
| |
| banner "Stage 1/5 Resume identifier (10 more epochs, lower LR)" | tee -a "$LOG" |
| ID_LAST="checkpoints/identifier/run_2026-05-12T20-20-52_identifier_v1/last.pt" |
| if [[ ! -f "$ID_LAST" ]]; then |
| echo "ERROR: identifier last.pt missing at $ID_LAST" | tee -a "$LOG" |
| exit 1 |
| fi |
| |
| ccdp train identifier \ |
| --epochs-stage1 3 --epochs-stage2 25 \ |
| --lr-stage2 5e-5 \ |
| --batch-size 32 --num-workers 4 \ |
| --resume "$ID_LAST" \ |
| 2>&1 | tee "$LOG_ID" >>"$LOG" |
|
|
| |
| banner "Stage 2/5 Detector v2 (50 epochs, imgsz 640, batch 16)" | tee -a "$LOG" |
| ccdp train detector \ |
| --epochs 50 --batch 16 --imgsz 640 --workers 4 \ |
| --tag yolov8n_v2 \ |
| 2>&1 | tee "$LOG_DET" >>"$LOG" |
|
|
| |
| banner "Stage 3/5 Promote identifier + detector v2" | tee -a "$LOG" |
| ID_RUN=$(latest_run_id identifier) |
| DET_RUN=$(latest_run_id detector) |
| echo " identifier -> $ID_RUN" | tee -a "$LOG" |
| echo " detector -> $DET_RUN" | tee -a "$LOG" |
| ccdp registry promote "$ID_RUN" identifier 2>&1 | tee -a "$LOG" |
| ccdp registry promote "$DET_RUN" detector 2>&1 | tee -a "$LOG" |
|
|
| |
| banner "Stage 4/5 Re-extract bbox features via new detector" | tee -a "$LOG" |
| ccdp train extract-bbox-features 2>&1 | tee -a "$LOG" |
|
|
| |
| banner "Stage 5/5 Retrain xgb_b on new bbox features" | tee -a "$LOG" |
| ccdp train xgb --variant b \ |
| --n-estimators 600 --max-depth 7 --learning-rate 0.05 \ |
| --tag xgb_b_v2 \ |
| 2>&1 | tee -a "$LOG" |
| XGB_B_RUN=$(latest_run_id xgb_b) |
| echo " xgb_b -> $XGB_B_RUN" | tee -a "$LOG" |
| ccdp registry promote "$XGB_B_RUN" xgb_b 2>&1 | tee -a "$LOG" |
|
|
| banner "DONE see registry: ccdp registry list" | tee -a "$LOG" |
| ccdp registry list 2>&1 | tee -a "$LOG" |
|
|