MCPcopy Create free account
hub / github.com/WorldModelBench-Team/WorldModelBench / main

Function main

evaluation.py:209–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207 self.handleError(record)
208
209def main():
210 import argparse
211
212 parser = argparse.ArgumentParser(description="Evaluate World Model Benchmark")
213 parser.add_argument("--judge", type=str, required=True, help="Path to judge model checkpoint")
214 parser.add_argument("--video_dir", type=str, required=True, help="Path to generated video directory")
215 parser.add_argument("--model_name", type=str, required=True, help="Tested model name")
216 parser.add_argument("--save_name", type=str, default="worldmodelbench_results", help="Path to save evaluation results")
217 parser.add_argument("--cot", action="store_true", help="Enable Chain-of-Thought output")
218 parser.add_argument("--no-save", action="store_true", help="Disable saving results")
219
220 args = parser.parse_args()
221
222 # Setup logging with custom Rich handler
223 logging.basicConfig(
224 level=logging.INFO,
225 format="%(message)s",
226 handlers=[RichLogHandler()]
227 )
228 logger = logging.getLogger(__name__)
229
230 # Initialize evaluator
231 config = EvaluationConfig()
232 evaluator = WorldModelEvaluator(args.judge, args.video_dir, config)
233 printer = ResultsPrinter()
234
235 # Load validation set with status message
236 printer.console.print("[bold]Loading validation set...[/bold]")
237 validation_set = load("./worldmodelbench.json")
238
239 # Check for existing results
240 save_path = f"{args.save_name}_cot.json" if args.cot else f"{args.save_name}.json"
241 if os.path.exists(save_path):
242 printer.console.print("[bold yellow]Loading existing results...[/bold yellow]")
243 results = load(save_path)
244 try:
245 preds, accs = results["preds"], results["accs"]
246 except KeyError:
247 raise KeyError("Expected keys not found in results file")
248 else:
249 printer.console.print("[bold green]Starting new evaluation...[/bold green]")
250 preds = {}
251 accs = defaultdict(list)
252
253 # Create a single progress instance for all operations
254 with Progress(
255 "[progress.description]{task.description}",
256 BarColumn(),
257 "[progress.percentage]{task.percentage:>3.0f}%",
258 TimeRemainingColumn(),
259 console=printer.console
260 ) as progress:
261 # Main task for video processing
262 video_task = progress.add_task("Processing videos", total=len(validation_set))
263
264 for vid, v_i in tqdm(enumerate(validation_set), total=len(validation_set)):
265 video_name = Path(v_i["first_frame"]).stem
266 video = evaluator._load_video(video_name)

Callers 1

evaluation.pyFile · 0.85

Calls 8

_load_videoMethod · 0.95
evaluate_videoMethod · 0.95
process_resultsMethod · 0.95
RichLogHandlerClass · 0.85
EvaluationConfigClass · 0.85
WorldModelEvaluatorClass · 0.85
ResultsPrinterClass · 0.85
save_resultsFunction · 0.85

Tested by

no test coverage detected