File size: 3,711 Bytes
1734875 | 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | # SACFlow-FM experiment guide
This guide lists the recommended first set of experiments.
## 0. Environment
```bash
conda env create -f environment.yml
conda activate sacflow
pip install -e .
```
For AMD MI210/ROCm, install the PyTorch ROCm wheel that matches the cluster ROCm version. Example for ROCm 6.2:
```bash
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.2
python -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.device_count())"
```
On ROCm, PyTorch still exposes AMD GPUs through the `torch.cuda` API. Use `torchrun` exactly as with CUDA GPU clusters.
## 1. Prepare dataset manifests
The code uses JSON manifests rather than hard-coded dataset layouts.
### MMWHS CT -> MR
```bash
python tools/create_dataset_json.py \
--name mmwhs_ct2mr \
--source-images /data/MMWHS/CT/images \
--source-labels /data/MMWHS/CT/labels \
--target-images /data/MMWHS/MR/images \
--target-labels /data/MMWHS/MR/labels \
--output data_json/mmwhs_ct2mr.json \
--val-fraction 0.2 \
--test-fraction 0.2 \
--seed 1337
```
### MMWHS MR -> CT
Swap source and target folders and write `data_json/mmwhs_mr2ct.json`.
### CrossMoDA ceT1 -> hrT2
```bash
python tools/create_dataset_json.py \
--name crossmoda_t1_to_t2 \
--source-images /data/CrossMoDA/ceT1/images \
--source-labels /data/CrossMoDA/ceT1/labels \
--target-images /data/CrossMoDA/hrT2/images \
--target-labels /data/CrossMoDA/hrT2/labels_optional_for_eval \
--output data_json/crossmoda_t1_to_t2.json
```
If target labels are not available, keep `target-labels` omitted and use a separate held-out validation set only when you have labels.
## 2. Main MMWHS experiment sequence
### A. Source training
```bash
bash scripts/mmwhs/train_source_ct2mr.sh
```
### B. Export compact source memory
```bash
bash scripts/mmwhs/export_memory_ct.sh
```
### C. Source-only target evaluation
```bash
bash scripts/mmwhs/eval_source_ct2mr.sh
```
### D. Oracle target supervised upper bound
```bash
bash scripts/mmwhs/train_oracle_mr.sh
```
### E. Internal SFDA baselines
```bash
bash scripts/mmwhs/run_selftrain_ct2mr.sh
bash scripts/mmwhs/run_peft_ct2mr.sh
bash scripts/mmwhs/run_proto_align_ct2mr.sh
```
### F. SACFlow-FM and key ablations
```bash
bash scripts/mmwhs/run_sacflow_ct2mr.sh
bash scripts/mmwhs/run_sacflow_linear_ct2mr.sh
bash scripts/mmwhs/run_sacflow_whole_feature_ct2mr.sh
bash scripts/mmwhs/run_sacflow_random_subspace_ct2mr.sh
```
## 3. External baselines
For CCRC, ProtoContra, A3-DualUD, HEAL, and RSA, prefer official repositories and run them on the exact same manifest split. Do not compare reported numbers in the main table unless the dataset split, backbone, label set, and metric are exactly identical.
Recommended first external baselines:
1. CCRC on MMWHS.
2. ProtoContra or A3-DualUD on MMWHS.
3. RSA on CrossMoDA.
## 4. W&B
Set:
```bash
export WANDB_PROJECT=SACFlow-FM
export WANDB_ENTITY=<your_entity_or_leave_empty>
wandb login
```
For offline logging:
```bash
export WANDB_MODE=offline
```
## 5. DDP on 8 AMD GPUs
Each script uses `torchrun`. Example:
```bash
torchrun --standalone --nnodes=1 --nproc_per_node=8 tools/train.py --config configs/experiments/mmwhs_sacflow_ct2mr.yaml
```
## 6. Metrics to monitor
Training logs include:
- total loss and per-loss components;
- CE, Dice, entropy, consistency;
- SACFlow FM loss;
- path-state validity weight;
- domain-progress score;
- task KL/logit drift;
- boundary loss;
- velocity magnitude;
- nullspace leakage;
- pseudo-label confidence and class distribution;
- Dice and HD95/ASSD during validation;
- accepted-state rate;
- ETA and iteration speed.
|