Download scripts/preflight.py from cobo2026/R4R-Auto-Eval: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/cobo2026/R4R-Auto-Eval/resolve/main/scripts/preflight.py
- Command line
-
hf download hf://datasets/cobo2026/R4R-Auto-Eval/scripts/preflight.py
-
curl -L -o preflight.py https://huggingface.co/datasets/cobo2026/R4R-Auto-Eval/resolve/main/scripts/preflight.py
2.46 kB
| """Validate the frozen 40-case input and decode every sampled frame; no API calls.""" | |
| import hashlib | |
| import json | |
| import sys | |
| from pathlib import Path | |
| import cv2 | |
| import openai | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[2])) | |
| import benchmark_gpt6_astra as runner | |
| def main(): | |
| output = Path('gpt6-reassemble40/results/api-preflight') | |
| config = json.loads((output / 'config.json').read_text()) | |
| previous = json.loads(Path('gpt6-30/results/openrouter/config.json').read_text()) | |
| assert {k: v for k, v in config.items() if k != 'benchmark'} == { | |
| k: v for k, v in previous.items() if k != 'benchmark' | |
| }, 'Inference configuration differs from the original run' | |
| assert hashlib.sha256(runner.SYSTEM_PROMPT.encode()).hexdigest() == previous['prompt_sha256'] | |
| records = [] | |
| paths = sorted(Path('gpt6-reassemble40/benchmark/cases').glob('case_*')) | |
| assert [p.name for p in paths] == [f'case_{n:03d}' for n in range(31, 71)] | |
| for path in paths: | |
| instruction, metadata, videos = runner.load_case(path) | |
| assert len(videos) == 3 | |
| timestamps, fps = runner.choose_timestamps(metadata, len(videos), 2, 1, 30, 900) | |
| hashes = {} | |
| for video in videos: | |
| digest = hashlib.sha256(video.read_bytes()).hexdigest() | |
| assert digest == metadata['videos'][video.stem]['sha256'], str(video) | |
| hashes[video.name] = digest | |
| content, count = runner.make_input(path.name, instruction, metadata, videos, timestamps, 'high', 85) | |
| assert sum(item['type'] == 'input_image' for item in content) == count | |
| records.append({'case_id': path.name, 'image_count': count, | |
| 'sampling_fps': fps, 'timestamps_s': timestamps, | |
| 'video_sha256': hashes, | |
| 'instruction_sha256': hashlib.sha256(instruction.encode()).hexdigest()}) | |
| print(f'{path.name}: {count} images decoded, video hashes verified', flush=True) | |
| report = {'checked_at': runner.utc_now(), 'case_count': len(records), | |
| 'image_count': sum(r['image_count'] for r in records), | |
| 'config_matches_previous_except_benchmark_name': True, | |
| 'openai_sdk_version': openai.__version__, 'opencv_version': cv2.__version__, | |
| 'api_calls': 0, 'ground_truth_read': False, 'cases': records} | |
| runner.atomic_write_json(output / 'preflight.json', report) | |
| if __name__ == '__main__': | |
| main() | |