Download scripts/train.sh from pramodthe/sam3-construction-drawings: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/pramodthe/sam3-construction-drawings/resolve/main/scripts/train.sh
- Command line
-
hf download hf://pramodthe/sam3-construction-drawings/scripts/train.sh
-
curl -L -o train.sh https://huggingface.co/pramodthe/sam3-construction-drawings/resolve/main/scripts/train.sh
1.35 kB
| # Fine-tune SAM3 on a prepared COCO dataset with Meta's trainer, on one GPU. | |
| # Usage: DATASET_ROOT=/path/to/dataset_1008 [OUTPUT_DIR=./runs] scripts/train.sh drawing_v1_full | |
| set -euo pipefail | |
| CONFIG="${1:?config name: drawing_v1_smoke or drawing_v1_full}" | |
| REPO="$(cd "$(dirname "$0")/.." && pwd)" | |
| : "${DATASET_ROOT:?set DATASET_ROOT to the prepared dataset folder (train/ valid/ test/)}" | |
| export DATASET_ROOT="$(cd "$DATASET_ROOT" && pwd)" | |
| export OUTPUT_DIR="${OUTPUT_DIR:-$REPO/runs}" | |
| mkdir -p "$OUTPUT_DIR" | |
| export OUTPUT_DIR="$(cd "$OUTPUT_DIR" && pwd)" | |
| PYTHON="${PYTHON:-python}" | |
| export PYTHONPATH="$REPO${PYTHONPATH:+:$PYTHONPATH}" | |
| # Meta's trainer only searches its own config package, so link these configs into it. | |
| SAM3_TRAIN_DIR="$("$PYTHON" -c 'import sam3.train as t; print(list(t.__path__)[0])')" | |
| ln -sfn "$REPO/configs" "$SAM3_TRAIN_DIR/configs/drawings" | |
| export SAM3_BPE_PATH="$("$PYTHON" -c 'from sam3_drawings.inference import bpe_path; print(bpe_path())')" | |
| export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True | |
| # Fewer glibc arenas keeps host RAM flat on machines with ~16 GB. | |
| export MALLOC_ARENA_MAX=2 | |
| # Run from the output folder so a local sam3/ checkout can't shadow the installed package. | |
| cd "$OUTPUT_DIR" | |
| exec "$PYTHON" -m sam3.train.train -c "configs/drawings/$CONFIG.yaml" --use-cluster 0 --num-gpus 1 | |