Image-Text-to-Text
Transformers
Safetensors
qwen3_5
vllm
video
multimodal
reinforcement-learning
temporal-grounding
object-tracking
video-segmentation
visual-question-answering
spatial-reasoning
qwen3.5
conversational
Instructions to use OraRL/Video-ORA-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OraRL/Video-ORA-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OraRL/Video-ORA-9B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("OraRL/Video-ORA-9B") model = AutoModelForMultimodalLM.from_pretrained("OraRL/Video-ORA-9B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OraRL/Video-ORA-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OraRL/Video-ORA-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OraRL/Video-ORA-9B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/OraRL/Video-ORA-9B
- SGLang
How to use OraRL/Video-ORA-9B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OraRL/Video-ORA-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OraRL/Video-ORA-9B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OraRL/Video-ORA-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OraRL/Video-ORA-9B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use OraRL/Video-ORA-9B with Docker Model Runner:
docker model run hf.co/OraRL/Video-ORA-9B
File size: 34,555 Bytes
53c10a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 | from __future__ import annotations
import hashlib
import json
import sys
import types
from pathlib import Path
from types import SimpleNamespace
import pytest
RELEASE_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(RELEASE_ROOT))
from orarl.cli import evaluate # noqa: E402
from orarl.evaluation.layout import ( # noqa: E402
annotation_path as canonical_annotation_path,
)
from orarl.evaluation.layout import media_directory # noqa: E402
def _write_jsonl(path: Path, records: list[dict[str, object]]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(
"".join(json.dumps(record, sort_keys=True) + "\n" for record in records),
encoding="utf-8",
)
def _canonical_root(
tmp_path: Path,
specs: list[dict[str, object]],
) -> Path:
root = tmp_path / "canonical"
manifests: list[dict[str, object]] = []
assets: list[dict[str, object]] = []
for spec in specs:
task = str(spec["task"])
benchmark = str(spec.get("benchmark", task))
split = str(spec.get("split", "test"))
video_bytes = f"{benchmark}/{split}".encode()
video_digest = hashlib.sha256(video_bytes).hexdigest()
video_path = f"{media_directory(benchmark, 'videos')}/{video_digest}.mp4"
(root / video_path).parent.mkdir(parents=True, exist_ok=True)
(root / video_path).write_bytes(video_bytes)
row = {
"schema_version": 1,
"eval_task": task,
"sample_id": f"{benchmark}-{split}",
"benchmark": benchmark,
"split": split,
"problem": "What happens?",
"answer": "A",
"images": [],
"videos": [video_path],
"problem_type": task,
"source": benchmark,
"task_payload": {},
"evaluation": {"metric_profile": "fixture"},
}
annotation_path = canonical_annotation_path(benchmark, split)
_write_jsonl(root / annotation_path, [row])
annotation_bytes = (root / annotation_path).read_bytes()
annotation_digest = hashlib.sha256(annotation_bytes).hexdigest()
manifest = {
"schema_version": 1,
"benchmark": benchmark,
"split": split,
"task": task,
"family": str(spec.get("family", task)),
"annotation_path": annotation_path,
"media_paths": [media_directory(benchmark, "videos")],
"artifact_paths": [],
"expected_count": 1,
"license": "fixture-only",
"source_url": f"https://example.org/{benchmark}",
"redistribution_authorized": True,
"evaluation": spec.get(
"evaluation",
{
"prompt_profile": "fixture",
"parser_profile": "fixture",
"metric_profile": "fixture",
},
),
"checksums": {annotation_path: annotation_digest},
}
if "preprocessing" in spec:
manifest["preprocessing"] = spec["preprocessing"]
if "legacy_environment" in spec:
manifest["legacy_environment"] = spec["legacy_environment"]
manifests.append(manifest)
assets.extend(
[
{
"path": annotation_path,
"sha256": annotation_digest,
"bytes": len(annotation_bytes),
"kind": "annotations",
"benchmark": benchmark,
"license": "fixture-only",
},
{
"path": video_path,
"sha256": video_digest,
"bytes": len(video_bytes),
"kind": "videos",
"benchmark": benchmark,
"license": "fixture-only",
},
]
)
manifests.sort(key=lambda record: (str(record["benchmark"]), str(record["split"])))
assets.sort(key=lambda record: str(record["path"]))
_write_jsonl(root / "datasets.jsonl", manifests)
_write_jsonl(root / "assets.jsonl", assets)
return root
def _canonical_arguments(tmp_path: Path, root: str, tasks: str = "vsi") -> list[str]:
model = tmp_path / "canonical-model"
model.mkdir(exist_ok=True)
evaluator = tmp_path / "canonical-eval.sh"
evaluator.write_text("#!/usr/bin/env bash\nexit 0\n", encoding="utf-8")
return [
"--model",
str(model),
"--tasks",
tasks,
"--dataset",
root,
"--evaluator",
str(evaluator),
"--summary",
str(tmp_path / "canonical-summary.json"),
]
def _base_arguments(tmp_path: Path, tasks: str = "vsi") -> list[str]:
model = tmp_path / "model"
model.mkdir()
evaluator = tmp_path / "eval.sh"
evaluator.write_text("#!/usr/bin/env bash\nexit 0\n", encoding="utf-8")
data_root = tmp_path / "benchmarks"
data_root.mkdir()
return [
"--model",
str(model),
"--tasks",
tasks,
"--data-root",
str(data_root),
"--evaluator",
str(evaluator),
"--summary",
str(tmp_path / "aggregate.json"),
]
def test_released_temporal_profiles_match_the_paper_evaluation() -> None:
records = [
json.loads(line)
for line in (RELEASE_ROOT / "data/eval/datasets.jsonl")
.read_text(encoding="utf-8")
.splitlines()
if line.strip()
]
records = [
record for record in records if record["task"] == "temporal_grounding"
]
assert {record["split"] for record in records} == {
"activitynet_timelens",
"charades_timelens",
"qvhighlights_timelens",
}
assert all(
record["preprocessing"]
== {
"fps": 4,
"max_frames": 2048,
"max_pixels": 409600,
"min_tokens": 1,
"total_tokens": 128000,
}
for record in records
)
def test_eval_builds_restricted_parent_command(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args(_base_arguments(tmp_path, "vsi,mindcube"))
command, environment, tasks, _, summary = evaluate.build_launch(namespace)
assert namespace.dry_run is True
assert tasks == ["vsi", "mindcube"]
assert command[:2] == ["bash", str((tmp_path / "eval.sh").resolve())]
assert command[command.index("--tasks") + 1] == "vsi,mindcube"
assert environment["MINDCUBE_EXPECTED_SAMPLES"] == "1050"
assert environment["VSI_DATA_FILE"].endswith("vsi/annotations.jsonl")
assert summary == (tmp_path / "aggregate.json").resolve()
def test_video_qa_alias_expands_to_documented_tasks(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args(_base_arguments(tmp_path, "video_qa"))
_, _, tasks, _, _ = evaluate.build_launch(namespace)
assert tuple(tasks) == (
"videomme",
"videommev2",
"mvbench",
"mmvu",
"videoholmes",
"longvideobench",
"mlvu",
)
def test_selected_assets_follow_manifested_video_qa_roots() -> None:
records = [
{
"benchmark": "videomme",
"annotation_path": "annotations/video_qa/videomme/test.jsonl",
"media_paths": ["media/video_qa/videomme/videos"],
"artifact_paths": ["artifacts/video_qa/videomme"],
}
]
paths = (
"annotations/video_qa/videomme/test.jsonl",
"media/video_qa/videomme/videos/test/clip.mp4",
"artifacts/video_qa/videomme/test/cache.pt",
"media/video_qa/videommev2/videos/test/other.mp4",
)
assets = [{"path": path} for path in paths]
selected = evaluate._selected_asset_records(assets, records)
assert [record["path"] for record in selected] == list(paths[:3])
def test_videommev2_accepts_bounded_smoke_test(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "videommev2",
"split": "test",
"legacy_environment": {
"VIDEOMMEV2_SETTING": "videommev2-fixture",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="videommev2"),
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["VIDEOMMEV2_MAX_SAMPLES"] == "8"
assert environment["VIDEOMMEV2_DATA_FILE"] == str(
(root / "annotations/video_qa/videommev2/test.jsonl").resolve()
)
def test_videomme_accepts_bounded_smoke_test(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "videomme",
"split": "test",
"legacy_environment": {
"VIDEOMME_SETTING": "videomme-fixture",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="videomme"),
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["VIDEOMME_MAX_SAMPLES"] == "8"
assert environment["VIDEOMME_DATA_FILE"] == str(
(root / "annotations/video_qa/videomme/test.jsonl").resolve()
)
@pytest.mark.parametrize(
("task", "prefix"),
[
("mvbench", "MVBENCH"),
("mmvu", "MMVU"),
("videoholmes", "VIDEOHOLMES"),
("longvideobench", "LONGVIDEOBENCH"),
("mlvu", "MLVU"),
],
)
def test_other_video_qa_tasks_accept_bounded_smoke_tests(
tmp_path: Path,
task: str,
prefix: str,
) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": task,
"split": "test",
"legacy_environment": {
f"{prefix}_SETTING": f"{task}-fixture",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks=task),
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment[f"{prefix}_MAX_SAMPLES"] == "8"
assert environment[f"{prefix}_DATA_FILE"] == str(
(root / f"annotations/video_qa/{task}/test.jsonl").resolve()
)
def test_eval_rejects_unknown_task(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args(_base_arguments(tmp_path, "unknown"))
with pytest.raises(evaluate.CliError, match="unsupported task"):
evaluate.build_launch(namespace)
def test_eval_rejects_benchmark_outside_paper_suite(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args(_base_arguments(tmp_path, "videommmu"))
with pytest.raises(evaluate.CliError, match="unsupported task"):
evaluate.build_launch(namespace)
def test_evaluator_discovery_uses_installed_runtime_checkout(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
runtime_root = tmp_path / "runtime"
package = runtime_root / "verl"
package.mkdir(parents=True)
init_file = package / "__init__.py"
init_file.touch()
evaluator = runtime_root / "eval" / "task" / "eval.sh"
evaluator.parent.mkdir(parents=True)
evaluator.touch()
monkeypatch.setattr(
evaluate,
"find_spec",
lambda _: SimpleNamespace(
origin=str(init_file),
submodule_search_locations=[str(package)],
),
)
assert evaluate._discover_evaluator(None) == evaluator.resolve()
def test_installed_evaluator_uses_wheel_data_files(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
evaluator = tmp_path / "share" / "orarl" / "eval" / "task" / "eval.sh"
evaluator.parent.mkdir(parents=True)
evaluator.touch()
package_distribution = SimpleNamespace(
files=["../../../share/orarl/eval/task/eval.sh"],
locate_file=lambda _: evaluator,
)
monkeypatch.setattr(evaluate, "distribution", lambda _: package_distribution)
assert evaluate._installed_evaluator() == evaluator.resolve()
def test_explicit_missing_evaluator_is_not_silently_ignored(
tmp_path: Path,
) -> None:
with pytest.raises(evaluate.CliError, match="evaluator does not exist"):
evaluate._discover_evaluator(str(tmp_path / "missing.sh"))
def test_task_config_is_allowlisted_and_resolves_relative_paths(tmp_path: Path) -> None:
arguments = _base_arguments(tmp_path)
config = tmp_path / "vsi.yaml"
config.write_text(
"task: vsi\n"
"environment:\n"
" VSI_DATA_FILE: annotations.jsonl\n"
" VSI_PREPROCESSED_VIDEO_DIR: media\n"
" EVAL_CONDA_ENV: orarl-eval\n",
encoding="utf-8",
)
arguments.extend(("--task-config", f"vsi={config}"))
namespace = evaluate.create_parser().parse_args(arguments)
command, environment, _, _, _ = evaluate.build_launch(namespace)
root = (tmp_path / "benchmarks").resolve()
assert environment["VSI_DATA_FILE"] == str(root / "annotations.jsonl")
assert environment["VSI_PREPROCESSED_VIDEO_DIR"] == str(root / "media")
assert "EVAL_CONDA_ENV" not in environment
assert command[command.index("--env") + 1] == "orarl-eval"
def test_canonical_local_root_resolves_profiles_and_paths(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "vsi",
"legacy_environment": {
"VSI_DATA_FILE": "annotations/spatial_intelligence/vsi/test.jsonl",
"VSI_PREPROCESSED_VIDEO_DIR": "media/spatial_intelligence/vsi/videos",
"VSI_TASK_FILTER": ["distance", "direction"],
},
}
],
)
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root))
)
_, environment, tasks, _, _ = evaluate.build_launch(namespace)
assert tasks == ["vsi"]
assert environment["ORARL_EVAL_DATA_ROOT"] == str(root.resolve())
assert environment["ORARL_EVAL_DATASETS_JSONL"] == str(
(root / "datasets.jsonl").resolve()
)
assert environment["VSI_DATA_FILE"] == str(
(root / "annotations/spatial_intelligence/vsi/test.jsonl").resolve()
)
assert environment["VSI_PREPROCESSED_VIDEO_DIR"] == str(
(root / "media/spatial_intelligence/vsi/videos").resolve()
)
assert environment["VSI_EXPECTED_SAMPLES"] == "1"
assert environment["VSI_TASK_FILTER"] == "distance,direction"
def test_canonical_revsi_uses_all_frame_profile_and_assets(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "revsi",
"family": "spatial_intelligence",
"legacy_environment": {
"REVSI_FRAME_BUDGET": "all",
"REVSI_MAX_FRAMES": 128,
"REVSI_EXACT_NFRAMES": True,
"REVSI_VIDEO_TOTAL_PIXELS": 16777216,
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="revsi"),
"--batch-size",
"4",
"--max-samples",
"8",
]
)
_, environment, tasks, _, _ = evaluate.build_launch(namespace)
assert tasks == ["revsi"]
assert environment["REVSI_DATA_FILE"] == str(
(root / "annotations/spatial_intelligence/revsi/test.jsonl").resolve()
)
assert environment["REVSI_VIDEO_ROOT"] == str(root.resolve())
assert environment["REVSI_EXPECTED_SAMPLES"] == "1"
assert environment["REVSI_FRAME_BUDGET"] == "all"
assert environment["REVSI_EXACT_NFRAMES"] == "true"
assert environment["REVSI_BATCH_SIZE"] == "4"
assert environment["REVSI_MAX_SAMPLES"] == "8"
def test_canonical_segmentation_supports_bounded_smoke_test(tmp_path: Path) -> None:
splits = ("mevis", "reasonvos", "refcoco", "refcocog", "refcocop")
root = _canonical_root(
tmp_path,
[
{
"task": "segmentation",
"split": split,
"family": "segmentation",
"legacy_environment": {
"SEGMENTATION_RUN_SAM2": False,
"SEGMENTATION_MAX_FRAMES": 128,
},
}
for split in splits
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="segmentation"),
"--max-samples",
"1",
]
)
_, environment, tasks, _, _ = evaluate.build_launch(namespace)
assert tasks == ["segmentation"]
assert environment["SEGMENTATION_DATASETS"] == ",".join(splits)
assert environment["SEGMENTATION_DATA_ROOT"] == str(root.resolve())
assert environment["SEGMENTATION_MAX_SAMPLES"] == "1"
assert environment["SEGMENTATION_RUN_SAM2"] == "false"
def test_canonical_metadata_can_use_a_separate_asset_root(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "vsi",
"legacy_environment": {
"VSI_PREPROCESSED_VIDEO_DIR": "media/spatial_intelligence/vsi/videos",
},
}
],
)
asset_root = tmp_path / "external-assets"
asset_root.mkdir()
(root / "assets.jsonl").rename(asset_root / "assets.jsonl")
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root)),
"--asset-root",
str(asset_root),
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["ORARL_EVAL_DATA_ROOT"] == str(root.resolve())
assert environment["ORARL_EVAL_ASSET_ROOT"] == str(asset_root.resolve())
assert environment["VSI_PREPROCESSED_VIDEO_DIR"] == str(
(asset_root / "media/spatial_intelligence/vsi/videos").resolve()
)
def test_temporal_grounding_accepts_per_split_preprocessing_profiles(
tmp_path: Path,
) -> None:
datasets = "charades_timelens,activitynet_timelens,qvhighlights_timelens"
root = _canonical_root(
tmp_path,
[
{
"task": "temporal_grounding",
"split": split,
"preprocessing": {
"fps": fps,
"min_tokens": 1,
"max_frames": 2048,
"max_pixels": 409600,
"total_tokens": 128000,
},
"legacy_environment": {"TIMELENS_DATASETS": datasets},
}
for split, fps in (
("charades_timelens", 4),
("activitynet_timelens", 2),
("qvhighlights_timelens", 2),
)
],
)
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root), tasks="temporal_grounding")
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["TIMELENS_DATASETS"] == datasets
assert environment["TIMELENS_BENCH_DIR"] == str(
(root / "annotations/temporal_grounding").resolve()
)
def test_temporal_grounding_can_select_sta_for_a_bounded_smoke_test(
tmp_path: Path,
) -> None:
datasets = "charades_timelens,activitynet_timelens,qvhighlights_timelens"
root = _canonical_root(
tmp_path,
[
{
"task": "temporal_grounding",
"split": split,
"preprocessing": {
"fps": fps,
"min_tokens": 1,
"max_frames": 2048,
"max_pixels": 409600,
"total_tokens": 128000,
},
"legacy_environment": {"TIMELENS_DATASETS": datasets},
}
for split, fps in (
("charades_timelens", 4),
("activitynet_timelens", 2),
("qvhighlights_timelens", 2),
)
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(
tmp_path,
str(root),
tasks="temporal_grounding",
),
"--splits",
"charades_timelens",
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["TIMELENS_DATASETS"] == "charades_timelens"
assert environment["TIMELENS_MAX_SAMPLES"] == "8"
assert environment["TIMELENS_FPS"] == "4"
assert environment["TIMELENS_MIN_TOKENS"] == "1"
assert environment["TIMELENS_MAX_FRAMES"] == "2048"
assert environment["TIMELENS_MAX_PIXELS"] == "409600"
assert environment["TIMELENS_TOTAL_TOKENS"] == "128000"
def test_spatial_grounding_maps_canonical_split_to_evaluator_name(
tmp_path: Path,
) -> None:
evaluator_datasets = "refcoco-val,refcoco+-testA"
root = _canonical_root(
tmp_path,
[
{
"task": "spatial_grounding",
"split": split,
"preprocessing": {"coordinate_system": "norm1000"},
"legacy_environment": {
"SPATIAL_GROUNDING_DATASETS": evaluator_datasets,
},
}
for split in ("refcoco_val", "refcocop_test_a")
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(
tmp_path,
str(root),
tasks="spatial_grounding",
),
"--splits",
"refcocop_test_a",
"--max-samples",
"16",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["SPATIAL_GROUNDING_DATASETS"] == "refcoco+-testA"
assert environment["SPATIAL_GROUNDING_MAX_SAMPLES"] == "16"
assert environment["SPATIAL_GROUNDING_BENCH_DIR"] == str(
(root / "annotations/spatial_grounding").resolve()
)
def test_tracking_maps_canonical_split_to_evaluator_name(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "tracking",
"split": "got10k",
"preprocessing": {
"tracking_fps": 1,
"tracking_max_frames": 32,
},
"legacy_environment": {
"TRACKING_DATASETS": "eval_got10k",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="tracking"),
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["TRACKING_DATASETS"] == "eval_got10k"
assert environment["TRACKING_MAX_SAMPLES"] == "8"
assert environment["TRACKING_BENCH_DIR"] == str(
(root / "annotations/tracking").resolve()
)
def test_stvg_maps_canonical_split_and_smoke_limit(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "stvg",
"split": "stvg",
"preprocessing": {
"stvg_fps": 2,
"stvg_max_frames": 128,
},
"legacy_environment": {
"STVG_DATASETS": "eval_stvg",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root), tasks="stvg"),
"--max-samples",
"8",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["STVG_DATASETS"] == "eval_stvg"
assert environment["STVG_MAX_SAMPLES"] == "8"
assert environment["STVG_BENCH_DIR"] == str(
(root / "annotations/stvg").resolve()
)
def test_canonical_dry_run_needs_only_valid_manifests(tmp_path: Path) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
for path in (root / "annotations").rglob("*"):
if path.is_file():
path.unlink()
for path in (root / "media").rglob("*"):
if path.is_file():
path.unlink()
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root))
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["VSI_DATA_FILE"].endswith(
"annotations/spatial_intelligence/vsi/test.jsonl"
)
def test_canonical_hf_dataset_uses_manifest_only_snapshot_for_dry_run(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
calls: list[dict[str, object]] = []
module = types.ModuleType("huggingface_hub")
def snapshot_download(**kwargs: object) -> str:
calls.append(dict(kwargs))
return str(root)
module.snapshot_download = snapshot_download # type: ignore[attr-defined]
monkeypatch.setitem(sys.modules, "huggingface_hub", module)
cache_dir = tmp_path / "hf-cache"
arguments = _canonical_arguments(tmp_path, "org/evaluation-data")
arguments.extend(
(
"--revision",
"release",
"--cache-dir",
str(cache_dir),
"--local-files-only",
)
)
namespace = evaluate.create_parser().parse_args(arguments)
evaluate.build_launch(namespace)
assert calls == [
{
"repo_id": "org/evaluation-data",
"repo_type": "dataset",
"revision": "release",
"cache_dir": str(cache_dir),
"local_files_only": True,
"allow_patterns": ["datasets.jsonl", "assets.jsonl"],
}
]
def test_canonical_hf_run_downloads_only_selected_task_assets(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
root = _canonical_root(
tmp_path,
[{"task": "vsi"}, {"task": "mmsi"}],
)
calls: list[dict[str, object]] = []
module = types.ModuleType("huggingface_hub")
def snapshot_download(**kwargs: object) -> str:
calls.append(dict(kwargs))
return str(root)
module.snapshot_download = snapshot_download # type: ignore[attr-defined]
monkeypatch.setitem(sys.modules, "huggingface_hub", module)
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, "org/evaluation-data"),
"--run",
]
)
evaluate.build_launch(namespace)
assert len(calls) == 2
selected = calls[1]["allow_patterns"]
assert isinstance(selected, list)
assert "annotations/spatial_intelligence/vsi/test.jsonl" in selected
assert any(
str(path).startswith("media/spatial_intelligence/vsi/")
for path in selected
)
assert not any(
str(path).startswith("media/spatial_intelligence/mmsi/")
for path in selected
)
def test_canonical_dataset_requires_task_coverage(tmp_path: Path) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root), "vsi,mmsi")
)
with pytest.raises(evaluate.CliError, match="no configuration record.*mmsi"):
evaluate.build_launch(namespace)
def test_canonical_dataset_rejects_conflicting_structured_profiles(
tmp_path: Path,
) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "tracking",
"split": "got10k",
"evaluation": {"metric_profile": "one"},
},
{
"task": "tracking",
"split": "lasot",
"evaluation": {"metric_profile": "two"},
},
],
)
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root), "tracking")
)
with pytest.raises(evaluate.CliError, match="conflicting canonical evaluation"):
evaluate.build_launch(namespace)
def test_canonical_structured_records_merge_identical_profiles(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{"task": "tracking", "split": "got10k"},
{"task": "tracking", "split": "lasot"},
],
)
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root), "tracking")
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["TRACKING_DATASETS"] == "eval_got10k,lasot"
assert environment["TRACKING_BENCH_DIR"] == str(
(root / "annotations/tracking").resolve()
)
assert environment["TRACKING_BASE_PREFIX"] == str(root.resolve())
def test_canonical_dataset_rejects_unrelated_profile_settings(tmp_path: Path) -> None:
root = _canonical_root(
tmp_path,
[
{
"task": "mmsi",
"legacy_environment": {
"VSI_DATA_FILE": "annotations/spatial_intelligence/mmsi/test.jsonl",
},
}
],
)
namespace = evaluate.create_parser().parse_args(
_canonical_arguments(tmp_path, str(root), "mmsi")
)
with pytest.raises(evaluate.CliError, match="unrelated canonical profile"):
evaluate.build_launch(namespace)
def test_canonical_run_verifies_asset_sizes_without_rehashing(tmp_path: Path) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
video = next((root / "media/spatial_intelligence/vsi/videos").iterdir())
video.write_bytes(b"bad")
namespace = evaluate.create_parser().parse_args(
[*_canonical_arguments(tmp_path, str(root)), "--run"]
)
with pytest.raises(evaluate.CliError, match="byte-size mismatch"):
evaluate.build_launch(namespace)
def test_canonical_run_validates_separate_asset_root(tmp_path: Path) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
asset_root = tmp_path / "external-assets"
asset_root.mkdir()
(root / "assets.jsonl").rename(asset_root / "assets.jsonl")
(root / "media").rename(asset_root / "media")
namespace = evaluate.create_parser().parse_args(
[
*_canonical_arguments(tmp_path, str(root)),
"--asset-root",
str(asset_root),
"--run",
]
)
_, environment, _, _, _ = evaluate.build_launch(namespace)
assert environment["ORARL_EVAL_ASSET_ROOT"] == str(asset_root.resolve())
def test_dataset_and_data_root_are_mutually_exclusive(tmp_path: Path) -> None:
root = _canonical_root(tmp_path, [{"task": "vsi"}])
arguments = _canonical_arguments(tmp_path, str(root))
legacy_root = tmp_path / "legacy-root"
legacy_root.mkdir()
arguments.extend(("--data-root", str(legacy_root)))
namespace = evaluate.create_parser().parse_args(arguments)
with pytest.raises(evaluate.CliError, match="mutually exclusive"):
evaluate.build_launch(namespace)
def test_asset_root_requires_canonical_dataset(tmp_path: Path) -> None:
asset_root = tmp_path / "assets"
asset_root.mkdir()
namespace = evaluate.create_parser().parse_args(
[*_base_arguments(tmp_path), "--asset-root", str(asset_root)]
)
with pytest.raises(evaluate.CliError, match="requires --dataset"):
evaluate.build_launch(namespace)
def test_split_selection_requires_canonical_dataset(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args(
[*_base_arguments(tmp_path), "--splits", "test"]
)
with pytest.raises(evaluate.CliError, match="requires --dataset"):
evaluate.build_launch(namespace)
def test_run_rejects_missing_conventional_inputs(tmp_path: Path) -> None:
namespace = evaluate.create_parser().parse_args([*_base_arguments(tmp_path), "--run"])
with pytest.raises(evaluate.CliError, match="input does not exist"):
evaluate.build_launch(namespace)
def test_sam2_run_requires_explicit_postprocessor_files(tmp_path: Path) -> None:
arguments = _base_arguments(tmp_path, "segmentation")
data_root = tmp_path / "benchmarks"
(data_root / "segmentation").mkdir()
for name in ("sam2.yaml", "sam2.pt", "postprocess.py"):
(data_root / name).touch()
config = tmp_path / "segmentation.yaml"
config.write_text(
"task: segmentation\n"
"environment:\n"
" SEGMENTATION_SAM2_CFG: sam2.yaml\n"
" SEGMENTATION_SAM2_CKPT: sam2.pt\n"
" SEGMENTATION_POSTPROCESSOR_PATH: postprocess.py\n",
encoding="utf-8",
)
arguments.extend(
(
"--task-config",
f"segmentation={config}",
"--segmentation-run-sam2",
"--run",
)
)
namespace = evaluate.create_parser().parse_args(arguments)
command, environment, _, _, _ = evaluate.build_launch(namespace)
assert "--segmentation-run-sam2" in command
assert environment["SEGMENTATION_POSTPROCESSOR_PATH"] == str(data_root / "postprocess.py")
def test_aggregate_embeds_new_official_summary(tmp_path: Path) -> None:
results_root = tmp_path / "outputs"
task_output = (
results_root
/ "model"
/ "spatial_intelligence"
/ "vsi"
/ "base"
/ "setting"
/ "run"
)
task_output.mkdir(parents=True)
(task_output / "summary.json").write_text(
json.dumps({"accuracy": 42.0}),
encoding="utf-8",
)
aggregate = tmp_path / "aggregate.json"
evaluate._write_aggregate(
aggregate,
model=str(tmp_path / "model"),
tasks=["vsi"],
results_root=results_root,
before={},
returncode=0,
)
payload = json.loads(aggregate.read_text(encoding="utf-8"))
assert payload["completed_tasks"] == ["vsi"]
assert payload["missing_tasks"] == []
assert payload["results"][0]["metrics"] == {"accuracy": 42.0}
|