WeaveBench / tasks /SPA /SPA_task_1_floor_plan.md
wanlilll's picture
Add 114 tasks under 8-domain flat layout
71e9dba verified
|
Raw History Blame Contribute Delete
23.4 kB
metadata
id: SPA_task_1_floor_plan
name: 按草图在平面图上标注家具
category: SPA
timeout_seconds: 1500

Prompt

/tmp_workspace/floor.svg is a blank floor plan of an 80 m² two-bedroom unit (dimensions already labeled). The client's hand-drawn sketch is at /tmp_workspace/sketch.jpg, describing the relative positions and orientations of 22 pieces of furniture. /tmp_workspace/reference_room.jpg is an interior reference photo (visual reference for tone / style / tidiness); you may compare mood against it but it is not required.

Task

Lay out the 22 pieces of furniture on the floor plan following the sketch, and produce a deliverable annotated SVG / PNG / acceptance report.

Layout: 4 rooms (living / bedroom1 / bedroom2 / kitchen) + 4 doors, with 22 pieces of furniture in total.

Furniture layout rules:

  • Each piece of furniture is represented as a vector rectangle/shape, colored by category: bed/sofa = blue, table/chair = green, kitchen appliance = orange, storage = gray.
  • Each piece of furniture must have a semantic named ID (e.g. bed_master, sofa_living), with ≥ 22 in total; auto-generated IDs like rect1234 or path5678 are not allowed.
  • Add a <text> next to each piece of furniture with its Chinese name + dimensions (including mm).
  • At least 5 passage-width annotations (with mm text + dimension lines), and each passage must be ≥ 600 mm wide.
  • At least 3 pieces of furniture must apply an Inkscape LPE (Live Path Effects; the SVG must contain an inkscape:path-effect attribute).
  • 4 pieces of furniture are evenly aligned along the east wall, with x-center-coordinate variance ≤ 5 mm across those 4.
  • Each piece of furniture lies fully inside the polygon of its assigned room, and its minimum distance to any door / wall is ≥ 60 px.
  • At least 8 orientation-constrained pieces of furniture face the correct direction (e.g. sofa facing the TV wall, bed headboard against a long wall).

Deliverables (write to /tmp_workspace/results/)

  • floor_annotated.svg — contains a furniture layer (inkscape:groupmode="layer" + inkscape:label="furniture") along with all the furniture / text labels / dimension annotations described above.
  • floor_annotated.png — PNG export of the above SVG, ≥ 2000×1500.
  • placement_check.md — ≥ 22 lines; each line lists, for one furniture item: ID + assigned room + target position + actual center coordinate + whether it satisfies the rules.
  • view_01_layers_panel.png — Layers panel screenshot showing ≥ 2 layers (base + furniture).
  • view_02_lpe_dialog.png — Path Effects dialog with at least 1 effect in the list.
  • view_03_align_dialog.png — Align and Distribute dialog.
  • view_04_measure_tool.png — Measure tool activated with readable measurement results.
  • view_xml_editor.png — XML editor showing a furniture node from the furniture layer along with its inkscape:label attribute.

Expected Behavior

参考解题流程 (设计者参考, 不发给 agent):

  1. 用 Inkscape 打开 floor.svg 作为底图; 创建名为 furniture 的图层。
  2. 按 sketch.jpg 中标注, 每件家具用矢量矩形/形状标注, 颜色按类别 (床/沙发=蓝, 桌椅=绿, 厨电=橙, 收纳=灰)。
  3. 每件家具必须有命名 ID (Object Properties → Label, 例如 id="bed_master")。
  4. 每件家具旁加文字标签 (中文家具名 + 尺寸 mm)。
  5. 用 Inkscape LPE (Path → Path Effects → 选 "Pattern Along Path" / "Mirror" / "Roughen") 给至少 3 件家具加效果。
  6. 用 Measure 工具标出 ≥ 5 处通道宽度 (≥ 600 mm)。
  7. Object → Align and Distribute 把 4 件家具沿东墙等距对齐 (x 坐标方差 ≤ 5 mm)。
  8. Ctrl+Shift+X 打开 XML editor, 截图含 furniture layer 的某个家具节点 + inkscape:label 属性。
  9. 4 张 Inkscape UI 工作截图: layers panel / LPE dialog / Align dialog / Measure tool。
  10. 存为 floor_annotated.svg + 导出 floor_annotated.png (≥ 2000×1500)。
  11. 写 placement_check.md: 列每件家具的目标位置 vs 实际中心坐标 + 是否符合 + ID。

