fourmodal-pathology-bind / reproduce.sh
Carpediem123's picture
Migrate release files 241-270
e03b3d1 verified
Raw History Blame Contribute Delete
1.72 kB
#!/usr/bin/env bash
# Reproduce the final model from the cached encoder features (GPU, ~20 min on one RTX A5000).
#
# PYTHON=python bash reproduce.sh # feature-level checks + retraining (no frozen encoders needed)
# RAW=1 PYTHON=python bash reproduce.sh # + raw-input check of embed.py (run setup_encoders.sh first)
#
# Steps
# 0. download cache/ + splits/ (features of the real paired data + virtual / synthetic test data, ~1.1 GB)
# from the dataset repo Pathstudy/fourmodal-pathology-features (skipped if present)
# 1. evaluate_saved.py: shipped fold-0 checkpoint on its held-out test -> must equal models/ej_ad_mv_fold0/test.csv
# 2. retrain fold 0 (models/repro_fold0) and the 5-fold CV (results/final_cv_*_repro.csv), compare with the shipped
# numbers (compare_reproduction.py); shipped checkpoints / results are not overwritten
# 3. retrain the release model (models/repro_release; train = fold-0 train + test, val = fold-0 val)
# 4. (RAW=1) example_check.py: raw images / text / counts / mIF tiles in examples/ -> embed.py
set -euo pipefail
cd "$(dirname "$0")"
PY=${PYTHON:-python}
if [ ! -f cache/he_uni2.npy ]; then
"$PY" -I -c "from huggingface_hub import snapshot_download as s; s('Pathstudy/fourmodal-pathology-features', repo_type='dataset', local_dir='.', allow_patterns=['cache/*', 'splits/*'])"
fi
"$PY" -I evaluate_saved.py models/ej_ad_mv_fold0
"$PY" -I 52_final_model.py fold0 --out repro_fold0
"$PY" -I 52_final_model.py cv --out repro
"$PY" -I compare_reproduction.py repro
"$PY" -I 52_final_model.py release --out repro_release
if [ "${RAW:-0}" = 1 ]; then
"$PY" -I example_check.py models/ej_ad_mv_fold0
fi
echo "reproduce.sh: all steps finished"