--- id: SPA_task_0_blender_room_arrange name: Blender 室内 3D 摆放小场景 category: SPA timeout_seconds: 1800 --- ## Prompt > ⚙️ **Execution convention**: this task is graded purely on the deliverable files — **there is no human approver**. Just execute, produce the files, and don't write "if you would like me to..." style questions or wait for approval. All deliverables must land in the **`/tmp_workspace/` root directory**, and once finished, run `ls -la /tmp_workspace/` as a self-check before exiting. Background: under `/tmp_workspace/assets/` there are 6 `.blend` furniture assets (sofa / coffee table / TV stand / dining table / chairs ×2 / nightstand). Note that `assets/floor_lamp.blend` is a legacy name — **the internal object is actually `ClassicNightstand_01` (a nightstand)**. Place it according to "nightstand" semantics; keep the filename unchanged. Goal: build a 30 m² rectangular living room (approximately 5 m × 6 m × 2.8 m, with 4 walls + floor + ceiling), arrange the 6 pieces of furniture per the home-layout common sense below, add basic lighting and a camera, render the scene, and produce the primary deliverable `room.blend` plus the supporting deliverables. The implementation method is up to you (Blender GUI / `bpy` script / headless `blender -b -P` are all fine); only the final deliverable fields are graded. Placement rules: - Sofa against the north wall, ~100 mm clearance from the wall; - TV stand against the south wall, centered horizontally; - Coffee table sits between the sofa and the TV stand, centered; - Dining table against the east wall with ~800 mm clearance, with the two chairs on either side of it; - Nightstand (from `floor_lamp.blend`) in the corner at the right end of the sofa, flush against the sofa's short side as a side table. ### Hard constraints on the primary deliverable `room.blend` - The filename must be exactly `room.blend` (not `room_scene.blend` or similar). - Must contain at least 6 MESH objects whose names can be recognized as synonyms of the following 6 furniture categories: sofa / coffee(table) / tv(stand or console) / dining(table) / chair / nightstand (bedside / sidetable / lamp and similar synonyms are accepted). - The xy bounding boxes of the 6 pieces must pairwise not overlap (no clipping); the overall overlap-compliance rate must be ≥ 0.85. - Placement orientation and wall clearances must conform to the rules above (tolerance ~ ±50–100 mm). - At least 1 piece of furniture must have `distance_to_nearest_wall_mm` within `[0, 200]` (i.e., genuinely flush against a wall). ### Supporting deliverables (under `/tmp_workspace/` root) | File | Requirement | |---|---| | `render.png` | Perspective render, resolution strictly **1920×1080**, with real materials and shadows (grayscale std > 35), file size ≥ 30 KB | | `top_view.png` | Top-down view screenshot, resolution ≥ **1280×720**, file size ≥ 15 KB; md5 must differ from `render.png` (prevents renaming the same image) | | `layout.csv` | ≥ 6 rows; header must be `object,x,y,z,rotation_z,distance_to_nearest_wall_mm`; the 6 object names must all be distinct | Overall, the scene should visibly demonstrate: a complete room, no furniture clipping, ≥ 3 large pieces against walls, a walkable aisle through the center, and normal lighting (not all-black / not over-exposed). ## Expected Behavior 设计意图与典型解题路径(仅供出题人参考,不发给 agent): 1. 推荐用 Blender 4.0 GUI 操作(也可走 `bpy` 脚本或 headless `blender -b -P`,三种通道判分等价)。 2. 用 Cube/Plane 建 4 面墙 + 地板 + 天花板,内部净尺寸约 5m×6m×2.8m,墙厚向外延伸不要侵占内部空间。 3. File → Append 从 `/tmp_workspace/assets/` 中逐个导入 6 个 `.blend` 的 Object。 4. 在 N 面板按摆放规则输入精确坐标(沙发 y 贴北墙、电视柜 y 贴南墙居中且与茶几共线、餐桌 x 靠东墙、椅子分坐餐桌两侧、床头柜在沙发右端角落)。 5. 添加 1 个 Sun 灯 + 1 个 Area 灯。 6. 设置一个人眼高度 ~1.6m 的对角斜拍相机,切换到 Cycles 或 Eevee,渲染 1920×1080 → `/tmp_workspace/render.png`。 7. 切顶视图(Numpad 7 或正交相机)截图 → `/tmp_workspace/top_view.png`,确保与 render.png 是不同视角的真实图(md5 不同)。 8. 写 `/tmp_workspace/layout.csv`,6 行,表头齐全,至少 1 件家具 `distance_to_nearest_wall_mm` ≤ 200。 9. 保存场景为 `/tmp_workspace/room.blend`,最后 `ls -la /tmp_workspace/` 自检。 约束说明:摆放精度约 ±50mm;`render.png` 与 `top_view.png` 必须是真实不同的图,禁止复制同一张图改名(grader 会比对 md5)。 评分要点(hard gates,从 grader cap 反推): - `room.blend` 不存在 → 上限 0.30; - bbox no-overlap < 0.85 → 上限 0.40; - 摆放规则符合度 < 0.6 → 上限 0.45; - mesh_count 不足 6 → 上限 0.50; - `render.png` 非 1920×1080 或 std 不达标 → 上限 0.45; - `top_view.png` 缺失或分辨率不达标 → 上限 0.50; - 两张截图 md5 相同(同图复用) → 上限 0.45; - `layout.csv` 表头不全或 6 个 object 名不唯一 → 上限 0.50; - VLM 综合评分 < 0.6 → 上限 0.50;< 0.4 → 上限 0.35;VLM 不可用 → 上限 0.60。 ## Source - Reddit: https://www.reddit.com/r/blender/comments/1bxxxxx/can_chatgpt_arrange_blender_scene/ - 原文引用:「ChatGPT can write `bpy` to place cubes, but for actual import-glb-and-arrange in viewport with N-panel precision, it has no spatial sense.」 - 对应 benchmark case: SPA / 新增(C4 Blender 子任务) ## Grading Criteria - [ ] `room.blend` 存在,含 ≥ 6 mesh object 命名匹配 sofa/coffee/tv/dining/chair/nightstand(或 lamp 别名) - [ ] 6 物体的 bounding box 两两 IoU = 0(无穿模),`no_overlap` ≥ 0.85 才不被 cap - [ ] `render.png` 1920×1080,非纯色(std > 35),文件大小 ≥ 30 KB - [ ] `top_view.png` 存在,分辨率 ≥ 1280×720,文件大小 ≥ 15 KB - [ ] `layout.csv` 6 行,列齐全;6 个 object 名两两不同 - [ ] 至少 1 个家具 `distance_to_nearest_wall_mm` 落在 [0, 200] 区间内 - [ ] `render.png` 与 `top_view.png` md5 不相同(防同图复用) ## Automated Checks ```python from pathlib import Path import csv, re, json, subprocess from PIL import Image import numpy as np def grade(workspace_path=None, **kwargs): workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace") """Stricter SPA_5 grader: bounding-box rule conformance against gt/expected.json.""" gt_path = (workspace.parent / "gt" / "expected.json") if not gt_path.exists(): gt_path = Path("/tmp_workspace/gt/expected.json") gt = json.loads(gt_path.read_text()) if gt_path.exists() else {} s = {} bl = workspace/"room.blend" s["blend_exists"] = 1.0 if bl.exists() else 0.0 objs = [] blender_ok = False if bl.exists(): try: sc=subprocess.run(["blender","-b",str(bl),"--python-expr", "import bpy,json;objs=[(o.name,list(o.location),list(o.dimensions),list(o.rotation_euler)) for o in bpy.data.objects if o.type=='MESH'];print('JSON_OUT',json.dumps(objs))"], capture_output=True,timeout=180,text=True) m=re.search(r"JSON_OUT (.+)", sc.stdout) if m: objs=json.loads(m.group(1)); blender_ok = True except Exception as e: s["blender_err"]=str(e)[:80] # Fallback: parse layout.csv if blender CLI not available / parse failed if not objs: lc = workspace/"layout.csv" if lc.exists(): try: import csv as _csv with lc.open() as fh: for row in _csv.DictReader(fh): try: x = float(row.get("x", 0) or 0) y = float(row.get("y", 0) or 0) z = float(row.get("z", 0) or 0) rz = float(row.get("rotation_z", 0) or 0) objs.append((row.get("object","obj"), [x, y, z], [0.5, 0.5, 0.5], # default bbox dims [0, 0, rz])) except Exception: pass except Exception: pass s["mesh_count"] = min(1.0, len(objs)/max(gt.get("min_meshes",6),6)) # keys -> 同义词集合(覆盖 Polyhaven 真实对象名 ClassicConsole / WoodenTable / # ClassicNightstand / ArmChair / WoodenChair 等,以及常见英文别名 couch/desk/stand/light) key_synonyms = { "sofa": ["sofa", "couch", "settee"], "coffee": ["coffee", "coffeetable", "cocktail"], "tv": ["tv", "television", "console", "classicconsole", "tvstand", "stand", "media", "cabinet"], "dining": ["dining", "diningtable", "woodentable", "table"], "chair": ["chair", "armchair", "woodenchair", "stool", "seat"], "nightstand": ["nightstand", "classicnightstand", "bedside", "sidetable", "endtable", "lamp", "light", "floorlamp", "torchiere"], } def _norm(n): return re.sub(r"[^a-z0-9]", "", n.lower()) norm_names = [_norm(n) for n,_,_,_ in objs] if objs else [] name_blob = " ".join(norm_names) matched_keys = set() for k, syns in key_synonyms.items(): if any(s in name_blob for s in syns): matched_keys.add(k) s["furniture_named"] = len(matched_keys)/6 def _obj_key(name): nn = _norm(name) for k, syns in key_synonyms.items(): if any(s in nn for s in syns): return k return None # bbox xy non-overlap boxes=[] for n,loc,dim,_ in objs: if _obj_key(n) is not None: boxes.append((loc[0]-dim[0]/2,loc[1]-dim[1]/2,loc[0]+dim[0]/2,loc[1]+dim[1]/2)) no_overlap = True; pairs=0; ok_pairs=0 for i in range(len(boxes)): for j in range(i+1,len(boxes)): pairs+=1; a,b=boxes[i],boxes[j] if max(a[0],b[0])>=min(a[2],b[2]) or max(a[1],b[1])>=min(a[3],b[3]): ok_pairs+=1 else: no_overlap=False s["no_overlap"] = (ok_pairs/pairs) if pairs else 0.0 # rule conformance vs gt R = gt.get("room_dims_m",{}); tol = gt.get("tolerance_m",0.05) Y = R.get("y",6.0); X = R.get("x",5.0) rule_hits=0; rule_total=0 obj_map = {} for n,loc,dim,_ in objs: k = _obj_key(n) if k is not None: obj_map.setdefault(k, (loc,dim)) for rule in gt.get("rules",[]): rule_total+=1 target = next((k for k in key_synonyms if k in rule.get("object","")), None) if not target or target not in obj_map: continue loc,dim = obj_map[target] if rule.get("wall")=="north": d = abs(Y - (loc[1]+dim[1]/2)) if abs(d - rule.get("distance_m",0))<=tol+0.05: rule_hits+=1 elif rule.get("wall")=="south": d = loc[1]-dim[1]/2 if d<=tol+0.05: rule_hits+=1 elif rule.get("wall")=="east": d = abs(X - (loc[0]+dim[0]/2)) if abs(d - rule.get("distance_m",0))<=tol+0.1: rule_hits+=1 if "x_center_m" in rule and abs(loc[0]-rule["x_center_m"])<=0.2: rule_hits+=0.5 s["rule_conformance"] = min(1.0, rule_hits/max(rule_total,1)) # render & top_view rp=workspace/"render.png" render_md5 = None if rp.exists(): im=Image.open(rp); arr=np.array(im.convert("L")) s["render_size"] = 1.0 if im.size==(1920,1080) else 0.0 s["render_nontrivial"] = 1.0 if arr.std()>35 else max(0.0, (arr.std()-10)/25) try: import hashlib render_md5 = hashlib.md5(rp.read_bytes()).hexdigest() s["render_filesize_ok"] = 1.0 if rp.stat().st_size >= 30*1024 else 0.0 except Exception: s["render_filesize_ok"] = 0.0 else: s["render_size"]=0.0; s["render_nontrivial"]=0.0; s["render_filesize_ok"]=0.0 tv=workspace/"top_view.png" tv_md5 = None if tv.exists(): _tvsz = Image.open(tv).size s["top_view_ok"] = 1.0 if (_tvsz[0]>=1280 and _tvsz[1]>=720) else 0.0 try: import hashlib tv_md5 = hashlib.md5(tv.read_bytes()).hexdigest() s["top_view_filesize_ok"] = 1.0 if tv.stat().st_size >= 15*1024 else 0.0 except Exception: s["top_view_filesize_ok"] = 0.0 else: s["top_view_ok"] = 0.0; s["top_view_filesize_ok"] = 0.0 s["screenshots_distinct"] = 1.0 if (render_md5 and tv_md5 and render_md5 != tv_md5) else 0.0 lc=workspace/"layout.csv" if lc.exists(): rows=list(csv.DictReader(lc.open())) if len(rows)>=6 and all(k in rows[0] for k in ["object","x","y","z","rotation_z","distance_to_nearest_wall_mm"]): s["layout_csv_schema"] = 1.0 try: ok = sum(1 for row in rows if 0<=float(row["distance_to_nearest_wall_mm"])<=200) s["layout_csv_distance"] = 1.0 if ok>=1 else 0.0 except: s["layout_csv_distance"]=0.0 names = [r.get("object","").strip().lower() for r in rows[:6]] s["layout_csv_unique"] = 1.0 if len(set(names))==6 and all(names) else 0.0 else: s["layout_csv_schema"]=0.5 if rows else 0.0; s["layout_csv_distance"]=0.0; s["layout_csv_unique"]=0.0 else: s["layout_csv_schema"]=0.0; s["layout_csv_distance"]=0.0; s["layout_csv_unique"]=0.0 try: from _judge_helper import vlm_score_rubric except Exception: vlm_score_rubric = None imgs = [str(p) for p in [workspace/"render.png", workspace/"top_view.png"] if p.exists()] if vlm_score_rubric and imgs: rubric = { "vlm_room_complete": "渲染图呈现一个完整的室内房间场景,含 ≥6 件家具(沙发/桌椅/柜灯等)", "vlm_no_overlap": "家具之间无明显穿模或重叠,摆放空间合理", "vlm_against_wall": "至少 3 件大件家具贴墙摆放(沙发靠墙、柜靠墙等)", "vlm_walkable_aisle": "中央或主要通道留有可行走的空间,未被家具完全占满", "vlm_lighting_ok": "渲染图光照正常(非全黑、非过曝),材质可辨", } vlm = vlm_score_rubric(imgs[:2], rubric, instruction="评估 Blender 室内家具布置的合理性。第一张为透视渲染,第二张为顶视图(如有)。") for k in rubric: s[k] = vlm.get(k, 0.0) s["judge_method"] = vlm.get("judge_method", "failed") nums=[v for v in s.values() if isinstance(v,(int,float))] flat = sum(nums)/len(nums) if nums else 0.0 # 加权:核心交付 60% / GUI 证据 30% / 辅助 10% core_keys = ["blend_exists","mesh_count","furniture_named","no_overlap","rule_conformance","layout_csv_schema","layout_csv_distance","layout_csv_unique"] gui_keys = ["render_size","render_nontrivial","render_filesize_ok","top_view_ok","top_view_filesize_ok","screenshots_distinct"] aux_keys = [k for k in s if k.startswith("vlm_")] def _avg(keys): vals = [s[k] for k in keys if k in s and isinstance(s[k],(int,float))] return sum(vals)/len(vals) if vals else 0.0 core = _avg(core_keys); gui = _avg(gui_keys); aux = _avg(aux_keys) if aux_keys else flat base = 0.6*core + 0.3*gui + 0.1*aux # 多层 hard gate(均上调) if s.get("blend_exists",0) < 1.0: base = min(base, 0.30) if s.get("no_overlap",0) < 0.85: base = min(base, 0.40) if s.get("rule_conformance",0) < 0.6: base = min(base, 0.45) if s.get("mesh_count",0) < 1.0: base = min(base, 0.50) if s.get("render_size",0) < 1.0 or s.get("render_nontrivial",0) < 0.8: base = min(base, 0.45) if s.get("top_view_ok",0) < 1.0: base = min(base, 0.50) if s.get("screenshots_distinct",0) < 1.0: base = min(base, 0.45) if s.get("layout_csv_schema",0) < 1.0 or s.get("layout_csv_unique",0) < 1.0: base = min(base, 0.50) vlm_keys = [k for k in s if k.startswith("vlm_")] if vlm_keys: vlm_avg = sum(s.get(k,0) for k in vlm_keys)/len(vlm_keys) if vlm_avg < 0.6: base = min(base, 0.50) if vlm_avg < 0.4: base = min(base, 0.35) else: # VLM 不可用时退化分上限封顶 0.6 base = min(base, 0.60) s["overall_score"] = round(base, 3) return s ``` ## Workspace Path `workspace/SPA/task_0_blender_room_arrange/` ## Skills ``` ``` ## Env ``` ``` ## Warmup ```bash which blender >/dev/null 2>&1 || (curl -fsSLo /tmp/blender.tar.xz https://download.blender.org/release/Blender4.0/blender-4.0.2-linux-x64.tar.xz && mkdir -p /opt/blender && tar -xJf /tmp/blender.tar.xz -C /opt/blender --strip-components=1 && ln -sf /opt/blender/blender /usr/local/bin/blender) || true apt-get install -y -qq tesseract-ocr || true pip install -q numpy pillow pytesseract || true ```