(prompt_dict)
| 63 | per_motion_metrics = [] |
| 64 | |
| 65 | def evaluate_entry(prompt_dict): |
| 66 | video_label = prompt_dict.get('prompt', 'unknown') |
| 67 | video_path = prompt_dict.get('evaluation_file', '') |
| 68 | motion_id = prompt_dict.get('id') |
| 69 | |
| 70 | if not os.path.exists(video_path): |
| 71 | return {"skip": True, "id": motion_id, "error": f"Missing video {video_path}"} |
| 72 | |
| 73 | try: |
| 74 | # Read video bytes directly - fps is now handled by Gemini API |
| 75 | with open(video_path, 'rb') as f: |
| 76 | video_bytes = f.read() |
| 77 | except Exception as exc: |
| 78 | return {"skip": True, "id": motion_id, "error": f"Video read error: {exc}"} |
| 79 | |
| 80 | |
| 81 | try: |
| 82 | response = call_gemini_api(video_bytes, prompt + f'"{video_label}".', api_key, fps=vlm_fps) |
| 83 | |
| 84 | except Exception as exc: |
| 85 | return {"skip": True, "id": motion_id, "error": f"Gemini error: {exc}"} |
| 86 | |
| 87 | response = response.encode('utf-8').decode('utf-8').strip() |
| 88 | decision_text = response.split("Answer:", 1)[-1].strip() |
| 89 | is_correct = "yes" in decision_text.lower() |
| 90 | |
| 91 | return { |
| 92 | "skip": False, |
| 93 | "id": motion_id, |
| 94 | "is_correct": is_correct, |
| 95 | "video_label": video_label, |
| 96 | "video_path": video_path, |
| 97 | "decision_text": decision_text, |
| 98 | "raw_response": response, |
| 99 | } |
| 100 | |
| 101 | with ThreadPoolExecutor(max_workers=gemini_workers) as executor: |
| 102 | futures = {executor.submit(evaluate_entry, prompt_dict): prompt_dict for prompt_dict in prompt_dict_ls} |
nothing calls this directly
no test coverage detected