Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,491 +1,134 @@
|
|
| 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 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
```bash
|
| 136 |
-
# Install dependencies
|
| 137 |
-
pip install -r requirements.txt
|
| 138 |
-
|
| 139 |
-
# Generate 5 scene sets with 5 objects each
|
| 140 |
-
python pipeline.py --num_scenes 5 --num_objects 5 --run_name my_first_run
|
| 141 |
-
|
| 142 |
-
# Generate examples of all counterfactual types
|
| 143 |
-
python scripts/generate_examples.py --render
|
| 144 |
-
```
|
| 145 |
-
|
| 146 |
-
### Web Interface (Streamlit)
|
| 147 |
-
|
| 148 |
-
Run the Streamlit web interface for an interactive experience:
|
| 149 |
-
|
| 150 |
-
```bash
|
| 151 |
-
streamlit run app.py
|
| 152 |
-
```
|
| 153 |
-
|
| 154 |
-
The web interface provides:
|
| 155 |
-
- Interactive parameter configuration
|
| 156 |
-
- Real-time progress
|
| 157 |
-
- Visual output preview
|
| 158 |
-
- Downloadable results as ZIP files
|
| 159 |
-
|
| 160 |
-
### 1. Generate and Render (Combined)
|
| 161 |
-
|
| 162 |
-
Use `python pipeline.py` to generate scene JSON files and render PNG images in one step:
|
| 163 |
-
|
| 164 |
-
```bash
|
| 165 |
-
python pipeline.py --num_scenes 10 --num_objects 5 --run_name experiment1
|
| 166 |
-
```
|
| 167 |
-
|
| 168 |
-
### 2. Generate Only (Skip Rendering)
|
| 169 |
-
|
| 170 |
-
Generate scenes without rendering:
|
| 171 |
-
|
| 172 |
-
```bash
|
| 173 |
-
python pipeline.py --num_scenes 10 --num_objects 5 --run_name experiment1 --skip_render
|
| 174 |
-
```
|
| 175 |
-
|
| 176 |
-
### 4. Render Existing Scenes Only
|
| 177 |
-
|
| 178 |
-
Render previously generated scene JSON files:
|
| 179 |
-
|
| 180 |
-
```bash
|
| 181 |
-
# Render scenes from a specific run
|
| 182 |
-
python pipeline.py --render_only --run_name experiment1
|
| 183 |
-
|
| 184 |
-
# Auto-detect latest run
|
| 185 |
-
python pipeline.py --render_only --auto_latest
|
| 186 |
-
|
| 187 |
-
# Use GPU rendering
|
| 188 |
-
python pipeline.py --render_only --run_name experiment1 --use_gpu 1
|
| 189 |
-
```
|
| 190 |
-
|
| 191 |
-
This allows you to:
|
| 192 |
-
- Generate scenes on one machine, render on another
|
| 193 |
-
- Generate many scenes, then render them in batches
|
| 194 |
-
- Re-render scenes with different settings (GPU/CPU, samples, resolution) without regenerating
|
| 195 |
-
|
| 196 |
-
### 5. Generating Scenes and Images (Full Options)
|
| 197 |
-
|
| 198 |
-
#### Arguments
|
| 199 |
-
|
| 200 |
-
| Argument | Default | Description |
|
| 201 |
-
| ------------------------- | ------------- | ---------------------------------------------------------------------------- |
|
| 202 |
-
| `--num_scenes` | 5 | Number of scene sets to generate |
|
| 203 |
-
| `--num_objects` | None | Fixed number of objects per scene (overrides min/max) |
|
| 204 |
-
| `--min_objects` | 3 | Minimum object count (if `num_objects` not given) |
|
| 205 |
-
| `--max_objects` | 7 | Maximum object count (if `num_objects` not given) |
|
| 206 |
-
| `--num_counterfactuals` | 2 | Number of counterfactual variants per scene |
|
| 207 |
-
| `--blender_path` | auto-detected | Path to Blender executable |
|
| 208 |
-
| `--output_dir` | `output` | Base directory for all runs (each run gets a timestamped/named subfolder) |
|
| 209 |
-
| `--run_name` | None | Optional custom name for this run (creates `output/run_name/`) |
|
| 210 |
-
| `--use_gpu` | 0 | 1 = enable GPU rendering, 0 = CPU rendering |
|
| 211 |
-
| `--samples` | 512 | Cycles sampling rate (higher = better quality, slower) |
|
| 212 |
-
| `--width` | 320 | Image width in pixels |
|
| 213 |
-
| `--height` | 240 | Image height in pixels |
|
| 214 |
-
| `--skip_render` | False | Generate scenes only (JSON only, no PNG rendering) |
|
| 215 |
-
| `--render_only` | False | Only render existing scene JSON files. Requires --run_dir, --run_name, or --auto_latest |
|
| 216 |
-
| `--run_dir` | None | Run directory containing scenes/ folder (for --render_only mode) |
|
| 217 |
-
| `--auto_latest` | False | Automatically use the latest run in output_dir (for --render_only mode) |
|
| 218 |
-
| `--resume` | False | Resume from where it stopped in an existing run |
|
| 219 |
-
| `--cf_types` | None | Explicitly choose which counterfactual types are used (order is respected; cycles if needed) |
|
| 220 |
-
| `--same_cf_type` | False | Use the same counterfactual type for all variants (first in `--cf_types`, or one random if unset) |
|
| 221 |
-
| `--list_cf_types` | False | Print available counterfactual types and exit |
|
| 222 |
-
| `--min_cf_change_score` | 1.0 | Minimum heuristic change score (retries CF until it’s “noticeable” enough) |
|
| 223 |
-
| `--max_cf_attempts` | 10 | Max retries per counterfactual to reach `--min_cf_change_score` |
|
| 224 |
-
|
| 225 |
-
#### Examples
|
| 226 |
-
|
| 227 |
-
```bash
|
| 228 |
-
# Generate 10 scene sets with 5 objects each
|
| 229 |
-
python3 pipeline.py --num_scenes 10 --num_objects 5 --run_name experiment1
|
| 230 |
-
|
| 231 |
-
# Generate 10 scene sets with 3-7 objects, using GPU
|
| 232 |
-
python3 pipeline.py --num_scenes 10 --min_objects 3 --max_objects 7 --use_gpu 1
|
| 233 |
-
|
| 234 |
-
# Resume from where it stopped
|
| 235 |
-
python3 pipeline.py --num_scenes 100 --run_name experiment1 --resume
|
| 236 |
-
|
| 237 |
-
# Generate scenes only (no rendering)
|
| 238 |
-
python3 pipeline.py --num_scenes 10 --skip_render
|
| 239 |
-
|
| 240 |
-
# List available counterfactual types
|
| 241 |
-
python3 pipeline.py --list_cf_types
|
| 242 |
-
|
| 243 |
-
# Force specific counterfactual types in order (CF1 then CF2)
|
| 244 |
-
python3 pipeline.py --num_scenes 10 --num_counterfactuals 2 --cf_types change_color add_noise
|
| 245 |
-
# All counterfactuals same type (e.g. both change_color):
|
| 246 |
-
python3 pipeline.py --num_scenes 10 --num_counterfactuals 2 --cf_types change_color --same_cf_type
|
| 247 |
-
|
| 248 |
-
# Make counterfactuals more noticeable (stricter threshold + more retries)
|
| 249 |
-
python3 pipeline.py --num_scenes 10 --min_cf_change_score 1.5 --max_cf_attempts 25
|
| 250 |
-
```
|
| 251 |
-
|
| 252 |
-
#### Counterfactual Types
|
| 253 |
-
|
| 254 |
-
The pipeline supports 17 different counterfactual types, divided into two categories:
|
| 255 |
-
|
| 256 |
-
**Image Counterfactuals** (Should change VQA answers - 10 types):
|
| 257 |
-
- `change_color` - Change the color of a random object (e.g., red → blue)
|
| 258 |
-
- `change_shape` - Change the shape of a random object (cube/sphere/cylinder)
|
| 259 |
-
- `change_size` - Change the size of a random object (small ↔ large)
|
| 260 |
-
- `change_material` - Change the material of a random object (metal ↔ rubber)
|
| 261 |
-
- `change_position` - Move a random object to a different location (with collision detection)
|
| 262 |
-
- `add_object` - Add a new random object to the scene
|
| 263 |
-
- `remove_object` - Remove a random object from the scene
|
| 264 |
-
- `replace_object` - Replace an object with a different one (keeping position)
|
| 265 |
-
- `swap_attribute` - Swap an attribute (e.g. color) between two objects
|
| 266 |
-
- `relational_flip` - Move object from left of X to right of X
|
| 267 |
-
|
| 268 |
-
**Negative Counterfactuals** (Should NOT change VQA answers - 8 types):
|
| 269 |
-
- `change_background` - Change the background/ground color
|
| 270 |
-
- `change_lighting` - Change lighting conditions (bright/dim/warm/cool/dramatic)
|
| 271 |
-
- `add_noise` - Add image noise/grain (light/medium/heavy levels)
|
| 272 |
-
- `occlusion_change` - Move object to partially hide another (visual only; answers unchanged)
|
| 273 |
-
- `apply_fisheye` - Apply fisheye lens distortion effect
|
| 274 |
-
- `apply_blur` - Apply Gaussian blur filter
|
| 275 |
-
- `apply_vignette` - Apply vignette effect (edge darkening)
|
| 276 |
-
- `apply_chromatic_aberration` - Apply chromatic aberration (color fringing)
|
| 277 |
-
|
| 278 |
-
**Default Behavior**: If `--cf_types` is not specified, the pipeline uses a default mix of 1 image counterfactual + 1 negative counterfactual per scene.
|
| 279 |
-
|
| 280 |
-
**Usage Examples**:
|
| 281 |
-
```bash
|
| 282 |
-
# List all available counterfactual types
|
| 283 |
-
python3 pipeline.py --list_cf_types
|
| 284 |
-
|
| 285 |
-
# Use specific counterfactual types (order is respected; cycles if needed)
|
| 286 |
-
python3 pipeline.py --num_scenes 10 --num_counterfactuals 2 --cf_types change_color change_position
|
| 287 |
-
|
| 288 |
-
# Mix image and negative counterfactuals
|
| 289 |
-
python3 pipeline.py --num_scenes 10 --cf_types change_shape change_lighting add_noise
|
| 290 |
-
|
| 291 |
-
# Use only negative counterfactuals
|
| 292 |
-
python3 pipeline.py --num_scenes 10 --cf_types change_background add_noise apply_blur
|
| 293 |
-
|
| 294 |
-
# Use only image counterfactuals
|
| 295 |
-
python3 pipeline.py --num_scenes 10 --cf_types change_color change_shape change_position
|
| 296 |
-
```
|
| 297 |
-
|
| 298 |
-
### 2. Generating Example Counterfactuals
|
| 299 |
-
|
| 300 |
-
Generate examples of all counterfactual types applied to a base scene:
|
| 301 |
-
|
| 302 |
-
```bash
|
| 303 |
-
# Generate scene JSON files only
|
| 304 |
-
python scripts/generate_examples.py
|
| 305 |
-
|
| 306 |
-
# Generate and render to images
|
| 307 |
-
python scripts/generate_examples.py --render
|
| 308 |
-
|
| 309 |
-
# Customize output directory and number of objects
|
| 310 |
-
python scripts/generate_examples.py --render --output_dir output/my_examples --num_objects 7
|
| 311 |
-
|
| 312 |
-
# Use GPU rendering
|
| 313 |
-
python scripts/generate_examples.py --render --use_gpu 1
|
| 314 |
-
```
|
| 315 |
-
|
| 316 |
-
This creates one example of each counterfactual type in `output/counterfactual_examples/`:
|
| 317 |
-
- Original scene
|
| 318 |
-
- 9 image counterfactual examples
|
| 319 |
-
- 8 negative counterfactual examples
|
| 320 |
-
|
| 321 |
-
### 3. Generating Question Mappings
|
| 322 |
-
|
| 323 |
-
Use `scripts/generate_questions_mapping.py` to create a CSV with counterfactual questions and answers.
|
| 324 |
-
|
| 325 |
-
#### Arguments
|
| 326 |
-
|
| 327 |
-
| Argument | Default | Description |
|
| 328 |
-
| ---------------------- | ---------------------------------- | -------------------------------------------------------------------------------- |
|
| 329 |
-
| `--output_dir` | `output` | Run directory or base output directory |
|
| 330 |
-
| `--auto_latest` | False | Automatically find and use the latest run in `output_dir` |
|
| 331 |
-
| `--csv_name` | `image_mapping_with_questions.csv` | Name of the generated CSV file |
|
| 332 |
-
| `--generate_questions` | False | Generate questions and answers (without this flag, only outputs image filenames) |
|
| 333 |
-
| `--long_format` | False | Also output a long-format QA dataset CSV (one row per image-question pair) |
|
| 334 |
-
| `--long_csv_name` | `qa_dataset.csv` | Filename for the long-format QA dataset CSV |
|
| 335 |
-
|
| 336 |
-
#### Examples
|
| 337 |
-
|
| 338 |
-
```bash
|
| 339 |
-
# Generate questions for a specific run
|
| 340 |
-
python scripts/generate_questions_mapping.py --output_dir output/experiment1 --generate_questions
|
| 341 |
-
|
| 342 |
-
# Auto-detect latest run and generate questions
|
| 343 |
-
python scripts/generate_questions_mapping.py --output_dir output --auto_latest --generate_questions
|
| 344 |
-
|
| 345 |
-
# Also generate a long-format QA dataset (includes correct answer labels/ids)
|
| 346 |
-
python scripts/generate_questions_mapping.py --output_dir output --auto_latest --generate_questions --long_format --long_csv_name qa_dataset.csv
|
| 347 |
-
```
|
| 348 |
-
|
| 349 |
-
#### Ensuring counterfactual answers differ
|
| 350 |
-
|
| 351 |
-
For evaluation and datasets, the **counterfactual image’s answer to its counterfactual question** should differ from the **original image’s answer to the original question**. The pipeline does this in two ways:
|
| 352 |
-
|
| 353 |
-
1. **Automatic retries**
|
| 354 |
-
When generating questions (with `--generate_questions`), the script retries up to **`MAX_CF_ANSWER_RETRIES`** (default 50) per scene. For each attempt it picks new counterfactual questions (with different randomness). It keeps a pair only when both CF1 and CF2 answers differ from the original answer (after normalizing, e.g. case and whitespace). If after all retries they still match, the scene is still included and a warning is printed.
|
| 355 |
-
|
| 356 |
-
2. **CF-specific question templates**
|
| 357 |
-
Counterfactual questions are chosen from templates that target the **changed** attribute or count, so the answer on the counterfactual image is different by design:
|
| 358 |
-
- **Count-changing CFs** (e.g. `add_object`, `remove_object`): questions like “How many objects are in the scene?” or “Are there more than N objects?” so the count/yes-no differs.
|
| 359 |
-
- **Attribute-changing CFs** (e.g. `change_color`, `change_shape`): questions about the **new** value (e.g. “How many red objects?” when an object was changed to red), so the count on the CF image differs from the original.
|
| 360 |
-
|
| 361 |
-
**What you need to do:**
|
| 362 |
-
|
| 363 |
-
- Run question generation **after** scenes and images exist (either as part of the pipeline with `--generate_questions`, or later on a run directory):
|
| 364 |
-
|
| 365 |
-
```bash
|
| 366 |
-
# As part of a full run (ensures answers differ for that run’s scenes)
|
| 367 |
-
python pipeline.py --num_scenes 10 --num_objects 5 --run_name my_run --generate_questions
|
| 368 |
-
|
| 369 |
-
# Or later, on an existing run
|
| 370 |
-
python scripts/generate_questions_mapping.py --output_dir output/my_run --generate_questions
|
| 371 |
-
```
|
| 372 |
-
|
| 373 |
-
- **Optional:** To allow more attempts per scene, edit `scripts/generate_questions_mapping.py` and increase **`MAX_CF_ANSWER_RETRIES`** (e.g. from 50 to 100). No CLI flag is exposed for this.
|
| 374 |
-
|
| 375 |
-
**720p dataset with different answers (distinct CF types per scene):**
|
| 376 |
-
|
| 377 |
-
- Scenes use **two distinct counterfactual types** per scene (no duplicate CF type for CF1 and CF2). To generate a 720p (1280×720) set with question/answer validation and optional removal of scenes where the CF answer matches the original:
|
| 378 |
-
|
| 379 |
-
```bash
|
| 380 |
-
python pipeline.py --num_scenes 1000 --output_dir output --run_name dataset_720p_diff --width 1280 --height 720 --semantic_only --num_counterfactuals 2 --generate_questions --filter_same_answer
|
| 381 |
-
```
|
| 382 |
-
|
| 383 |
-
- This produces `output/dataset_720p_diff/` with scene sets where CF1 and CF2 use different types, questions are validated (original + CFs), and rows where the CF image’s answer to the CF question matches the original are removed. Increase `MAX_CF_ANSWER_RETRIES` in `scripts/generate_questions_mapping.py` if you want fewer “could not find valid questions” warnings.
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
## Project Structure
|
| 387 |
-
|
| 388 |
-
```
|
| 389 |
-
.
|
| 390 |
-
├── pipeline.py # Main pipeline and rendering (supports --render_only)
|
| 391 |
-
├── app.py # Streamlit web interface
|
| 392 |
-
├── requirements.txt # Python dependencies
|
| 393 |
-
├── data/ # Scene assets
|
| 394 |
-
│ ├── base_scene.blend # Base Blender scene
|
| 395 |
-
│ ├── CoGenT_A.json # Scene configuration A
|
| 396 |
-
│ ├── CoGenT_B.json # Scene configuration B
|
| 397 |
-
│ ├── properties.json # Object properties configuration
|
| 398 |
-
│ ├── materials/ # Material definitions
|
| 399 |
-
│ └── shapes/ # 3D shape definitions
|
| 400 |
-
├── scripts/ # Scripts directory
|
| 401 |
-
│ ├── render.py # Blender rendering script (run by pipeline)
|
| 402 |
-
│ ├── generate_scenes.py # Generate scene JSON files only (alternative to --skip_render)
|
| 403 |
-
│ ├── generate_examples.py # Generate example counterfactuals
|
| 404 |
-
│ └── generate_questions_mapping.py # Generate question-answer datasets
|
| 405 |
-
├── output/ # Output directory (generated)
|
| 406 |
-
│ └── counterfactual_examples/ # Example counterfactuals (from generate_examples.py)
|
| 407 |
-
├── .gitignore # Git ignore rules
|
| 408 |
-
└── README.md # This file
|
| 409 |
-
|
| 410 |
-
**Note**: The pipeline dynamically generates temporary files during execution:
|
| 411 |
-
- `render_images_patched.py` - Patched rendering script
|
| 412 |
-
- `temp_output/<run_id>/` - Temporary output per run (e.g. `temp_output/2025-01-29_12-30-45/images` and `.../scenes`), so different runs use separate directories and do not overwrite each other.
|
| 413 |
-
|
| 414 |
-
These files are automatically created when needed, cleaned up after use, and are ignored by git.
|
| 415 |
-
```
|
| 416 |
-
|
| 417 |
-
## Output Structure
|
| 418 |
-
|
| 419 |
-
Each run creates a directory structure like:
|
| 420 |
-
|
| 421 |
-
```
|
| 422 |
-
output/
|
| 423 |
-
└── <run_name_or_timestamp>/
|
| 424 |
-
├── checkpoint.json
|
| 425 |
-
├── run_metadata.json
|
| 426 |
-
├── scenes/
|
| 427 |
-
│ ├── scene_0000_original.json
|
| 428 |
-
│ ├── scene_0000_cf1.json
|
| 429 |
-
│ ├── scene_0000_cf2.json
|
| 430 |
-
│ └── ...
|
| 431 |
-
├── images/
|
| 432 |
-
│ ├── scene_0000_original.png
|
| 433 |
-
│ ├── scene_0000_cf1.png
|
| 434 |
-
│ ├── scene_0000_cf2.png
|
| 435 |
-
│ └── ...
|
| 436 |
-
├── image_mapping_with_questions*.csv
|
| 437 |
-
└── qa_dataset*.csv (if generated with --long_format)
|
| 438 |
-
```
|
| 439 |
-
|
| 440 |
-
### Dataset columns (high level)
|
| 441 |
-
|
| 442 |
-
**Wide Format CSV** (default with `--generate_questions`):
|
| 443 |
-
- **Image columns**: `original_image`, `semantic_counterfactual_image`, `negative_counterfactual_image`
|
| 444 |
-
- **Question columns**: `original_question`, `semantic_counterfactual_question_1`, `negative_counterfactual_question_1`
|
| 445 |
-
- **Answer matrix columns** (9 total, showing each image's answer to each question):
|
| 446 |
-
- `original_image_answer_to_original_question`
|
| 447 |
-
- `original_image_answer_to_semantic_counterfactual_question_1`
|
| 448 |
-
- `original_image_answer_to_negative_counterfactual_question_1`
|
| 449 |
-
- `semantic_counterfactual_image_answer_to_original_question`
|
| 450 |
-
- `semantic_counterfactual_image_answer_to_semantic_counterfactual_question_1`
|
| 451 |
-
- `semantic_counterfactual_image_answer_to_negative_counterfactual_question_1`
|
| 452 |
-
- `negative_counterfactual_image_answer_to_original_question`
|
| 453 |
-
- `negative_counterfactual_image_answer_to_semantic_counterfactual_question_1`
|
| 454 |
-
- `negative_counterfactual_image_answer_to_negative_counterfactual_question_1`
|
| 455 |
-
|
| 456 |
-
**Basic Format CSV** (without `--generate_questions`):
|
| 457 |
-
- Only image columns: `original_image`, `semantic_counterfactual_image`, `negative_counterfactual_image`
|
| 458 |
-
|
| 459 |
-
## Data Curation Note
|
| 460 |
-
|
| 461 |
-
For reporting-ready experiments, use the curated subset:
|
| 462 |
-
|
| 463 |
-
- `output/dataset_720p_v2_clean800`
|
| 464 |
-
- `800` scene triplets (`original`, `cf1`, `cf2`) with matching `images/`, `scenes/`, and `image_mapping_with_questions.csv`
|
| 465 |
-
- Deterministic selection rule: keep valid, non-backfilled scene IDs in ascending order until 800 are collected
|
| 466 |
-
|
| 467 |
-
The subset excludes IDs that were previously backfilled during intermediate dataset assembly. Final experiments and metrics should be run on this curated subset for clean provenance and reproducibility.
|
| 468 |
-
|
| 469 |
-
## Code Style
|
| 470 |
-
|
| 471 |
-
The codebase follows a clean, consistent style:
|
| 472 |
-
- No multiline docstrings (removed for brevity)
|
| 473 |
-
- Consistent spacing and formatting
|
| 474 |
-
- Single blank lines between functions
|
| 475 |
-
- Clear, concise function names
|
| 476 |
-
|
| 477 |
-
## License
|
| 478 |
-
|
| 479 |
-
MIT License
|
| 480 |
-
|
| 481 |
-
## Contributing
|
| 482 |
-
|
| 483 |
-
Contributions are welcome! Please ensure:
|
| 484 |
-
- Code follows the existing style (no multiline docstrings, consistent spacing)
|
| 485 |
-
- All tests pass
|
| 486 |
-
- Documentation is updated as needed
|
| 487 |
-
|
| 488 |
-
## Acknowledgments
|
| 489 |
-
|
| 490 |
-
This project is inspired by the CLEVR dataset and uses Blender for 3D scene rendering.
|
| 491 |
-
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
pretty_name: MMIB Counterfactual VQA Dataset
|
| 4 |
+
task_categories:
|
| 5 |
+
- visual-question-answering
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- vision
|
| 10 |
+
- language
|
| 11 |
+
- multimodal
|
| 12 |
+
- counterfactual
|
| 13 |
+
- mechanistic-interpretability
|
| 14 |
+
- synthetic
|
| 15 |
+
- clevr
|
| 16 |
+
size_categories:
|
| 17 |
+
- n<1K
|
| 18 |
+
paperswithcode_id:
|
| 19 |
+
configs:
|
| 20 |
+
- config_name: default
|
| 21 |
+
data_files:
|
| 22 |
+
- split: train
|
| 23 |
+
path: data/train-*
|
| 24 |
+
dataset_info:
|
| 25 |
+
features:
|
| 26 |
+
- name: original_image
|
| 27 |
+
dtype: image
|
| 28 |
+
- name: semantic_counterfactual_image
|
| 29 |
+
dtype: image
|
| 30 |
+
- name: negative_counterfactual_image
|
| 31 |
+
dtype: image
|
| 32 |
+
- name: semantic_counterfactual_type
|
| 33 |
+
dtype: string
|
| 34 |
+
- name: negative_counterfactual_type
|
| 35 |
+
dtype: string
|
| 36 |
+
- name: semantic_counterfactual_description
|
| 37 |
+
dtype: string
|
| 38 |
+
- name: negative_counterfactual_description
|
| 39 |
+
dtype: string
|
| 40 |
+
- name: original_question
|
| 41 |
+
dtype: string
|
| 42 |
+
- name: semantic_counterfactual_question_1
|
| 43 |
+
dtype: string
|
| 44 |
+
- name: negative_counterfactual_question_1
|
| 45 |
+
dtype: string
|
| 46 |
+
- name: original_question_answer_type
|
| 47 |
+
dtype: string
|
| 48 |
+
- name: semantic_counterfactual_question_1_answer_type
|
| 49 |
+
dtype: string
|
| 50 |
+
- name: negative_counterfactual_question_1_answer_type
|
| 51 |
+
dtype: string
|
| 52 |
+
- name: original_question_reasoning_op
|
| 53 |
+
dtype: string
|
| 54 |
+
- name: semantic_counterfactual_question_1_reasoning_op
|
| 55 |
+
dtype: string
|
| 56 |
+
- name: negative_counterfactual_question_1_reasoning_op
|
| 57 |
+
dtype: string
|
| 58 |
+
- name: original_image_answer_to_original_question
|
| 59 |
+
dtype: string
|
| 60 |
+
- name: original_image_answer_to_semantic_counterfactual_question_1
|
| 61 |
+
dtype: string
|
| 62 |
+
- name: original_image_answer_to_negative_counterfactual_question_1
|
| 63 |
+
dtype: string
|
| 64 |
+
- name: semantic_counterfactual_image_answer_to_original_question
|
| 65 |
+
dtype: string
|
| 66 |
+
- name: semantic_counterfactual_image_answer_to_semantic_counterfactual_question_1
|
| 67 |
+
dtype: string
|
| 68 |
+
- name: semantic_counterfactual_image_answer_to_negative_counterfactual_question_1
|
| 69 |
+
dtype: string
|
| 70 |
+
- name: negative_counterfactual_image_answer_to_original_question
|
| 71 |
+
dtype: string
|
| 72 |
+
- name: negative_counterfactual_image_answer_to_semantic_counterfactual_question_1
|
| 73 |
+
dtype: string
|
| 74 |
+
- name: negative_counterfactual_image_answer_to_negative_counterfactual_question_1
|
| 75 |
+
dtype: string
|
| 76 |
+
splits:
|
| 77 |
+
- name: train
|
| 78 |
+
num_bytes: 38600000
|
| 79 |
+
num_examples: 100
|
| 80 |
+
download_size: 38600000
|
| 81 |
+
dataset_size: 38600000
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
# MMIB Counterfactual VQA Dataset
|
| 85 |
+
|
| 86 |
+
Authors: **Oyedeji Sonuga**.
|
| 87 |
+
|
| 88 |
+
Synthetic CLEVR-style scenes for the Multimodal Mechanistic Interpretability Benchmark (MMIB), presented as a poster at the Sci-FM workshop, COLM 2026. Each row is a **triplet**: an original scene, a semantic counterfactual (the answer should change), and a perturbation (the answer should hold), plus three questions and the full 3×3 answer matrix.
|
| 89 |
+
|
| 90 |
+
Images are **320×320** PNG renders (confirmed on all 300 files in this revision).
|
| 91 |
+
|
| 92 |
+
## Revisions
|
| 93 |
+
|
| 94 |
+
| Tag | What it is |
|
| 95 |
+
| --- | --- |
|
| 96 |
+
| `v1.0` | The 100-triplet set used in the paper / poster. Same rows as [`AnonymousECCV15285/MMIB_Counterfactual_image_Dataset`](https://huggingface.co/datasets/AnonymousECCV15285/MMIB_Counterfactual_image_Dataset). Column names use `counterfactual1_` / `counterfactual2_`. |
|
| 97 |
+
| `v1.1` (this revision, `main`) | Regenerated 100 triplets with flip/hold validation and answer-balance quotas. Column names use `semantic_counterfactual_` / `negative_counterfactual_`, and include `*_answer_type` and `*_reasoning_op`. |
|
| 98 |
+
|
| 99 |
+
Load a pinned revision:
|
| 100 |
+
|
| 101 |
+
```python
|
| 102 |
+
from datasets import load_dataset
|
| 103 |
+
|
| 104 |
+
paper = load_dataset("scholo/MMB_dataset", split="train", revision="v1.0")
|
| 105 |
+
v11 = load_dataset("scholo/MMB_dataset", split="train", revision="v1.1")
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## What v1.1 changed
|
| 109 |
+
|
| 110 |
+
- Flip/hold precheck: a triplet is kept only if the semantic edit flips the designed question and the perturbation holds.
|
| 111 |
+
- Absent yes/no existence questions are paired with an introducing edit (`add_object`, `change_color`, `replace_object`).
|
| 112 |
+
- Acceptance quotas: original yes/no answers near 50%; any single count value at most 25% of count rows.
|
| 113 |
+
- 100% same-question flip on this split is by construction (failed candidates are discarded), not a measured gain over v1.0.
|
| 114 |
+
|
| 115 |
+
## Loading
|
| 116 |
+
|
| 117 |
+
```python
|
| 118 |
+
from datasets import load_dataset
|
| 119 |
+
|
| 120 |
+
ds = load_dataset("scholo/MMB_dataset", split="train")
|
| 121 |
+
print(ds[0]["original_question"])
|
| 122 |
+
print(ds[0]["original_image_answer_to_original_question"])
|
| 123 |
+
print(ds[0]["semantic_counterfactual_image_answer_to_original_question"])
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
No `trust_remote_code=True` is required.
|
| 127 |
+
|
| 128 |
+
## Columns
|
| 129 |
+
|
| 130 |
+
Each row has three images (`original_image`, `semantic_counterfactual_image`, `negative_counterfactual_image`), three questions, answer types, reasoning-op tags, and nine answers (every image × every question).
|
| 131 |
+
|
| 132 |
+
## License
|
| 133 |
+
|
| 134 |
+
MIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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