siddharthdhara17 commited on
Commit
2b2f102
·
verified ·
1 Parent(s): 4f926db

Upload baselines/run_all.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. baselines/run_all.sh +97 -0
baselines/run_all.sh ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # =============================================================================
3
+ # Run all deterministic baselines: train, predict, evaluate
4
+ # =============================================================================
5
+ set -e
6
+
7
+ DATA_ROOT="data"
8
+ EPOCHS=100
9
+ BATCH_SIZE=32
10
+ LR=0.001
11
+
12
+ echo "============================================================"
13
+ echo "Deterministic Segmentation Baselines for LIDC-IDRI"
14
+ echo "============================================================"
15
+
16
+ # Step 1: Prepare data (if not already done)
17
+ if [ ! -d "${DATA_ROOT}/flat_train/images" ]; then
18
+ echo ""
19
+ echo "[Step 1] Preparing flat dataset with majority-vote masks..."
20
+ python baselines/prepare_data.py --data_root ${DATA_ROOT} --skip_nnunet
21
+ else
22
+ echo "[Step 1] Flat dataset already exists, skipping..."
23
+ fi
24
+
25
+ # Step 2: Train and predict for each model
26
+ MODELS=("unet" "attention_unet" "unetpp" "transunet")
27
+
28
+ for MODEL in "${MODELS[@]}"; do
29
+ echo ""
30
+ echo "============================================================"
31
+ echo "[Step 2] Training ${MODEL}..."
32
+ echo "============================================================"
33
+
34
+ python baselines/train.py \
35
+ --model ${MODEL} \
36
+ --data_dir ${DATA_ROOT}/flat_train \
37
+ --epochs ${EPOCHS} \
38
+ --batch_size ${BATCH_SIZE} \
39
+ --lr ${LR} \
40
+ --checkpoint_dir checkpoints
41
+
42
+ echo ""
43
+ echo "[Step 3] Predicting with ${MODEL}..."
44
+ python baselines/predict.py \
45
+ --model ${MODEL} \
46
+ --checkpoint checkpoints/${MODEL}_best.pth \
47
+ --test_dir ${DATA_ROOT}/flat_test \
48
+ --output_dir results/${MODEL} \
49
+ --num_samples 16
50
+
51
+ echo ""
52
+ echo "[Step 4] Evaluating ${MODEL}..."
53
+ python evaluate.py \
54
+ --samples_dir results/${MODEL} \
55
+ --gt_dir ${DATA_ROOT}/testing \
56
+ --results_file results/${MODEL}_eval.csv
57
+
58
+ echo ""
59
+ echo ">>> ${MODEL} complete!"
60
+ echo ""
61
+ done
62
+
63
+ # Step 5: Print comparison summary
64
+ echo ""
65
+ echo "============================================================"
66
+ echo "FINAL RESULTS COMPARISON"
67
+ echo "============================================================"
68
+ python -c "
69
+ import pandas as pd
70
+ import os
71
+
72
+ models = ['unet', 'attention_unet', 'unetpp', 'transunet']
73
+ results = []
74
+
75
+ for m in models:
76
+ f = f'results/{m}_eval.csv'
77
+ if os.path.exists(f):
78
+ df = pd.read_csv(f)
79
+ avg = df[df['image_id'] == 'AVERAGE'].iloc[0]
80
+ results.append({
81
+ 'Method': m,
82
+ 'GED ↓': f\"{avg['ged_iou_paper']:.4f}\",
83
+ 'CI ↑': f\"{avg['CI_Score_Paper']:.4f}\",
84
+ 'Dmax ↑': f\"{avg['D_max_Paper']:.4f}\",
85
+ 'Dice': f\"{avg['avg_dice']:.4f}\",
86
+ 'IoU': f\"{avg['avg_iou']:.4f}\",
87
+ })
88
+
89
+ if results:
90
+ df = pd.DataFrame(results)
91
+ print(df.to_string(index=False))
92
+ else:
93
+ print('No results found!')
94
+ "
95
+
96
+ echo ""
97
+ echo "All baselines complete!"