Spaces:
Sleeping
Sleeping
GitHub Actions commited on
Commit ·
6da2618
1
Parent(s): 22a203c
Deploy from GitHub commit e5655c5148bdf9ff2f4a5d17d6cefe1ca9563ba1
Browse files- app.py +8 -0
- verify_n2_sim.py +11 -0
app.py
CHANGED
|
@@ -1342,6 +1342,14 @@ def build_segmentation_bundle(contents: bytes):
|
|
| 1342 |
t0 = time.perf_counter()
|
| 1343 |
quad = np.asarray(plane["quad"], dtype=np.float32).reshape(4, 2) if plane and plane.get("quad") else None
|
| 1344 |
surface_mask, occluder_zone = build_floor_surface_mask(floor_mask, seg_map, quad, depth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1345 |
print(f"[TIMING] Surface masking took {time.perf_counter() - t0:.3f} seconds", flush=True)
|
| 1346 |
|
| 1347 |
t0 = time.perf_counter()
|
|
|
|
| 1342 |
t0 = time.perf_counter()
|
| 1343 |
quad = np.asarray(plane["quad"], dtype=np.float32).reshape(4, 2) if plane and plane.get("quad") else None
|
| 1344 |
surface_mask, occluder_zone = build_floor_surface_mask(floor_mask, seg_map, quad, depth)
|
| 1345 |
+
# N2 — final enclosed-island sweep on the FINISHED surface, without class
|
| 1346 |
+
# protection: pattern features the segmenter calls objects (the blue
|
| 1347 |
+
# accent tile in the kitchen reference room) pass the earlier protected
|
| 1348 |
+
# fill and get re-cut by the occluder subtraction. At this stage a tiny
|
| 1349 |
+
# hole fully enclosed by the surface is flat floor pattern by
|
| 1350 |
+
# construction — real standing objects extend beyond the floor region, so
|
| 1351 |
+
# their cut-outs stay connected to the rest of the scene and are immune.
|
| 1352 |
+
surface_mask = fill_enclosed_islands(surface_mask, None, max_area=int(w * h * 0.001))
|
| 1353 |
print(f"[TIMING] Surface masking took {time.perf_counter() - t0:.3f} seconds", flush=True)
|
| 1354 |
|
| 1355 |
t0 = time.perf_counter()
|
verify_n2_sim.py
CHANGED
|
@@ -54,6 +54,15 @@ def main():
|
|
| 54 |
|
| 55 |
out = fill_enclosed_islands(mask, protect, max_area=2000)
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
checks = [
|
| 58 |
("1 plain island filled", bool((out[52:68, 52:68] == 1).all())),
|
| 59 |
("2 bridged island filled", bool((out[212:224, 262:274] == 1).all())),
|
|
@@ -62,6 +71,8 @@ def main():
|
|
| 62 |
("4 stray-pixel island filled", bool((out[82:98, 402:418] == 1).all())),
|
| 63 |
("5 border hole kept", bool((out[2:28, 502:538] == 0).all())),
|
| 64 |
("6 big hole kept", bool((out[285:355, 385:555] == 0).all())),
|
|
|
|
|
|
|
| 65 |
]
|
| 66 |
ok = True
|
| 67 |
for name, passed in checks:
|
|
|
|
| 54 |
|
| 55 |
out = fill_enclosed_islands(mask, protect, max_area=2000)
|
| 56 |
|
| 57 |
+
# 7. final unprotected sweep (N2b): a fully-protected small island — a
|
| 58 |
+
# pattern feature the segmenter calls an object — must fill when the sweep
|
| 59 |
+
# runs without class protection on the finished surface, while the big
|
| 60 |
+
# protected mat hole still survives via max_area.
|
| 61 |
+
mask7 = np.ones((400, 600), np.uint8)
|
| 62 |
+
mask7[150:175, 300:330] = 0 # "blue accent tile" island
|
| 63 |
+
mask7[200:240, 100:190] = 0 # mat-sized hole (3600 px)
|
| 64 |
+
out7 = fill_enclosed_islands(mask7, None, max_area=1000)
|
| 65 |
+
|
| 66 |
checks = [
|
| 67 |
("1 plain island filled", bool((out[52:68, 52:68] == 1).all())),
|
| 68 |
("2 bridged island filled", bool((out[212:224, 262:274] == 1).all())),
|
|
|
|
| 71 |
("4 stray-pixel island filled", bool((out[82:98, 402:418] == 1).all())),
|
| 72 |
("5 border hole kept", bool((out[2:28, 502:538] == 0).all())),
|
| 73 |
("6 big hole kept", bool((out[285:355, 385:555] == 0).all())),
|
| 74 |
+
("7 final sweep fills pattern island", bool((out7[152:173, 302:328] == 1).all())),
|
| 75 |
+
("7 final sweep keeps big hole", bool((out7[205:235, 105:185] == 0).all())),
|
| 76 |
]
|
| 77 |
ok = True
|
| 78 |
for name, passed in checks:
|