#!/usr/bin/env bash

set -euo pipefail

NNODES=${NNODES:-4}
MASTER_ADDR=${MASTER_ADDR:-10.232.119.105}
MASTER_PORT=${MASTER_PORT:-29501}
NPROC_PER_NODE=${NPROC_PER_NODE:-8}
NODE_RANK=${NODE_RANK:?Please set NODE_RANK, for example: NODE_RANK=0 bash train_mono3d_roi1.sh}

python -m torch.distributed.run \
--nnodes="${NNODES}" \
--node_rank="${NODE_RANK}" \
--master_addr "${MASTER_ADDR}" \
--master_port "${MASTER_PORT}" \
--nproc_per_node "${NPROC_PER_NODE}" \
train_mono3d.py \
--epochs 100 \
--lr0 0.01 \
--batch 512 \
--imgsz 768,352 \
--pretrained yolo26s-pretrain.pt \
--roi_metrics_only \
--warmup_epochs 3 \
--loss_3d_warmup_epochs 10 \
--loss_3d_ramp_epochs 10 \
--loss_3d_weight_max 0.01 \
--roi roi1 \
--exp_dir=./runs/detect/train_mono3d_roi1_20260406
