Repository navigation
Expand file tree
/
Copy pathtrain_partmaterial.sh
More file actions
37 lines (32 loc) · 2.06 KB
/
Copy pathtrain_partmaterial.sh
File metadata and controls
37 lines (32 loc) · 2.06 KB
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
#!/bin/bash
# Train PartMaterialCATSeg (parts + materials) on PACO tabletop + DMS, then score the final
# checkpoint on PACO test (parts, object-conditioned) and DMS test (materials).
# Data: $DETECTRON2_DATASETS/PACO_tabletop (datasets/paco_tabletop_preprocess.py) and
# $DETECTRON2_DATASETS/DMS_material (datasets/dms_material_preprocess.py).
# Config: configs/zero_shot/partmaterialcatseg_paco_dms.yaml (fine-tunes the PACO model).
#
# bash train_partmaterial.sh # full run: 20k iterations
# OUT=output/pm_smoke bash train_partmaterial.sh SOLVER.MAX_ITER 20 TEST.EVAL_PERIOD 0 # smoke test
# CFG=configs/zero_shot/partmaterialcatseg_paco_dms_mattmpl.yaml bash train_partmaterial.sh # material templates
#
# OUT defaults to output/<config name>.
# Trailing args are detectron2 config overrides (KEY VALUE pairs). Re-running resumes from
# $OUT/last_checkpoint. Refuses to start while another process holds the GPU (shared server);
# FORCE=1 overrides that. SKIP_TEST=1 skips the final test-set evaluation.
set -euo pipefail
cd "$(dirname "$0")"
source ./pixi_setup.sh
CFG=${CFG:-configs/zero_shot/partmaterialcatseg_paco_dms.yaml}
OUT=${OUT:-output/$(basename "$CFG" .yaml)}
NUM_GPUS=${NUM_GPUS:-1}
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True # less fragmentation near the 24 GB limit
busy=$(nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader)
if [ -n "$busy" ] && [ "${FORCE:-0}" != 1 ]; then
echo "GPU is in use by other processes; not starting (FORCE=1 to override):"; echo "$busy"; exit 1
fi
run() { pixi run --frozen python train_net.py --num-gpus "$NUM_GPUS" --config-file "$CFG" "$@"; }
# 1. train (evaluates on PACO val + DMS val_1k every TEST.EVAL_PERIOD iterations and at the end)
run --resume OUTPUT_DIR "$OUT" "$@"
# 2. final checkpoint on the test splits: PACO test (parts) and DMS test (materials)
[ "${SKIP_TEST:-0}" = 1 ] || run --eval-only MODEL.WEIGHTS "$OUT/model_final.pth" OUTPUT_DIR "$OUT/test" \
DATASETS.TEST "('paco_tabletop_obj_part_sem_seg_test_obj_condition', 'dms_material_test')"