File size: 2,856 Bytes
7c61ee6 | 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 | # Chain: val eval done -> select per family -> one-shot test gen/eval for sub-01/02/03 -> identification + semantic.
source /home/hubin/venvs/trellis/bin/activate
cd /home/hubin/trellis_work
O=/home/hubin/trellis_work/outputs
R=$O/rigor
F=/home/hubin/data/fMRI-Shape
until grep -q VAL_DONE $O/valsel/run_val.log; do sleep 60; done
python mapper/valsel_select.py > $R/select.log 2>&1
# jobs: <out_dir> <tokens> <cfg>; sub-01 uses its val picks; new subjects reuse the sub-01 CFG and use the
# label-family classify-then-generate variant (v2 needs per-subject training).
make_jobs() {
python - "$@" <<'EOF'
import glob, json, sys
O = "/home/hubin/trellis_work/outputs"
sel = json.load(open(f"{O}/valsel/selection.json"))["selection"]
for sub in sys.argv[1:]:
src = f"{O}/valsel/test" if sub == "sub0001" else f"{O}/valsel_{sub}/test"
for fam, s in sel.items():
v = s["variant"]
if sub != "sub0001" and fam == "labels":
v = glob.glob(f"{src}/clsfirst_knn*")[0].split("/")[-1]
print(f"{O}/rigor/{sub}/{fam}_{v}_cfg{s['cfg']} {src}/{v}/tokens.npy {s['cfg']}")
EOF
}
run_jobs() {
while read d tok c; do mkdir -p $d; ln -sf $tok $d/tokens.npy; echo "$c $d"; done > $R/jobs_$1.txt
for c in $(awk '{print $1}' $R/jobs_$1.txt | sort -u); do
D=$(awk -v c=$c '$1==c{print $2}' $R/jobs_$1.txt | tr '\n' ' ')
for w in 0 1 2 3; do
CUDA_VISIBLE_DEVICES=$((w%2)) python gen_from_tokens.py --variant_dirs $D --cfg $c --shard $w --num_shards 4 > $R/gen_$1_cfg${c}_w$w.log 2>&1 &
done
done
wait
for d in $(awk '{print $2}' $R/jobs_$1.txt); do
OMP_NUM_THREADS=8 OPENBLAS_NUM_THREADS=8 MKL_NUM_THREADS=8 python eval_shape.py --gen_dir $d/meshes --out $d/metrics.json --save_pts $d/pts.npz > $d/eval.log 2>&1 &
done
wait
M=""; for d in $(awk '{print $2}' $R/jobs_$1.txt); do M="$M $(echo ${d#$R/} | tr / _)=$d/meshes"; done
CUDA_VISIBLE_DEVICES=1 python ident_eval.py --out_dir $O/ident --methods $M > $R/ident_$1.log 2>&1
}
make_jobs sub0001 sub0002raw | run_jobs a
echo PHASE_A_DONE
until grep -q DL_OK $F/dl_sub23.log; do sleep 120; done
(cd mapper && python precompute_raw.py --sub_id 0003 && \
CUDA_VISIBLE_DEVICES=0 python valsel_preds.py --sub_id 0003raw --out_dir $O/valsel_sub0003raw --v2_runs --auto_lambda) \
> $R/sub0003_prep.log 2>&1
make_jobs sub0003raw | run_jobs b
echo PHASE_B_DONE
until [ -f weights/vit_h_14_swag-80465313.pth ]; do
[ -f /tmp/vith.done ] && [ $(stat -c %s /tmp/vit_h_14_swag-80465313.pth) -eq 2534034033 ] && \
mv /tmp/vit_h_14_swag-80465313.pth weights/
sleep 60
done
M=""; for d in $(awk '{print $2}' $R/jobs_a.txt $R/jobs_b.txt); do M="$M $(echo ${d#$R/} | tr / _)=${d#$O/}"; done
CUDA_VISIBLE_DEVICES=0 python sem_eval.py --methods $M > $R/sem_rigor.log 2>&1
CUDA_VISIBLE_DEVICES=0 python sem_eval.py > $R/sem_all.log 2>&1
echo RIGOR_DONE
|