#!/bin/bash

# YOLOv5-3D 评测启动脚本
# 使用方法: sh eval_tools/run_eval.sh

# ==============================================
# 配置参数
# ==============================================

# 数据路径

# 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}"
DET_PATH="/data1/dongying/Mono3d/G1M3/300w/txt_results"

GT_PATH="/data1/dongying/Mono3d/G1M3/labels"
OUTPUT_DIR="eval_results/$(date +%Y%m%d_%H%M%S)"

# 图像参数
IMG_WIDTH=1920
IMG_HEIGHT=1080

# 评测参数
IOU_THRESHOLD=0.5
CONF_THRESHOLD=0.5
AP_METHOD="voc2010"  # voc2010 或 coco

# 并行进程数 (默认自动检测)
NUM_WORKERS=8  # 设置为空使用自动检测: NUM_WORKERS=""

# ==============================================
# 构建命令
# ==============================================
# 构建命令
# ==============================================

CMD="python eval_tools/core/eval.py \
    --det-path $DET_PATH \
    --gt-path $GT_PATH \
    --output-dir $OUTPUT_DIR \
    --img-width $IMG_WIDTH \
    --img-height $IMG_HEIGHT \
    --iou-threshold $IOU_THRESHOLD \
    --conf-threshold $CONF_THRESHOLD \
    --ap-method $AP_METHOD"

# 添加并行进程数参数
if [ -n "$NUM_WORKERS" ]; then
    CMD="$CMD --num-workers $NUM_WORKERS"
fi

# ==============================================
# 执行评测
# ==============================================

echo "========================================"
echo "YOLOv5-3D 评测"
echo "========================================"
echo "检测结果: $DET_PATH"
echo "真值标签: $GT_PATH"
echo "输出目录: $OUTPUT_DIR"
echo "图像尺寸: ${IMG_WIDTH}x${IMG_HEIGHT}"
echo "IoU阈值: $IOU_THRESHOLD"
echo "置信度阈值: $CONF_THRESHOLD"
if [ -n "$NUM_WORKERS" ]; then
    echo "并行进程: $NUM_WORKERS"
else
    echo "并行进程: 自动检测"
fi
echo "========================================"
echo ""

# 执行命令
eval $CMD

echo ""
echo "评测完成! 结果已保存到: $OUTPUT_DIR"
