File size: 3,312 Bytes
0a0af24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Minimal demo of loading SimVerse from HuggingFace and verifying a record.

Run from inside the dataset directory:
    cd hf_dataset
    python example_load.py

Or after `huggingface-cli download <org>/simverse --local-dir ./simverse`:
    python simverse/example_load.py

This script:
  1. Loads each of the 5 task configs via `datasets.load_dataset(...)`.
  2. Prints the first record's prompt + answer + media path.
  3. Verifies the referenced image/video file is reachable on disk.
"""
from __future__ import annotations

import json
import os
from pathlib import Path

CONFIGS = ("voi", "cube1", "cube2", "lamp", "cutrope")
ROOT = Path(__file__).resolve().parent


def _resolve_media_path(record: dict, config: str) -> tuple[str, list[Path]]:
    """Pick the canonical media field per config and return (label, list of paths)."""
    if config == "voi":
        rel = record.get("images_relative_to_config", {}) or {}
        target = rel.get("target")
        shapes = list((rel.get("shapes") or {}).values())
        return ("target image + shape images", [
            ROOT / config / target if target else None,
            *(ROOT / config / s for s in shapes if s),
        ])
    if config == "cube1":
        ip = record.get("image_paths", {}) or {}
        return ("blank net + path sequence", [
            ROOT / config / ip.get("blank_net_image", ""),
            ROOT / config / ip.get("path_sequence_image", ""),
        ])
    if config == "cube2":
        rel = record.get("images_relative_to_config", {}) or {}
        return ("initial net + target top face", [
            ROOT / config / rel.get("initialNetImage", ""),
            ROOT / config / rel.get("targetTopFaceImage", ""),
        ])
    if config == "lamp":
        rel = record.get("images_relative_to_config", {}) or {}
        return ("workspace image", [
            ROOT / config / rel.get("image", ""),
        ])
    if config == "cutrope":
        rel = record.get("video_relative_to_config", {}) or {}
        return ("gameplay video", [
            ROOT / config / rel.get("path", ""),
        ])
    return ("?", [])


def main() -> None:
    for config in CONFIGS:
        path = ROOT / config / "test.jsonl"
        if not path.exists():
            print(f"[{config}] missing {path}")
            continue
        with path.open(encoding="utf-8") as fh:
            first = json.loads(fh.readline())
            total = sum(1 for _ in fh) + 1

        sample_id = first.get("__sample_id__")
        prompt_sys = (first.get("prompt") or {}).get("system", "")
        prompt_usr = (first.get("prompt") or {}).get("user", "")
        answer = first.get("answer")
        label, media_paths = _resolve_media_path(first, config)

        print(f"=== {config} ===")
        print(f"  records: {total}")
        print(f"  sample_id: {sample_id}")
        print(f"  prompt.system: {len(prompt_sys)} chars")
        print(f"  prompt.user:   {len(prompt_usr)} chars")
        print(f"  answer keys: {sorted((answer or {}).keys())}")
        print(f"  {label}:")
        for media in media_paths:
            if media is None:
                continue
            ok = "OK" if media.is_file() else "MISSING"
            print(f"    {ok}  {media.relative_to(ROOT)}")
        print()


if __name__ == "__main__":
    main()