#!/bin/bash
# 
# Compare Models Only (Skip Evaluation Steps)
# 
# This script runs only the comparison steps (Step 4-5), assuming that
# evaluation and common match finding have already been completed.
#
# Usage:
#   bash eval_tools/compare_models_only.sh <MODEL1_DIR> <MODEL2_DIR> <COMMON_MATCHES_JSON>
#
# Example:
#   bash eval_tools/compare_models_only.sh \
#     eval_results_common_match_comparison/mono3d/20260203_210259 \
#     eval_results_common_match_comparison/yolov5s-300w/20260203_210259 \
#     eval_results_common_match_comparison/common_matches_20260203_210259/common_matches.json


set -e  # Exit on error

# Set PYTHONPATH to project root for module imports
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH}"

MODEL1_DIR="evaluation_results/eval_results_common_match_comparison_cncap_yolov5s_20260228_roi0/yolov5s-300w-newdata/20260228_102849"
MODEL2_DIR="evaluation_results/eval_results_common_match_comparison_cncap_yolov5s_20260228_roi0/yolov5s-300w-newdata-cncap/20260228_102849"
MODEL1_NAME="yolov5s-300w-newdata"
MODEL2_NAME="yolov5s-300w-newdata-cncap"
COMMON_MATCHES_DIR="evaluation_results/eval_results_common_match_comparison_cncap_yolov5s_20260228_roi0/common_matches_20260228_102849"
COMPARISON_DIR="evaluation_results/eval_results_common_match_comparison_cncap_yolov5s_20260228_roi0/comparison_common_matches_20260228_102849-v2"

python eval_tools/model_comparison/compare_models.py \
  --model1 ${MODEL1_DIR}/evaluation_report.json \
  --model2 ${MODEL2_DIR}/evaluation_report.json \
  --model1-name "${MODEL1_NAME}" \
  --model2-name "${MODEL2_NAME}" \
  --common-matches ${COMMON_MATCHES_DIR}/common_matches.json \
  --output-dir ${COMPARISON_DIR}

echo "✓ Comparison results saved to: ${COMPARISON_DIR}"


# python eval_tools/model_comparison/compare_models.py \
#   --model1 ${MODEL1_DIR}/evaluation_report.json \
#   --model2 ${MODEL2_DIR}/evaluation_report.json \
#   --model1-name "${MODEL1_NAME}" \
#   --model2-name "${MODEL2_NAME}" \
#   --output-dir ${COMPARISON_TRADITIONAL_DIR}