File size: 6,332 Bytes
a863f79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import hashlib
import json
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
REL = ROOT / "release" / "data_v1"


def sha256(path):
    h = hashlib.sha256()
    with open(path, "rb") as fh:
        for chunk in iter(lambda: fh.read(1 << 20), b""):
            h.update(chunk)
    return h.hexdigest()


def file_object(name, rel_path, fmt, description, with_hash=True):
    path = REL / rel_path
    if not path.exists():
        raise FileNotFoundError(f"Croissant 引用的文件不存在:{path}")
    obj = {
        "@type": "cr:FileObject",
        "@id": name,
        "name": name,
        "contentUrl": rel_path,
        "encodingFormat": fmt,
        "description": description,
    }
    if with_hash and path.is_file():
        obj["sha256"] = sha256(path)
    return obj


def main():
    truth_rows = [json.loads(line) for line in (REL / "truth" / "truth_all.jsonl").open()]
    first = truth_rows[0]
    fields = []
    for key, dtype in (
        ("scene_id", "sc:Text"),
        ("state", "sc:Text"),
        ("family", "sc:Text"),
        ("image", "sc:Text"),
        ("declared", "sc:Text"),
        ("computed", "sc:Text"),
        ("agree", "sc:Boolean"),
        ("margin", "sc:Float"),
        ("inside_frame", "sc:Boolean"),
        ("pixel_separation", "sc:Float"),
    ):
        if key not in first:
            raise KeyError(f"truth 记录缺少字段 {key}")
        fields.append({"@type": "cr:Field", "@id": f"truth/{key}", "name": key, "dataType": dtype})

    doc = {
        "@context": {
            "@language": "en",
            "@vocab": "https://schema.org/",
            "citeAs": "https://schema.org/citeAs",
            "cr": "http://mlcommons.org/croissant/",
            "rai": "http://mlcommons.org/croissant/RAI/",
        },
        "@type": "sc:Dataset",
        "conformsTo": "http://mlcommons.org/croissant/1.0",
        "name": "Counterfactual Spatial Evidence Benchmark",
        "description": (
            "2,400 paired rendered scenes (4,800 images) built from 192 Objaverse assets. The two members of a pair "
            "are identical except for the pose or contact change that flips one spatial predicate, and the truth is "
            "computed from 3D geometry. Each image is paired with five textual conditions: no evidence, asserted-true, "
            "asserted-false, missing edge and explicit unknown."
        ),
        "version": "1.0.0",
        "datePublished": "2026-11-07",
        "license": "https://creativecommons.org/licenses/by/4.0/",
        "url": "release/data_v1",
        "citeAs": "GraphEvolve Project. Counterfactual Spatial Evidence Benchmark, version 1.0.0. 2026.",
        "creator": {"@type": "sc:Organization", "name": "GraphEvolve Project"},
        "keywords": ["spatial reasoning", "vision-language models", "counterfactual", "scene graph", "benchmark"],
        "rai:dataCollection": "Rendered in Blender 3.3.21 from Objaverse meshes; no human subjects and no scraped personal data.",
        "rai:dataUseCases": "Evaluating how structural assertions change yes/no answers of vision-language models on spatial relations.",
        "rai:dataLimitations": (
            "Synthetic tabletop scenes only; four predicate families; assets normalised to a fixed size; no human "
            "annotation of the rendered pairs; one of 4,800 images has a declared contact state that the recomputed "
            "overlap ratio does not confirm and is listed in metadata/truth_mismatch.json."
        ),
        "rai:dataBiases": "Object categories follow LVIS/Objaverse availability, which over-represents household tabletop objects.",
        "rai:personalSensitiveInformation": "None.",
        "rai:dataSocialImpact": "Intended for measurement and audit of model behaviour; not for deployment decisions.",
        "rai:hasDataUsePermission": "https://mlcommons.org/croissant/RAI/datausepermission/users",
        "distribution": [
            file_object("images_rgb", "images/render_all", "image/png", "4,800 RGB renders with instance masks and 16-bit depth maps.", with_hash=False),
            file_object("truth_all", "truth/truth_all.jsonl", "application/jsonl", "Geometry-derived truth for all 4,800 images."),
            file_object("truth_dev", "truth/truth_dev.jsonl", "application/jsonl", "Development split truth (600 pairs)."),
            file_object("truth_test", "truth/truth_test.jsonl", "application/jsonl", "Test split truth (1,800 pairs)."),
            file_object("prompts_all", "prompts/prompts_all.jsonl", "application/jsonl", "24,000 prompts, five conditions per image."),
            file_object("specs_dev", "specs/scene_specs_dev.jsonl", "application/jsonl", "Development scene specifications with asset ids and poses."),
            file_object("specs_test", "specs/scene_specs_test.jsonl", "application/jsonl", "Test scene specifications with asset ids and poses."),
            file_object("asset_catalog", "assets/asset_catalog.jsonl", "application/jsonl", "192 Objaverse assets with source URL, licence and SHA-256."),
            file_object("licenses", "assets/licenses.csv", "text/csv", "Per-asset licence table."),
            file_object("split_manifest", "metadata/split_manifest.json", "application/json", "Split definition and scene counts."),
            file_object("truth_mismatch", "metadata/truth_mismatch.json", "application/json", "Records where declared and recomputed truth disagree."),
            file_object("checksums", "metadata/CHECKSUMS.sha256", "text/plain", "SHA-256 of every released file.", with_hash=False),
            file_object("code", "code", "text/x-python", "Generation, inference, gating and analysis scripts.", with_hash=False),
        ],
        "recordSet": [
            {
                "@type": "cr:RecordSet",
                "@id": "truth",
                "name": "truth",
                "description": "One row per rendered image; declared state, recomputed geometry truth and agreement flags.",
                "field": fields,
            }
        ],
    }
    out = ROOT / "release" / "croissant.json"
    out.write_text(json.dumps(doc, indent=2, ensure_ascii=False), encoding="utf-8")
    print(json.dumps({"wrote": str(out), "fileObjects": len(doc["distribution"]), "fields": len(fields)}))


if __name__ == "__main__":
    main()