set -e
set -x

export PYTHONPATH=$PWD
export DETECTRON2_DATASETS=${your_data_path}

MODEL_DIR=${your_model_path}

CUDA_VISIBLE_DEVICES=0,1,2,3 python train_net_rcnn.py \
  --config configs/Base-RCNN-TSP.yaml \
  --num-gpus 4 \
  --dist-url "tcp://localhost:23457" \
  OUTPUT_DIR ${MODEL_DIR} \
  MODEL.WEIGHTS "detectron2://ImageNetPretrained/MSRA/R-50.pkl" \
  MODEL.RESNETS.DEPTH 50 \
  MODEL.ANCHOR_GENERATOR.SIZES "[[32, 40.32, 51.80], [64, 80.63, 101.59], [128, 161.27, 203.19], [256, 322.54, 406.37], [512, 645.08, 812.75]]" \
  MODEL.RPN.IN_FEATURES "['p3', 'p4', 'p5', 'p6', 'p7']" \
  MODEL.RPN.HEAD_NAME "MyStandardRPNHead" \
  MODEL.RPN.NUM_CONV 2 \
  MODEL.RPN.BBOX_REG_LOSS_WEIGHT 2.0 \
  MODEL.RPN.POST_NMS_TOPK_TRAIN 700 \
  MODEL.RPN.POST_NMS_TOPK_TEST 700 \
  MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE 700 \
  MODEL.ROI_BOX_HEAD.RANDOM_PROPOSAL_DROP True \
  MODEL.ROI_BOX_HEAD.RANDOM_PROPOSAL_DROP_LOWER_BOUND 0.7 \
  MODEL.ROI_BOX_HEAD.USE_OBJ_LOSS True \
  MODEL.ROI_HEADS.NMS_THRESH_TEST 0.7 \
  MODEL.MY_ROI_BOX_HEAD.NUM_FC 1 \
  MODEL.MY_ROI_BOX_HEAD.DIM_FEEDFORWARD 2048 \
  SOLVER.IMS_PER_BATCH 16 \
  SOLVER.BASE_LR 0.02 \
  SOLVER.TRANSFORMER_MULTIPLIER 0.005 \
  SOLVER.STEPS "(180000, 240000)" \
  SOLVER.MAX_ITER 270000 \
  SOLVER.CHECKPOINT_PERIOD 10000
