File size: 6,950 Bytes
e27853f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a29261
 
 
 
e27853f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00a9e70
e27853f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
---
language:
- en
license: cc-by-4.0
pretty_name: BlenderBench
tags:
- 3d
- blender
- code-generation
- vision
- multimodal
- benchmark
dataset_info:
  features:
  - name: instance_id
    dtype: string
  - name: task_description
    dtype: string
  - name: start_render
    dtype: image
  - name: goal_render
    dtype: image
  - name: start_code
    dtype: string
  - name: goal_code
    dtype: string
  - name: blend_file_path
    dtype: string
  - name: blend_file_size_mb
    dtype: float64
  splits:
  - name: train
    num_bytes: 18000000000
    num_examples: 27
  download_size: 18000000000
  dataset_size: 18000000000
---

# BlenderBench Dataset

<p align="center">
    <a href="https://fugtemypt123.github.io/VIGA-website/"><img src="https://img.shields.io/badge/Page-Project-blue" alt="Project Page"></a>
    <a href="https://arxiv.org/abs/2601.11109"><img src="https://img.shields.io/badge/Paper-arXiv-b31b1b" alt="arXiv Paper"></a>
    <a href="https://github.com/Fugtemypt123/VIGA"><img src="https://img.shields.io/badge/Code-Github-black" alt="Github Code"></a>
</p>

## Dataset Description

**BlenderBench** is a comprehensive benchmark dataset for evaluating models on 3D scene editing tasks in Blender. The dataset challenges agents to understand visual differences between initial and target scenes, then generate appropriate Blender Python code to transform the initial scene to match the target.

### Key Features

- **27 instances** across 3 difficulty levels
- **Multi-modal**: Combines visual understanding with code generation
- **Realistic 3D scenes**: Using Blender Studio assets
- **Progressive difficulty**: From simple camera adjustments to complex scene manipulations
- **Rich annotations**: Each instance includes task descriptions, start/goal code, and rendered images

### Task Categories

The dataset covers three main difficulty levels:

1. **Level 1** (9 instances): Camera adjustments
2. **Level 2** (9 instances): Multi-step editing
3. **Level 3** (9 instances): Compositional editing (level 1 + level 2)

## Dataset Structure

Each instance in the dataset contains:

```
instance/
├── blender_file.blend       # Blender scene file
├── start.py                  # Initial scene configuration code
├── goal.py                   # Target scene configuration code
├── task.txt                  # Natural language task description
└── renders/
    ├── start/
    │   └── render1.png      # Rendered image of initial scene (512x512)
    └── goal/
        └── render1.png      # Rendered image of target scene (512x512)
```

### Data Fields

When loaded using `datasets.load_dataset()`, each example contains:

- `instance_id` (string): Unique identifier (e.g., "level1/camera1")
- `level` (string): Difficulty level ("level1", "level2", or "level3")
- `instance_name` (string): Instance name within the level
- `task_description` (string): Natural language description of the task
- `start_code` (string): Python code for the initial scene setup
- `goal_code` (string): Python code for the target scene configuration
- `start_render` (image): Rendered image of the initial scene (512x512 PNG)
- `goal_render` (image): Rendered image of the target scene (512x512 PNG)
- `blend_file_path` (string): Relative path to the .blend file
- `blend_file_size_mb` (float): Size of the .blend file in MB

### Data Splits

The dataset provides a single training split containing all instances. You can filter by difficulty level using the dataset configurations:

- `all`: All instances (default)
- `level1`: Only level 1 instances
- `level2`: Only level 2 instances
- `level3`: Only level 3 instances


## Usage

### Installation

```bash
pip install datasets huggingface_hub
```

### Loading the Dataset

```python
from datasets import load_dataset

# Load all instances
dataset = load_dataset("DietCoke4671/BlenderBench")

# Load only level 1 instances
dataset = load_dataset("DietCoke4671/BlenderBench", "level1")

# Access an example
example = dataset["train"][0]
print(f"Task: {example['task_description']}")
print(f"Level: {example['level']}")

# Display images
example['start_render'].show()  # Initial scene
example['goal_render'].show()   # Target scene

# Access code
print(f"Start code:\n{example['start_code']}")
print(f"Goal code:\n{example['goal_code']}")
```

### Using with Blender

To actually render and evaluate generated code, you'll need Blender installed:

```python
import subprocess
from pathlib import Path

def render_with_blender(blend_file, code, output_dir):
    """
    Execute Blender code and render the result.

    Args:
        blend_file: Path to .blend file
        code: Python code to execute in Blender
        output_dir: Directory to save rendered output
    """
    # Save code to temporary file
    code_file = Path(output_dir) / "temp_code.py"
    with open(code_file, 'w') as f:
        f.write(code)

    # Run Blender
    cmd = [
        "blender",
        "--background",
        str(blend_file),
        "--python", str(code_file),
        "--render-output", str(output_dir / "render.png"),
        "--render-frame", "1"
    ]

    subprocess.run(cmd)

# Example usage
example = dataset["train"][0]
render_with_blender(
    blend_file=f"path/to/{example['blend_file_path']}",
    code=example['start_code'],
    output_dir="output/"
)
```

### Example: Building an AI Agent

```python
from datasets import load_dataset
import openai

# Load dataset
dataset = load_dataset("DietCoke4671/BlenderBench", "level1")

def solve_blender_task(example):
    """
    Use an AI agent to solve a BlenderBench task.
    """
    # Prepare prompt with task description and images
    prompt = f"""
You are an expert Blender Python programmer. Your task is to:

Task: {example['task_description']}

Given the initial scene code and rendered image, generate Blender Python code
to transform the scene to match the target image.

Initial code:
{example['start_code']}

Generate the modified code that will produce the target scene.
"""

    # Call your AI model (e.g., GPT-4 with vision)
    response = openai.ChatCompletion.create(
        model="gpt-4-vision-preview",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": prompt},
                    {
                        "type": "image_url",
                        "image_url": {"url": encode_image(example['start_render'])}
                    },
                    {
                        "type": "image_url",
                        "image_url": {"url": encode_image(example['goal_render'])}
                    }
                ]
            }
        ]
    )

    return response.choices[0].message.content

# Solve all level 1 tasks
for example in dataset["train"]:
    solution = solve_blender_task(example)
    print(f"Solution for {example['instance_id']}:")
    print(solution)
```