#!/usr/bin/env python3 """ Public RealVideo-Bench evaluation script. This file merges the dataset/meta preparation flow from process.py with the response parsing and accuracy flow from result/parse_res.py. It intentionally contains no private paths, private imports, API keys, or vendor-specific secrets. Typical usage: 1. Build task jsonl files from the released dataset layout: python public_eval.py build-meta --dataset-root /path/to/RealVideo-Bench/data --output-dir task 2. Run model inference with an OpenAI-compatible vision API: export REALVIDEO_API_KEY="YOUR_API_KEY" export REALVIDEO_BASE_URL="https://your.openai-compatible.endpoint/v1" python public_eval.py infer --task-file task/task1_meta.jsonl --task-type 1 \ --video-root /path/to/RealVideo-Bench/data --model YOUR_MODEL \ --output result/task_1/your_model_fps5.jsonl 3. Parse model responses: python public_eval.py parse --input result/task_1/your_model_fps5.jsonl \ --task-type 1 --output result/parse_res/task_1/your_model_fps5.jsonl \ --parser api --model YOUR_TEXT_MODEL 4. Calculate accuracy: python public_eval.py accuracy --input result/parse_res/task_1/your_model_fps5.jsonl \ --task-type 1 --meta-file task/task1_meta.jsonl """ from __future__ import annotations import argparse import base64 import copy import json import os import random import re import threading import time import traceback from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple try: from tqdm import tqdm except ImportError: # pragma: no cover def tqdm(iterable: Iterable[Any], **_: Any) -> Iterable[Any]: return iterable VIDEO_SUFFIXES = (".mp4", ".avi", ".mkv", ".mov", ".webm") DEFAULT_API_KEY_ENVS = ("REALVIDEO_API_KEY", "OPENAI_API_KEY") DEFAULT_BASE_URL_ENVS = ("REALVIDEO_BASE_URL", "OPENAI_BASE_URL") PROMPT_TASK_1 = """Determine whether the given video is generated by modern AI-based generative models (AIGC). Videos created using traditional computer graphics (CG), animation pipelines, game engines, or professional rendering tools should NOT be classified as AIGC, even though they are not captured from the real world. This includes stylized or animated content, as well as game footage. Such videos may exhibit visual artifacts due to artistic design, rendering limitations, compression, or real-time graphics constraints. However, these artifacts are fundamentally different from those introduced by AI generative models and should NOT be used as evidence for AIGC classification. Your judgment should be based on the presence of artifacts that are characteristic of AIGC methods, arising from the limitations of generative models. Typical AIGC artifacts include, but are not limited to: - temporal inconsistency (e.g., flickering, unstable details across frames), - structural distortions (e.g., warped objects, inconsistent geometry), - unnatural motion or dynamics, - semantic incoherence (e.g., objects appearing/disappearing or morphing inconsistently), - abnormal visual appearance or texture anomalies (e.g., overly smooth, painterly, or "oily" rendering). Do NOT rely solely on visual style (e.g., animation, rendering style, or game graphics) when making your judgment. Instead, focus on identifying artifact patterns that are indicative of AI-based generation. If such AIGC-specific artifacts are clearly present, classify the video as "yes". Otherwise, classify it as "no". Respond with "yes" if the video is AIGC, and "no" otherwise.""" PROMPT_TASK_2 = """You are given two videos,