Download code/tests/test_specs_from_metadata.py from sidgairo18/strange-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/datasets/sidgairo18/strange-bench/resolve/main/code/tests/test_specs_from_metadata.py
- Command line
-
hf download hf://datasets/sidgairo18/strange-bench/code/tests/test_specs_from_metadata.py
-
curl -L -o test_specs_from_metadata.py https://huggingface.co/datasets/sidgairo18/strange-bench/resolve/main/code/tests/test_specs_from_metadata.py
1.35 kB
| """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) | |