Download eval_pvsg/evaluate_model.py from royguw/vsg_eval: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/datasets/royguw/vsg_eval/resolve/main/eval_pvsg/evaluate_model.py
- Command line
-
hf download hf://datasets/royguw/vsg_eval/eval_pvsg/evaluate_model.py
-
curl -L -o evaluate_model.py https://huggingface.co/datasets/royguw/vsg_eval/resolve/main/eval_pvsg/evaluate_model.py
2.05 kB
| #!/usr/bin/env python3 | |
| """ | |
| Evaluate a single Qwen-VL model variant on PVSG dataset | |
| """ | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| from evaluator import PVSGEvaluator | |
| from config import MODELS | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Evaluate Qwen-VL model on PVSG dataset") | |
| parser.add_argument( | |
| "--model_variant", | |
| choices=list(MODELS.keys()), | |
| required=True, | |
| help="Model variant to evaluate" | |
| ) | |
| parser.add_argument( | |
| "--device", | |
| default="auto", | |
| help="Device to use for inference (auto, cuda, cpu)" | |
| ) | |
| parser.add_argument( | |
| "--max_videos", | |
| type=int, | |
| default=None, | |
| help="Maximum number of videos to evaluate (default: all test videos)" | |
| ) | |
| parser.add_argument( | |
| "--no_save_intermediate", | |
| action="store_true", | |
| help="Don't save intermediate checkpoints" | |
| ) | |
| args = parser.parse_args() | |
| print(f"Starting evaluation of {args.model_variant} model") | |
| print(f"Model config: {MODELS[args.model_variant]}") | |
| # Create evaluator | |
| evaluator = PVSGEvaluator( | |
| model_variant=args.model_variant, | |
| device=args.device, | |
| max_videos=args.max_videos | |
| ) | |
| # Run evaluation | |
| try: | |
| results = evaluator.evaluate_all_videos( | |
| save_intermediate=not args.no_save_intermediate | |
| ) | |
| # Print summary | |
| summary = evaluator.get_evaluation_summary() | |
| print("\\n" + "="*50) | |
| print("EVALUATION SUMMARY") | |
| print("="*50) | |
| for key, value in summary.items(): | |
| print(f"{key}: {value}") | |
| print(f"\\nEvaluation completed successfully!") | |
| print(f"Results saved in: {Path(__file__).parent / 'results'}") | |
| except KeyboardInterrupt: | |
| print("\\nEvaluation interrupted by user") | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"\\nError during evaluation: {e}") | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() |