File size: 1,350 Bytes
3726258 3f3fbe2 | 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 | """Record of ``scene_metadata.jsonl`` to render specification.
"""
from strangebench.generation.specs_from_metadata import spec_from_record
RECORD = {
"scene_id": "v2_tier2_1atypical__small_anchor__a000_s0000", "sub_tier": "tier2_1atypical__small_anchor",
"anchor": "person", "partners": ["cat"], "labels_intended": ["person", "cat"], "mode": "atypical",
"planner_layout_xyxy": [[416, 388, 583, 513], [400, 400, 800, 700]], "layout_source": "qwen",
"template_prompt": "A photorealistic photo of a person and a cat", "caption": "A wide shot of a person and a cat.",
"caption_llm": "Qwen/Qwen2.5-3B-Instruct", "render_seed": 52657, "in_balanced": True,
}
def test_stage1_fields():
s = spec_from_record(RECORD)
assert s["anchor"] == {"idx": 0, "name": "person"}
assert s["partners"] == [{"idx": 15, "name": "cat"}]
assert s["labels"] == ["person", "cat"] and s["n_partners"] == 1
assert s["layout_boxes"] == RECORD["planner_layout_xyxy"]
assert s["prompt"] == RECORD["template_prompt"] and s["caption"] == RECORD["caption"]
assert s["img_size"] == 1024
def test_variant_from_sub_tier():
assert spec_from_record(RECORD)["variant"] == "small_anchor"
plain = dict(RECORD, sub_tier="tier2_1atypical", scene_id="v2_tier2_1atypical__a000_s0000")
assert "variant" not in spec_from_record(plain)
|