#!/usr/bin/env python3
"""
Print actual parameters used by the anonymization pipeline.
Run this to verify what values are being used for the paper.
"""

import os
import sys
from pathlib import Path

# Load .env file (same way main.py does)
try:
    from dotenv import load_dotenv
    load_dotenv(override=False)
    print("[INFO] Loaded .env file", file=sys.stderr)
except ImportError:
    print("[INFO] python-dotenv not available, using environment only", file=sys.stderr)

print("\n" + "="*70)
print("ACTUAL PARAMETERS USED BY ANONYMIZATION PIPELINE")
print("="*70)

# Person Inpainting (SDXL)
print("\n### PERSON INPAINTING (Phase 1) ###")
print(f"INPAINT_USE_SDXL: {os.getenv('INPAINT_USE_SDXL', 'true')}")
print(f"INPAINT_SDXL_RESOLUTION: {os.getenv('INPAINT_SDXL_RESOLUTION', '1024')}px")
print(f"INPAINT_SDXL_STEPS: {os.getenv('INPAINT_SDXL_STEPS', '50')}")
print(f"INPAINT_STRENGTH: {os.getenv('INPAINT_STRENGTH', '0.9')}")
print(f"INPAINT_GUIDANCE_SCALE: {os.getenv('INPAINT_GUIDANCE_SCALE', '7.5')}")
print(f"INPAINT_CONTROLNET_POSE_SCALE: {os.getenv('INPAINT_CONTROLNET_POSE_SCALE', '0.8')}")
print(f"INPAINT_ETA: {os.getenv('INPAINT_ETA', '0.0')} (0.0=deterministic)")

# Calculate effective steps
try:
    steps = int(os.getenv('INPAINT_SDXL_STEPS', '50'))
    strength = float(os.getenv('INPAINT_STRENGTH', '0.9'))
    effective = int(steps * strength)
    print(f"  → Effective steps executed: {effective} ({steps} × {strength})")
except:
    pass

# Object Inpainting (SDXL)
print("\n### OBJECT INPAINTING (Phase 2) ###")
print(f"INPAINT_OBJECT_USE_SDXL: {os.getenv('INPAINT_OBJECT_USE_SDXL', 'true')}")
print(f"INPAINT_CONTROLNET_OBJECT_SCALE: {os.getenv('INPAINT_CONTROLNET_OBJECT_SCALE', '0.8')}")
print(f"  (Uses same STEPS, STRENGTH, GUIDANCE_SCALE as persons)")

# YOLO Person Detection
print("\n### YOLO PERSON DETECTION (Phase 1) ###")
print(f"YOLO_MODEL_PATH: {os.getenv('YOLO_MODEL_PATH', 'models/yolov8m-seg.pt')}")
print(f"YOLO_CONF: {os.getenv('YOLO_CONF', '0.10')} (confidence threshold)")
print(f"YOLO_MASK_DILATE_KERNEL: {os.getenv('YOLO_MASK_DILATE_KERNEL', '15')}")
print(f"YOLO_MASK_DILATE_ITERATIONS: {os.getenv('YOLO_MASK_DILATE_ITERATIONS', '3')}")

# License Plate Detection
print("\n### LICENSE PLATE DETECTION (Phase 1) ###")
print(f"YOLO_LP_MODEL_PATH: {os.getenv('YOLO_LP_MODEL_PATH', 'models/license-plate-detection/lp_smallobj_1280/weights/best.pt')}")
print(f"YOLO_LP_CONF: {os.getenv('YOLO_LP_CONF', '0.10')} (confidence threshold)")
print(f"YOLO_LP_IMGSZ: {os.getenv('YOLO_LP_IMGSZ', '2560')}px")
print(f"YOLO_LP_IOU: {os.getenv('YOLO_LP_IOU', '0.5')} (NMS threshold)")

# Traffic Sign Detection
print("\n### TRAFFIC SIGN DETECTION (Phase 1) ###")
print(f"YOLO_TS_MODEL_PATH: {os.getenv('YOLO_TS_MODEL_PATH', 'models/traffic-sign-detection/YOLO-TS/weights/GTSDB_best.pt')}")
print(f"YOLO_TS_CONF: {os.getenv('YOLO_TS_CONF', '0.25')} (confidence threshold)")
print(f"YOLO_TS_IMGSZ: {os.getenv('YOLO_TS_IMGSZ', '1024')}px")
print(f"YOLO_TS_IOU: {os.getenv('YOLO_TS_IOU', '0.45')} (NMS threshold)")

# Grounded SAM-2 (Phase 2)
print("\n### GROUNDED SAM-2 (Phase 2 - Indirect PII) ###")
print(f"BOX_THRESHOLD: {os.getenv('BOX_THRESHOLD', '0.35')}")
print(f"TEXT_THRESHOLD: {os.getenv('TEXT_THRESHOLD', '0.25')}")

# Vision Models
print("\n### VISION MODELS ###")
print(f"USE_OLLAMA_VISION: {os.getenv('USE_OLLAMA_VISION', 'false')}")
print(f"OLLAMA_VISION_MODEL: {os.getenv('OLLAMA_VISION_MODEL', 'qwen2.5vl:32b')}")
print(f"USE_GEMINI_VISION: {os.getenv('USE_GEMINI_VISION', 'false')}")
if os.getenv('USE_GEMINI_VISION', 'false').lower() == 'true':
    print(f"GEMINI_VISION_MODEL: {os.getenv('GEMINI_VISION_MODEL', 'gemini-2.5-pro')}")

# LLM Models
print("\n### LLM MODELS (Orchestrator) ###")
print(f"USE_OPENAI: {os.getenv('USE_OPENAI', 'false')}")
print(f"USE_GEMINI: {os.getenv('USE_GEMINI', 'false')}")
if os.getenv('USE_GEMINI', 'false').lower() == 'true':
    print(f"GEMINI_MODEL: gemini-2.5-pro")
elif os.getenv('USE_OPENAI', 'false').lower() == 'true':
    print(f"AUTOGEN_MODEL: {os.getenv('AUTOGEN_MODEL', 'gpt-4o-mini')}")
else:
    print(f"AUTOGEN_MODEL: {os.getenv('AUTOGEN_MODEL', 'qwen2.5:32b')} (Ollama)")

print("\n" + "="*70)
print("\nCopy these values to main.tex and supp.tex for accurate paper documentation.")
print("="*70 + "\n")
