forked from Intellindust-AI-Lab/DEIMv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_lightly_distill_dinov3_splus_vitb.sh
More file actions
executable file
·77 lines (66 loc) · 2.3 KB
/
Copy pathrun_lightly_distill_dinov3_splus_vitb.sh
File metadata and controls
executable file
·77 lines (66 loc) · 2.3 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
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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CUDA_DEVICES="${CUDA_DEVICES:-0,1,2,3}"
CONDA_ENV="${CONDA_ENV:-deimv2}"
DATA_DIR="${DATA_DIR:-/home/nikhileswara/DEIMv2/data/crowd_human_mot_coco/images/train}"
OUT_DIR="${OUT_DIR:-/home/nikhileswara/DEIMv2/outputs/lightly_distill/dinov3_vits16plus_from_vitb16_crowd_human_mot}"
STUDENT_MODEL="${STUDENT_MODEL:-dinov3/vits16plus}"
TEACHER_MODEL="${TEACHER_MODEL:-dinov3/vitb16}"
METHOD="${METHOD:-distillationv2}"
EPOCHS="${EPOCHS:-200}"
BATCH_SIZE="${BATCH_SIZE:-512}"
NUM_WORKERS="${NUM_WORKERS:-16}"
DEVICES="${DEVICES:-4}"
PRECISION="${PRECISION:-32-true}"
SEED="${SEED:-143}"
OVERWRITE="${OVERWRITE:-0}"
RESUME_INTERRUPTED="${RESUME_INTERRUPTED:-0}"
RUNNER="${ROOT_DIR}/engine/lightly_distill_deimv2/run_distill_dinov3_splus_vitb.py"
LOG_DIR="${LOG_DIR:-${ROOT_DIR}/logs/lightly_distill}"
LOG_FILE="${LOG_FILE:-${LOG_DIR}/$(basename "${OUT_DIR}").log}"
if [[ ! -f "${RUNNER}" ]]; then
echo "Runner not found: ${RUNNER}" >&2
exit 1
fi
if [[ ! -d "${DATA_DIR}" ]]; then
echo "Data directory not found: ${DATA_DIR}" >&2
exit 1
fi
# Backward-compat cleanup: old launcher wrote live.log inside OUT_DIR, which
# makes Lightly refuse to start because the output dir is not empty.
if [[ -d "${OUT_DIR}" && -f "${OUT_DIR}/live.log" ]]; then
if [[ -z "$(find "${OUT_DIR}" -mindepth 1 -maxdepth 1 ! -name 'live.log' -print -quit)" ]]; then
rm -f "${OUT_DIR}/live.log"
rmdir "${OUT_DIR}" 2>/dev/null || true
fi
fi
mkdir -p "$(dirname "${LOG_FILE}")"
echo "Starting LightlyTrain distillation"
echo "CUDA_VISIBLE_DEVICES=${CUDA_DEVICES}"
echo "DATA_DIR=${DATA_DIR}"
echo "OUT_DIR=${OUT_DIR}"
echo "LOG_FILE=${LOG_FILE}"
CMD=(
conda run --no-capture-output -n "${CONDA_ENV}" python -u "${RUNNER}"
--data "${DATA_DIR}"
--out "${OUT_DIR}"
--student-model "${STUDENT_MODEL}"
--teacher-model "${TEACHER_MODEL}"
--method "${METHOD}"
--epochs "${EPOCHS}"
--batch-size "${BATCH_SIZE}"
--num-workers "${NUM_WORKERS}"
--devices "${DEVICES}"
--precision "${PRECISION}"
--seed "${SEED}"
)
if [[ "${OVERWRITE}" == "1" ]]; then
CMD+=(--overwrite)
fi
if [[ "${RESUME_INTERRUPTED}" == "1" ]]; then
CMD+=(--resume-interrupted)
fi
CUDA_VISIBLE_DEVICES="${CUDA_DEVICES}" \
PYTHONUNBUFFERED=1 \
"${CMD[@]}" 2>&1 | tee "${LOG_FILE}"