判分要点速览:

  • Inkscape GUI 启动并打开 /tmp_workspace/floor.svg 作为底图。
  • 文档中存在一个名为 furniture 的 layer (inkscape:groupmode="layer" + inkscape:label="furniture")。
  • furniture layer 内含 ≥ 22 个家具形状 (<rect> 或 <path>), 覆盖 4 类颜色 (蓝/绿/橙/灰)。
  • 至少 22 个语义化命名 ID (如 bed_master、sofa_living), 形如 ^[a-z]+(_[a-z0-9]+)+$, 不含 rect1234 自动 ID。
  • 每件家具旁有 <text> 中文名 + 尺寸 (含 "mm"), 合计 ≥ 22 个 <text> 元素, 并出现 ≥ 5 处 "mm" 测量标注。
  • 至少 3 件家具应用了 Inkscape LPE (SVG 中含 inkscape:path-effect 属性)。
  • gt 中列出的核心家具名 (sofa / tv_stand / bed_master / fridge / dining_table 等) 在命名 ID 集合中可被覆盖。
  • 4 件沿东墙对齐的家具, 命名 ID 的 x 中心坐标方差 ≤ 5 (mm 等价单位)。
  • 5 张 Inkscape UI 截图 (Layers / LPE / Align / Measure / XML Editor) 出现在 /tmp_workspace/results/。
  • 导出 floor_annotated.png 分辨率 ≥ 2000×1500, 并写出 placement_check.md ≥ 22 行说明每件家具目标 vs 实际位置。

设计版本备注 (v2 加难, additive):

  • 房型从初版的单一开间扩到 4 个房间 (living / bedroom1 / bedroom2 / kitchen) + 4 道门。
  • 家具件数从 18 提到 22, 每件必须: 完全位于分配房间内, 距门/墙 ≥ 60 px, 至少 8 件带朝向约束方向正确。

Source

Grading Criteria

  • floor_annotated.svg 存在;含 ≥ 22 个 <rect> 或 <path> 在 furniture layer
  • SVG 中含 ≥ 4 种 fill color
  • SVG 中 <text> 元素 ≥ 22
  • 至少 5 处 dimension 标注(含 "mm" 文本)
  • floor_annotated.png 分辨率 ≥ 2000×1500(文件大小 ≥ 50KB,防纯白占位图)
  • placement_check.md 行数 ≥ 22
  • SVG 中存在 inkscape:groupmode="layer" + inkscape:label="furniture" 的 furniture 图层
  • SVG 中至少 22 个语义化命名 ID(形如 ^[a-z]+(_[a-z0-9]+)+$,不能是 rect1234 自动 ID)
  • SVG 中至少 3 个 inkscape:path-effect(LPE 应用证据)
  • SVG 中至少 5 个含 "mm" 的 <text> 测量标注
  • gt/expected_furniture.json 列出的核心家具名(sofa / tv_stand / bed_master / fridge / dining_table 等)在命名 ID 集合中至少覆盖 8 个
  • gt/rooms.json 列出的房间名(living / bedroom1 / bedroom2 / kitchen)在 SVG <text> 或 inkscape:label 中可被识别
  • 沿东墙等距对齐的 4 件家具,其命名 ID 对应矩形的 x 中心方差 ≤ 5
  • 5 张 Inkscape UI 截图齐全(layers/lpe/align/measure/xml_editor)出现在 /tmp_workspace/results/
  • VLM 视觉评分(在 VLM 可用时):家具叠加完整、文字可读、颜色分类、布局合理

Automated Checks

from pathlib import Path
import json
import re
from PIL import Image

