()
| 270 | |
| 271 | |
| 272 | def main(): |
| 273 | import argparse |
| 274 | |
| 275 | parser = argparse.ArgumentParser() |
| 276 | parser.add_argument("--api_url", default="http://localhost:8080") |
| 277 | parser.add_argument("--prompt_path", required=True) |
| 278 | parser.add_argument("--image_root", default=None) |
| 279 | parser.add_argument("--output_path", default="./results.json") |
| 280 | parser.add_argument("--error_path", default=None) |
| 281 | parser.add_argument("--max_workers", type=int, default=None) |
| 282 | parser.add_argument("--max_retries", type=int, default=10) |
| 283 | parser.add_argument("--timeout_base", type=int, default=60) |
| 284 | args = parser.parse_args() |
| 285 | |
| 286 | with open(args.prompt_path, "r", encoding="utf-8") as f: |
| 287 | test_data = json.load(f) |
| 288 | |
| 289 | open(args.output_path, "w", encoding="utf-8").close() |
| 290 | error_path = args.error_path |
| 291 | if error_path is None: |
| 292 | error_path = f"{args.output_path}.errors.jsonl" |
| 293 | open(error_path, "w", encoding="utf-8").close() |
| 294 | results = evaluate_batch( |
| 295 | test_data, |
| 296 | args.api_url, |
| 297 | image_root=args.image_root, |
| 298 | output_file=args.output_path, |
| 299 | error_file=error_path, |
| 300 | max_workers=args.max_workers, |
| 301 | max_retries=args.max_retries, |
| 302 | timeout_base=args.timeout_base, |
| 303 | ) |
| 304 | |
| 305 | success_count = sum(1 for item in results if item and item.get("success")) |
| 306 | print("\nStatistics:") |
| 307 | print(f"Total data: {len(test_data)}") |
| 308 | ratio = success_count / len(test_data) if len(test_data) > 0 else 0 |
| 309 | print(f"Success ratio: {success_count} ({ratio:.2%})") |
| 310 | |
| 311 | |
| 312 | if __name__ == "__main__": |
no test coverage detected