|
Download code/README.md from sidgairo18/strange-bench: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/datasets/sidgairo18/strange-bench/resolve/main/code/README.md
- Command line
-
hf download hf://datasets/sidgairo18/strange-bench/code/README.md
-
curl -L -o README.md https://huggingface.co/datasets/sidgairo18/strange-bench/resolve/main/code/README.md
3.76 kB
| # STRANGE-Bench generation code | |
| The code that generated this dataset from the COCO `train2017` annotations and public models: co-occurrence | |
| statistics, scene specifications, rendering, automatic audits, the `clean/` and `balanced/` trees, and instance masks. | |
| The launcher defaults are the settings of this release. | |
| ## Layout | |
| ``` | |
| code/ | |
| ├── README.md, requirements.txt, env_template.sh | |
| ├── launchers/ one script per stage (common.sh holds the shared paths) | |
| ├── strangebench/ | |
| │ ├── cooccurrence/ NPMI statistics and partner sampling | |
| │ ├── scene_specs/ sub-tiers, anchor and partner classes, layouts | |
| │ ├── generation/ captioning, rendering and segmentation; specs_from_metadata.py | |
| │ ├── audit/ detector audit and the clean tree | |
| │ ├── strict/ second audit, strict filter, clean / balanced build | |
| │ ├── masks/ instance masks | |
| │ └── common/ shared helpers | |
| └── tests/ CPU tests (pytest) | |
| ``` | |
| ## Setup | |
| Two Python environments, listed with their versions in `requirements.txt`: a generation environment (PyTorch, | |
| diffusers, transformers, SAM 3) and an MMDetection 3.x environment for the Grounding DINO audit. Paths, the Hugging | |
| Face cache and the detector checkpoint are set in `env_template.sh`. | |
| Models: `Qwen/Qwen2.5-3B-Instruct` (layouts, captions), `stabilityai/stable-diffusion-3.5-large` (rendering; gated, | |
| accept its license on the Hub first), SAM 3 (`facebook/sam3`; segmentation, audit, masks), Grounding DINO Swin-B from | |
| MMDetection (audit) and `google/owlv2-large-patch14-ensemble` (audit). No weights are bundled. | |
| ## Running | |
| Edit and source `env_template.sh`, activate the environment of each stage, and run the launchers in order. Sharded | |
| stages take `SHARD_ID` (or `SLURM_ARRAY_TASK_ID`); each launcher has an optional Slurm header. Outputs go under | |
| `$WORK_ROOT`. | |
| | stage | launcher | GPU | what it does | | |
| |---|---|---|---| | |
| | 0 | `stage0_cooccurrence.sh` | no | co-occurrence statistics (NPMI) from COCO train | | |
| | 1 | `stage1_scene_specs.sh` | yes | scene specifications: sub-tier, anchor, partners, layout | | |
| | 2 | `stage2_render.sh` | yes | caption, render (up to 3 attempts) and segment each scene | | |
| | 3 | `stage3_lean_audit.sh` | yes | Grounding DINO audit for unrequested and duplicate objects | | |
| | 4 | `stage4_clean_tree.sh` | no | apply the audit and build the clean tree | | |
| | 5 | `stage5_independent_audits.sh` | yes | SAM 3 and OWLv2 detections of all 80 classes | | |
| | 6 | `stage6_strict_build.sh` | no | strict filter, then the `clean/` and `balanced/` trees | | |
| | 7 | `stage7_masks.sh` | yes | instance masks (COCO RLE) for the released trees | | |
| The full run takes about 200 GPU-hours, most of it in stage 2. Tests: `cd code && pytest tests`. | |
| ## Re-rendering released scenes | |
| ```bash | |
| python code/strangebench/generation/specs_from_metadata.py --metadata scene_metadata.jsonl --out specs.json \ | |
| [--scene-ids ids.txt] | |
| RAW_ROOT=$WORK_ROOT/rerender SCENE_SPECS=specs.json CAPTION_FROM_SPEC=1 NUM_SHARDS=1 bash code/launchers/stage2_render.sh | |
| ``` | |
| Each scene is rendered from its stored caption with the seeds of the release. | |
| ## Notes | |
| - Layouts and captions are sampled from the language model, so a new run gives new ones; the released ones are in | |
| `scene_metadata.jsonl`. | |
| - Use numpy 2 for stage 1 to reproduce the released scene specifications. | |
| - `LEGACY_CAPTION_WORDING=1` in stage 2 uses the caption requests of this release, in which the atypical sub-tiers | |
| were requested with the typical context wording; the default uses the wording described in the paper. | |
| ## License | |
| MIT, see `LICENSE-CODE` at the root of this repository. The dataset is CC BY 4.0 (`LICENSE-DATA`). | |