def grade(workspace_path=None, **kwargs):
    workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace")
    try:
        from _judge_helper import vlm_score_rubric
    except Exception:
        vlm_score_rubric = None
    # gt directory: sibling of workspace (host-side), not visible to agent
    gt_dir = workspace.parent / "gt"
    if not gt_dir.exists():
        # fallback: bench-style layout where gt sits next to workspace via ../gt
        for cand in [workspace / "gt", workspace.parent.parent / "gt"]:
            if cand.exists():
                gt_dir = cand
                break

    r = {"checks": {}, "overall_score": 0.0}
    # v2: weighted scoring buckets
    core_s, core_t = 0.0, 0  # 60% — svg/png/placement core deliverables
    gui_s, gui_t = 0.0, 0    # 30% — Inkscape GUI evidence (ui shots / lpe / measure / layer)
    aux_s, aux_t = 0.0, 0    # 10% — GT coverage / alignment auxiliary
    svg = workspace / "floor_annotated.svg"
    # also try /tmp_workspace/results/ landing
    if not svg.exists() and (workspace / "results" / "floor_annotated.svg").exists():
        svg = workspace / "results" / "floor_annotated.svg"
    if svg.exists():
        try:
            c = svg.read_text(errors="ignore")
        except Exception:
            c = ""
        shapes = len(re.findall(r"<(rect|path)", c))
        core_t += 1
        if shapes >= 22:
            r["checks"][f"shapes={shapes}"] = True; core_s += 1
        elif shapes >= 14:
            r["checks"][f"shapes={shapes}"] = 0.5; core_s += 0.5
        colors = set(re.findall(r"fill:#([0-9a-fA-F]{3,6})", c))
        core_t += 1
        if len(colors) >= 4:
            r["checks"][f"colors={len(colors)}"] = True; core_s += 1
        texts = len(re.findall(r"<text", c))
        core_t += 1
        if texts >= 22:
            r["checks"][f"texts={texts}"] = True; core_s += 1
        elif texts >= 14:
            r["checks"][f"texts={texts}"] = 0.5; core_s += 0.5
        gui_t += 1
        if c.count("mm") >= 5:
            r["checks"]["dim_mm>=5"] = True; gui_s += 1
        elif c.count("mm") >= 3:
            r["checks"]["dim_mm>=5"] = 0.5; gui_s += 0.5
    png = workspace / "floor_annotated.png"
    if not png.exists() and (workspace / "results" / "floor_annotated.png").exists():
        png = workspace / "results" / "floor_annotated.png"
    core_t += 1
    if png.exists():
        try:
            w, h = Image.open(png).size
            png_size = png.stat().st_size
            # v2 anti-cheat: also require min file size to defeat blank/placeholder images
            if w >= 2000 and h >= 1500 and png_size >= 50_000:
                r["checks"]["png_res"] = True; core_s += 1
            elif w >= 2000 and h >= 1500:
                r["checks"]["png_res"] = 0.4; core_s += 0.4
        except Exception:
            pass
    pc = workspace / "placement_check.md"
    if not pc.exists() and (workspace / "results" / "placement_check.md").exists():
        pc = workspace / "results" / "placement_check.md"
    core_t += 1
    if pc.exists():
        try:
            lines = pc.read_text(errors="ignore").splitlines()
            if len(lines) >= 22:
                r["checks"]["check_lines"] = True; core_s += 1
            elif len(lines) >= 14:
                r["checks"]["check_lines"] = 0.5; core_s += 0.5
        except Exception:
            pass

    # Collect named IDs once
    named = []
    c2 = ""
    if svg.exists():
        try:
            c2 = svg.read_text(errors="ignore")
        except Exception:
            c2 = ""
        # furniture layer present
        gui_t += 1
        if re.search(r'inkscape:groupmode\s*=\s*"layer"', c2) and re.search(r'inkscape:label\s*=\s*"furniture"', c2):
            r["checks"]["furniture_layer"] = True; gui_s += 1
        else:
            r["checks"]["furniture_layer"] = False
        # v2: Named IDs threshold raised to 22 (match prompt count)
        all_ids = re.findall(r'\bid\s*=\s*"([^"]+)"', c2)
        named = [i for i in all_ids if re.match(r'^[a-z]+(_[a-z0-9]+)+$', i)]
        r["checks"]["named_ids"] = min(1.0, len(named) / 22.0); core_s += r["checks"]["named_ids"]; core_t += 1
        # LPE
        lpe_count = len(re.findall(r"inkscape:path-effect", c2))
        r["checks"]["lpe_count"] = 1.0 if lpe_count >= 3 else lpe_count / 3.0
        gui_s += r["checks"]["lpe_count"]; gui_t += 1
        # Measure annotations: count text elements with mm
        mm_count = len(re.findall(r"<text[^>]*>[^<]*mm[^<]*</text>", c2))
        r["checks"]["measure_count"] = 1.0 if mm_count >= 5 else mm_count / 5.0
        gui_s += r["checks"]["measure_count"]; gui_t += 1

    # ---------- GT integration (B2 / D1 / B2 alignment) ----------
    gt_furniture = {}
    gt_rooms = {}
    try:
        ef = gt_dir / "expected_furniture.json"
        if ef.exists():
            gt_furniture = json.loads(ef.read_text(errors="ignore")).get("required_furniture", {})
    except Exception:
        gt_furniture = {}
    try:
        rj = gt_dir / "rooms.json"
        if rj.exists():
            gt_rooms = json.loads(rj.read_text(errors="ignore"))
    except Exception:
        gt_rooms = {}

    # D1: how many GT-required furniture names appear in named ID set
    if gt_furniture:
        named_set = set(named)
        hits = sum(1 for k in gt_furniture if any(k == n or n.startswith(k + "_") or n.endswith("_" + k) or k in n for n in named_set))
        # v2: tighter target — require ≥10 hits or ≥50% of GT
        target = max(10, int(0.5 * len(gt_furniture)))
        r["checks"]["gt_furniture_coverage"] = min(1.0, hits / float(target))
        aux_s += r["checks"]["gt_furniture_coverage"]; aux_t += 1

    # D1: how many GT room names referenced in SVG text/labels
    if gt_rooms and c2:
        room_hits = sum(1 for rn in gt_rooms if rn in c2)
        r["checks"]["gt_room_refs"] = min(1.0, room_hits / max(1.0, float(len(gt_rooms))))
        aux_s += r["checks"]["gt_room_refs"]; aux_t += 1

    # B2 alignment: 4 furniture along east wall, x-center variance ≤ 5
    # Heuristic: find rect IDs containing 'east' or use any 4 explicit aligned IDs;
    # parse <rect ... id="..." x="..." width="..." />
    if c2:
        rect_pat = re.compile(
            r'<rect\b[^>]*?\bid\s*=\s*"([^"]+)"[^>]*?\bx\s*=\s*"([\-0-9.]+)"[^>]*?\bwidth\s*=\s*"([\-0-9.]+)"',
            re.DOTALL,
        )
        rects = []
        for m in rect_pat.finditer(c2):
            try:
                rects.append((m.group(1), float(m.group(2)) + float(m.group(3)) / 2.0))
            except Exception:
                continue
        # also try the alternative attribute order: id ... width ... x
        rect_pat2 = re.compile(
            r'<rect\b[^>]*?\bid\s*=\s*"([^"]+)"[^>]*?\bwidth\s*=\s*"([\-0-9.]+)"[^>]*?\bx\s*=\s*"([\-0-9.]+)"',
            re.DOTALL,
        )
        existing = {rid for rid, _ in rects}
        for m in rect_pat2.finditer(c2):
            if m.group(1) in existing:
                continue
            try:
                rects.append((m.group(1), float(m.group(3)) + float(m.group(2)) / 2.0))
            except Exception:
                continue
        east_rects = [(rid, cx) for rid, cx in rects if "east" in rid.lower() or rid.lower().endswith("_e")]
        align_score = 0.0
        if len(east_rects) >= 4:
            xs = [cx for _, cx in east_rects[:4]]
            mean = sum(xs) / 4.0
            var = sum((x - mean) ** 2 for x in xs) / 4.0
            r["checks"]["east_align_variance"] = round(var, 3)
            align_score = 1.0 if var <= 5.0 else (0.5 if var <= 25.0 else 0.0)
        else:
            r["checks"]["east_align_variance"] = None
        r["checks"]["alignment_score"] = align_score
        aux_s += align_score; aux_t += 1
    # ---------- end GT integration ----------

    # 5 UI screenshots — check both workspace/ and workspace/results/
    # v2 anti-cheat: also require each present shot to be ≥5KB and md5-unique
    import hashlib
    rd_results = workspace
    rd_alt = workspace / "results"
    ui_shots = ["view_01_layers_panel.png", "view_02_lpe_dialog.png", "view_03_align_dialog.png",
                "view_04_measure_tool.png", "view_xml_editor.png"]
    ui_paths = []
    for n in ui_shots:
        for d in (rd_results, rd_alt):
            p = d / n
            if p.exists():
                ui_paths.append(p)
                break
    ui_md5s = set()
    ui_valid = 0
    for p in ui_paths:
        try:
            if p.stat().st_size >= 5000:
                h = hashlib.md5(p.read_bytes()).hexdigest()
                if h not in ui_md5s:
                    ui_md5s.add(h); ui_valid += 1
        except Exception:
            continue
    r["checks"]["inkscape_ui_shots"] = ui_valid / len(ui_shots)
    r["checks"]["inkscape_ui_unique_md5"] = len(ui_md5s)
    gui_s += ui_valid / len(ui_shots); gui_t += 1

    # v2: weighted overall — core 60%, gui 30%, aux 10%
    def _avg(s, t): return (s / t) if t > 0 else 0.0
    core_avg = _avg(core_s, core_t)
    gui_avg = _avg(gui_s, gui_t)
    aux_avg = _avg(aux_s, aux_t)
    base = 0.6 * core_avg + 0.3 * gui_avg + 0.1 * aux_avg
    r["checks"]["_core_avg"] = round(core_avg, 3)
    r["checks"]["_gui_avg"] = round(gui_avg, 3)
    r["checks"]["_aux_avg"] = round(aux_avg, 3)
    vlm_ran = False
    # v2: cap base when VLM unavailable so no-VLM path can't reach full score
    base_no_vlm_cap = 0.60
    if vlm_score_rubric and png.exists():
        rubric = {
            "vlm_furniture_present": "户型图上叠加了 ≥18 个家具/物件标注(矩形或图形元素)",
            "vlm_text_legible": "每个标注上有清晰可读的文字编号或名称(不重叠原户型线条)",
            "vlm_color_categorized": "标注按 ≥4 种颜色分类(如不同房间或不同家具类别)",
            "vlm_layout_realistic": "家具摆放符合常理(沙发对电视、床靠墙等),无明显穿墙或占用通道",
        }
        try:
            vlm = vlm_score_rubric([str(png)], rubric, instruction="评估手绘客户家具摆放叠加在户型图上的标注质量。")
        except Exception:
            vlm = {}
        for k in rubric:
            r["checks"][k] = vlm.get(k, 0.0)
        r["judge_method"] = vlm.get("judge_method", "failed")
        vlm_avg = sum(vlm.get(k, 0.0) for k in rubric) / len(rubric)
        if vlm and r["judge_method"] != "failed":
            vlm_ran = True
            r["overall_score"] = round((base + vlm_avg) / 2, 3)
        else:
            r["overall_score"] = round(base, 3)
    else:
        r["overall_score"] = round(base, 3)

    # v2: when VLM did not run, hard cap overall score (no full marks without judge)
    if not vlm_ran:
        r["overall_score"] = round(min(r["overall_score"], base_no_vlm_cap), 3)
    # v2 hard gates — tighter and multi-layer
    if vlm_ran:
        vlm_keys = ["vlm_furniture_present", "vlm_text_legible", "vlm_color_categorized", "vlm_layout_realistic"]
        vlm_avg = sum(r["checks"].get(k, 0) for k in vlm_keys) / len(vlm_keys)
        if vlm_avg < 0.75:
            r["overall_score"] = round(min(r["overall_score"], 0.50), 3)
        if vlm_avg < 0.5:
            r["overall_score"] = round(min(r["overall_score"], 0.35), 3)
    # core deliverable gate — if core average < 0.5, hard cap 0.40
    if r["checks"].get("_core_avg", 0) < 0.5:
        r["overall_score"] = round(min(r["overall_score"], 0.40), 3)
    # named id gate (raised threshold)
    if r["checks"].get("named_ids", 0) < 0.7:
        r["overall_score"] = round(min(r["overall_score"], 0.50), 3)
    if r["checks"].get("named_ids", 0) < 0.4:
        r["overall_score"] = round(min(r["overall_score"], 0.35), 3)
    # GUI evidence gate (raised threshold + multi-layer)
    if r["checks"].get("inkscape_ui_shots", 0) < 0.6:
        r["overall_score"] = round(min(r["overall_score"], 0.50), 3)
    if r["checks"].get("inkscape_ui_shots", 0) < 0.3:
        r["overall_score"] = round(min(r["overall_score"], 0.35), 3)
    if r["checks"].get("lpe_count", 0) < 1.0:
        r["overall_score"] = round(min(r["overall_score"], 0.60), 3)
    if r["checks"].get("lpe_count", 0) == 0:
        r["overall_score"] = round(min(r["overall_score"], 0.40), 3)
    # furniture layer is mandatory — without it agent didn't really use Inkscape layers
    if r["checks"].get("furniture_layer") is not True:
        r["overall_score"] = round(min(r["overall_score"], 0.50), 3)
    # Structural gate: missing core furniture coverage caps overall
    if "gt_furniture_coverage" in r["checks"] and r["checks"]["gt_furniture_coverage"] < 0.5:
        r["overall_score"] = round(min(r["overall_score"], 0.55), 3)

    # ----- BEGIN CHEAT/VLM HARD-GATE (auto-injected) -----
    try:
        from _judge_helper import audit_chat_jsonl_for_banned as _audit
    except Exception:
        _audit = None
    _BANS = ['"xmllint"', 'xpath', 'svgpathtools.parse']
    if _audit is not None:
        try:
            _a = _audit(_BANS)
            r["audit_total_tool_calls"] = _a.get("total_tool_calls", 0)
            r["audit_screenshots"] = _a.get("computer_screenshots", 0)
            r["audit_any_banned"] = 1.0 if _a.get("any_banned") else 0.0
            r["audit_matches"] = ",".join(_a.get("matches", [])[:5])
            if _a.get("any_banned") and _a.get("computer_screenshots", 0) == 0:
                r["overall_score"] = min(float(r.get("overall_score", 1.0)), 0.30)
            if _a.get("total_tool_calls", 0) >= 5 and _a.get("computer_screenshots", 0) == 0:
                r["overall_score"] = min(float(r.get("overall_score", 1.0)), 0.45)
        except Exception as _e:
            r["audit_error"] = str(_e)[:120]
    # ----- END CHEAT/VLM HARD-GATE -----
    r["overall_score"] = float(r["overall_score"])
    return r

