File size: 2,022 Bytes
8e932ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Launch the full corrected experiment pipeline on the Azure T4 VM.
# Designed to be called via:  sshpass + nohup so it survives SSH disconnect.
#
# Outputs go to ~/fundus_project/final_experiments/
#   - run.log               progress
#   - {model}_kfold.json    5-fold CV summary per model
#   - {model}_test.json     independent-test metrics per model
#   - {model}_test_preds.json  per-sample preds for McNemar
#   - mcnemar.json          pairwise paired tests
#   - weights/{model}_final.pth  reproducible model weights
#   - kfold_summary.json    aggregate

set -euo pipefail
cd ~/fundus_project
source ~/.venv/bin/activate

# Use ORIGINAL dataset to avoid data-leakage: in the Augmented dataset, each
# original image has multiple augmented copies with no group ID, so a random
# split puts copies of the same source into BOTH train and test (inflates test
# accuracy 2-6pp). On-the-fly augmentation in the train transform compensates.
echo "[$(date)] building holdout split (ORIGINAL dataset, no leakage)"
python comparison_experiment/build_holdout_split.py \
  --data-dir Database/Original_Dataset \
  --output holdout_split.json \
  --test-size 0.15 --val-size 0.15 --folds 5 --seed 42

echo "[$(date)] starting unified pipeline (k-fold CV + independent test for all 6 models)"
echo "  - class-weighted CE loss (sqrt-inverse-frequency)"
echo "  - CLIP uses OpenAI pretrained weights"
echo "  - saves per-sample probs for ROC/PR/ECE analysis"
echo "  - bootstrap 95% CIs on test metrics"
python comparison_experiment/run_final_experiments.py \
  --manifest holdout_split.json \
  --models vgg19 resnet50 resnet101 densenet121 inception_v3 clip_openai \
  --epochs 60 --folds 5 --batch-size 32 --workers 4 --lr 1e-4 --patience 8 \
  --output-dir final_experiments

echo "[$(date)] generating gradcam figures"
python comparison_experiment/generate_all_gradcam.py \
  --weights-dir final_experiments/weights \
  --manifest holdout_split.json \
  --output-dir gradcam_outputs_final

echo "[$(date)] DONE"