Image Segmentation
PyTorch
English
painting-vision-robotics-kit
semantic-segmentation
robotics
edge-ai
construction-ai
autonomous-painting
wall-painting-robot
paint-coverage-estimation
building-facade
drywall
skirting-detection
window-detection
lidar
depth-validation
segformer
deeplabv3
Eval Results (legacy)
Update code: real-machine G-code adapter, commissioning gate, machine_job runner, pump watchdog firmware, twin completion gate, realism and masking modules (card and weights unchanged)
4eecd03 verified Download eval_drone_paint.py from constructelligence/painting-vision-robotics-kit: direct link, hf CLI and curl.
- Browser
- Download file 6.26 kB
-
https://huggingface.co/constructelligence/painting-vision-robotics-kit/resolve/main/eval_drone_paint.py
- Command line
-
hf download hf://constructelligence/painting-vision-robotics-kit/eval_drone_paint.py
-
curl -L -o eval_drone_paint.py https://huggingface.co/constructelligence/painting-vision-robotics-kit/resolve/main/eval_drone_paint.py
6.26 kB
| #!/usr/bin/env python3 | |
| """Spray-drone painting quality on synthetic facades, by simulation (see drone_areas.py for the deposit model). | |
| Three plans per facade: the roller-style plan (fan edge exactly at a window, no margin), the margin plan (fan kept | |
| clear of openings by feather + position error + drift), and margin + edge pass (a narrower fan for the strip the main | |
| pass cannot reach). Scored on film quality and on paint reaching windows, averaged over 20 flights with random errors. | |
| python eval_drone_paint.py [--positioning 0.02] | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import numpy as np | |
| import application as ap | |
| import drone_areas as da | |
| import drone_path as dp | |
| import robot_planner as rp | |
| MM = 25.0 # mm per pixel; 30 m x 18 m facade would be too large to simulate, this is 12 m x 7.5 m | |
| H, W = 300, 480 | |
| def deposit(main_s, edge_s, edge_fan_mm, shape, sp, positioning, seed, model="timing"): | |
| """The film a flight lays: the geometric model, or the timed one (speed, standoff and valve flow per sample).""" | |
| if model == "legacy": | |
| film = da.simulate_deposit(main_s, shape, MM, sp["fan_width_mm"], positioning, 10.0, seed, sp["pass_spacing_mm"]) | |
| if edge_s: | |
| film = film + da.simulate_deposit(edge_s, shape, MM, edge_fan_mm, positioning, 10.0, 1000 + seed, edge_fan_mm / 2) | |
| return film | |
| film = da.deposit_from_timeline(dp.from_strokes(main_s, MM, shape, sp, standoff_mm=sp["standoff_mm"], | |
| lateral_sigma_mm=positioning * 1000, seed=seed), | |
| shape, MM, sp, drift_mm=10.0)["film"] | |
| if edge_s: # the edge pass is flown closer, so its own standoff and spacing are the design | |
| film = film + da.deposit_from_timeline(dp.from_strokes(edge_s, MM, shape, sp, standoff_mm=sp["standoff_mm"] / 2, | |
| lateral_sigma_mm=positioning * 1000, seed=1000 + seed), | |
| shape, MM, sp, drift_mm=10.0, design_standoff_mm=sp["standoff_mm"] / 2, | |
| design_spacing_mm=edge_fan_mm / 2)["film"] | |
| return film | |
| def facades(): | |
| def base(): | |
| c = np.full((H, W), 2, np.uint8) | |
| return c | |
| out = {} | |
| c = base(); out["plain"] = c | |
| c = base(); c[60:140, 60:140] = 8; c[60:140, 220:300] = 8; c[60:140, 380:440] = 8; out["window row"] = c | |
| c = base() | |
| for r in (40, 160): | |
| for x in (50, 160, 270, 380): | |
| c[r:r + 70, x:x + 60] = 8 | |
| c[220:300, 200:260] = 7 | |
| out["grid + door"] = c | |
| c = base(); c[100:140, 40:440] = 8; out["ribbon window"] = c # a strip window: the wall above/below is narrow | |
| c = base(); c[50:250, 30:60] = 8; c[50:250, 90:120] = 8; c[50:250, 150:180] = 8; out["tall slots"] = c | |
| return out | |
| def spray(standoff=300): | |
| tip = ap.SprayTip.parse("517") | |
| return ap.spray_settings(tip.flow_lps(2000), tip.fan_angle_deg, standoff, 38, 0.38) | |
| def plans(classes, positioning, sp): | |
| h, w = classes.shape | |
| wall = np.isin(classes, da.WALL) | |
| keep = np.isin(classes, da.OPENINGS) | |
| paintable = wall & ~keep | |
| fan_px = max(2, int(round(sp["fan_width_mm"] / MM))) | |
| old, _ = rp.build_plan(paintable, keep, fan_px, 0.5, 0, "horizontal", None, MM, 4.0) | |
| old_strokes = old["plan"]["strokes"] | |
| new = da.plan_passes(classes, MM, sp, positioning_m=positioning) | |
| masked = da.plan_passes(classes, MM, sp, positioning_m=positioning, masked_openings=True) | |
| return paintable, keep, {"unmasked, no margin (unsafe)": (old_strokes, []), | |
| "unmasked, margin": (new["main_strokes_px"], []), | |
| "unmasked, margin + edge pass": (new["main_strokes_px"], new["edge_strokes_px"]), | |
| "windows masked": (masked["main_strokes_px"], masked["edge_strokes_px"])}, new, masked | |
| def main(): | |
| a = argparse.ArgumentParser() | |
| a.add_argument("--positioning", type=float, default=0.02) | |
| a.add_argument("--flights", type=int, default=20) | |
| a.add_argument("--deposit", choices=("timing", "legacy"), default="timing", | |
| help="timing deposits from the timed path; legacy is the model published before it") | |
| args = a.parse_args() | |
| sp = spray() | |
| print(f"fan {sp['fan_width_mm']:.0f} mm, pass spacing {sp['pass_spacing_mm']:.0f} mm, positioning sigma {args.positioning * 100:.0f} cm, " | |
| f"{args.deposit} deposit\n") | |
| print(f"{'facade':14s} {'plan':30s} {'good':>6s} {'thin':>6s} {'heavy':>6s} {'on windows':>10s} {'heavy on win':>12s} {'hand m2':>8s}") | |
| totals = {} | |
| for name, classes in facades().items(): | |
| paintable, keep, variants, new, masked = plans(classes, args.positioning, sp) | |
| for label, (main_s, edge_s) in variants.items(): | |
| rows = [] | |
| for seed in range(args.flights): | |
| film = deposit(main_s, edge_s, new["edge_fan_mm"], classes.shape, sp, args.positioning, seed, args.deposit) | |
| if label == "windows masked": # paint that lands on a masked opening is on the mask, not on the glass | |
| rows.append(da.score_deposit(film, paintable, np.zeros_like(keep))) | |
| continue | |
| rows.append(da.score_deposit(film, paintable, keep)) | |
| m = {k: float(np.mean([r[k] for r in rows])) for k in rows[0]} | |
| hand = {"unmasked, margin + edge pass": new["hand_finish_m2"], "windows masked": masked["hand_finish_m2"], | |
| "unmasked, margin": float((paintable & ~new["masks"]["main"]).sum()) * (MM / 1000) ** 2}.get(label, 0.0) | |
| print(f"{name:14s} {label:30s} {m['good']:6.1%} {m['thin']:6.1%} {m['heavy']:6.1%} {m['overspray_on_openings']:10.1%} {m['overspray_heavy_on_openings']:12.1%} {hand:8.1f}") | |
| totals.setdefault(label, []).append(m) | |
| print() | |
| for label, ms in totals.items(): | |
| print(f"{label:30s} mean good {np.mean([m['good'] for m in ms]):.1%} mean paint on windows {np.mean([m['overspray_on_openings'] for m in ms]):.1%} heavy on windows {np.mean([m['overspray_heavy_on_openings'] for m in ms]):.1%}") | |
| if __name__ == "__main__": | |
| main() | |