Workspace Path

workspace/SPA/task_1_floor_plan/

Skills


Env


Warmup

which inkscape >/dev/null 2>&1 || (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq inkscape) || true
which gimp >/dev/null 2>&1 || DEBIAN_FRONTEND=noninteractive apt-get install -y -qq gimp || true
which xdotool >/dev/null 2>&1 || DEBIAN_FRONTEND=noninteractive apt-get install -y -qq xdotool || true
which wmctrl >/dev/null 2>&1 || DEBIAN_FRONTEND=noninteractive apt-get install -y -qq wmctrl || true
fc-list | grep -qi 'Noto Sans CJK' || DEBIAN_FRONTEND=noninteractive apt-get install -y -qq fonts-noto-cjk || true
fc-cache -f >/dev/null 2>&1 || true
pip install -q pillow || true
# OCR / image deps used by grader / judge helpers (universal across Eyeson cases)
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq tesseract-ocr || true
pip install -q pytesseract numpy || true
chown -R user:user /tmp_workspace 2>/dev/null || true
mkdir -p /tmp_workspace/results 2>/dev/null || true
rm -f /home/user/.openclaw/agents/main/sessions/*.lock 2>/dev/null || true
openclaw config unset agents.defaults.imageModel >/dev/null 2>&1 || true
openclaw config set agents.defaults.sandbox.imageModel.primary "" >/dev/null 2>&1 || true