#!/bin/bash
set -e

# ── Paths ─────────────────────────────────────────────────────────────────────
VQA_DIR=/path/to/VQA_v2
COCO_VAL_DIR=/path/to/COCO/val2014
SUBSET_IMG_DIR=/path/to/VQA_v2/sample500_images
DEPTH_DIR=/path/to/VQA_v2/sample500_depth

PROJECT_ROOT=/path/to/experiments
DEPTH_PROJECT_ROOT=/path/to/experiments/depth_hallucination
# ──────────────────────────────────────────────────────────────────────────────

echo "[STEP 1] Prepare VQA subset (questions/answers + copy images)"
cd "${PROJECT_ROOT}"
python ./eval/vqa_v2_subset.py \
  --question-json "${VQA_DIR}/vqa_v2/v2_OpenEnded_mscoco_val2014_questions.json" \
  --annotation-json "${VQA_DIR}/vqa_v2/v2_mscoco_val2014_annotations.json" \
  --num-samples 500 \
  --out-question-file "${VQA_DIR}/sample500_questions.json" \
  --out-answer-file "${VQA_DIR}/sample500_answers.json" \
  --image-root "${COCO_VAL_DIR}" \
  --subset-image-folder "${SUBSET_IMG_DIR}"

echo "[STEP 2] Run DepthAnythingV2 on subset images to produce depth npy"
cd "${DEPTH_PROJECT_ROOT}"
python run_np.py \
  --img-path "${SUBSET_IMG_DIR}" \
  --input-size 518 \
  --outdir "${DEPTH_DIR}" \
  --encoder vitl

echo "[DONE] VQA subset and depth preparation finished."
