agent-manifesto-kit 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collection/skills/concept-asset-builder/SKILL.md +14 -5
- package/collection/skills/concept-asset-builder/assets/templates/agent_brief.md +5 -2
- package/collection/skills/concept-asset-builder/references/field-lessons.md +9 -0
- package/collection/skills/concept-asset-builder/scripts/blender/render_views.py +4 -2
- package/collection/skills/concept-asset-builder/scripts/codex_review.sh +4 -1
- package/collection/skills/concept-asset-builder/scripts/godot/capture.gd +5 -2
- package/collection/skills/concept-asset-builder/scripts/init_workspace.sh +1 -1
- package/collection/skills/concept-asset-builder/scripts/measure_silhouette.py +18 -4
- package/collection/skills/concept-asset-builder/scripts/overlay_masks.py +25 -0
- package/collection/skills/concept-asset-builder/scripts/test_tools.py +44 -0
- package/collection/skills/concept-asset-builder/scripts/threejs/studio.js +4 -2
- package/collection/skills/concept-asset-builder/scripts/wear_stats.py +35 -1
- package/package.json +1 -1
|
@@ -49,28 +49,28 @@ Read from the invocation; defaults in brackets.
|
|
|
49
49
|
blender/ threejs/ studio (frozen) + the builder's code
|
|
50
50
|
out/<pipeline>/<view>.png renders; reviews/; reports/; textures/
|
|
51
51
|
```
|
|
52
|
-
2. **No sheet yet?** Generate one with Codex image generation (`codex exec -m gpt-6.2-sol -c model_reasoning_effort=high -i <scene crop> -i <an approved sheet of the same scene>`, prompt via stdin). Ask for: the same layout and rendering style as the approved sheet, 5 labelled views at the same scale and camera height, a detail panel, palette and proportions, neutral soft studio light (not the scene's mood light), and weathering in the scene's language (name it: chips to primer with ragged edges at edges and corners, short rust drips under seams, grime only at the bottom). Look at the result before using it; regenerate if views disagree or are cropped.
|
|
52
|
+
2. **No sheet yet?** Generate one with Codex image generation (`codex exec -m gpt-6.2-sol -c model_reasoning_effort=high -i <scene crop> -i <an approved sheet of the same scene>`, prompt via stdin). Ask for: the same layout and rendering style as the approved sheet, 5 labelled views at the same scale and camera height, a detail panel, palette and proportions, neutral soft studio light (not the scene's mood light), and weathering in the scene's language (name it: chips to primer with ragged edges at edges and corners, short rust drips under seams, grime only at the bottom). Look at the result before using it; regenerate if views disagree or are cropped. Then check it against the scene concept and the style file: image models like to draw wear as a regular lattice of identical patches (a building sheet drew peeling plaster as a diamond grid) — a stamped pattern the style forbids. Keep the sheet for shape, layout and colour, and name the scene concept as the reference for the wear language in the description, so neither the builder nor the reviewer copies the stamp.
|
|
53
53
|
3. Cut the views: write `reference/boxes.json` ({view: [x0, y0, x1, y1]} in sheet pixels, include the whole object and a margin, exclude labels), run `python3 tools/crop.py`, LOOK at every crop.
|
|
54
54
|
4. View conventions (used by every studio): azimuth 0 = front (+Z), positive toward +X; `left` = −90 (the front edge appears on the RIGHT of the image), `right` = +90, `3q` = the sheet's 3/4 (estimate the azimuth from the visible front/side width ratio: tan(az) ≈ (W/D)·(side px/front px)). Elevation: 8–15° (top surfaces barely visible); all views share one elevation unless the sheet clearly differs.
|
|
55
55
|
|
|
56
56
|
## 2. Spec from pixels (geometry is measured, never eyeballed)
|
|
57
57
|
|
|
58
|
-
`python3 tools/measure_silhouette.py front --height <h>` (and `left`, `
|
|
58
|
+
`python3 tools/measure_silhouette.py front --height <h>` (and `back`, `left`, `right`) prints mm/px, the width profile by height and the largest dark/bright components with their positions in metres, already in object coordinates for that view (back mirrors x; side views report z). When only part of the height is known (a building: wall height known, roof not), measure with `--height 1` and scale by a known width. LOOK at the crop and name each component (opening, panel, window, button). Write `spec/object.json`:
|
|
59
59
|
- dimensions of the body and every visible part (metres; Y up, front +Z, ground y=0, x from the centre), counts (facets, shelves, slats, screws), edge radii;
|
|
60
60
|
- palette sampled from the concept (median of each paint zone, not your words);
|
|
61
61
|
- `cameras`: `fov_deg` 18, `elevation_deg`, `views` azimuths, `image` [560, 1100], `fill` 0.955 (object fills 95.5% of the image height, like the crops), `target_y`; `palette.background` = the sheet background.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Put the owner's hard numbers (overall size, floor heights, counts, "a wooden back door") in a `constraints` block of the spec, separate from measured values: they always win over the sheet, and a builder who finds the sheet disagreeing (a floor seam drawn at 3.45 m when floors are 3 m) follows the constraint and logs it, instead of guessing which to trust. Treat the measured part as a draft: a contact shadow inside the silhouette shifts heights by a few cm, top surfaces add height, AI sheets disagree between views. Builders must log deviations they find (Phase 4) instead of silently following a wrong number.
|
|
64
64
|
|
|
65
65
|
## 3. Wear description (the shared numeric target)
|
|
66
66
|
|
|
67
67
|
This is the step that replaced most of the owner's corrections. Do it once per object, before any building.
|
|
68
|
-
1. **Calibrate the masks.** Edit `reference/zones.json` (template: `assets/templates/zones.json`, filled example `zones_example_vending.json`): horizontal `bands` in metres over the whole silhouette (every view) and `front_rects` for key parts; chip rule (`dL`, `min_L`, `max_C`, `window_m`; for light paint where chips differ by hue: `mode: "hue"`), rust rule (`mode: "dark"` for red/orange paint, `"hue"` with an orange-brown hue range for other colours), grime hue range, `exclude_emissive` for glowing windows. Run `python3 tools/wear_stats.py`,
|
|
68
|
+
1. **Calibrate the masks.** Edit `reference/zones.json` (template: `assets/templates/zones.json`, filled example `zones_example_vending.json`): horizontal `bands` in metres over the whole silhouette (every view) and `front_rects` for key parts; chip rule (`dL`, `min_L`, `max_C`, `window_m`; for light paint where chips differ by hue: `mode: "hue"`), rust rule (`mode: "dark"` for red/orange paint, `"hue"` with an orange-brown hue range for other colours), grime hue range, `exclude_emissive` for glowing windows, `exclude_rects` per view for areas that are not surface (glazing with goods behind it, signs). For wear that is DARKER than the surface (peeling plaster or paint over a darker layer) use chip `mode: "dark"`: it compares with a high percentile (`ref_pct`, 80) of the wall in a wide window (`window_m` ~1 m), because a median is dragged down when a third of the wall is peeled. Run `python3 tools/wear_stats.py`, then `python3 tools/overlay_masks.py <out.png> [image_dir] [views]` (chips magenta, rust orange, grime green, excluded areas dimmed) and LOOK. Expect 3–4 iterations; never trust a mask you have not overlaid. Typical traps: chips larger than the paint window vanish (use a wide chip window), light paint makes chips "not lighter", bright paint or the background read as a glowing window, louvres and highlights read as chips.
|
|
69
69
|
2. **Write `brief/wear_description.md`** from the numbers AND your eyes on 2x crops (example: `assets/templates/wear_description_example.md`):
|
|
70
70
|
- the object in one paragraph (materials, paint zones, edge radii);
|
|
71
71
|
- a table per zone: chip % of area, rust %, grime %, character (where, which sizes);
|
|
72
72
|
- per part and per side: count and size classes of chips (small < 2 cm, medium 2–5, large ≥ 5 cm, with ranges), where they sit (edges vs faces), drip sources and lengths, edge-wear strength, special notes ("the door: drips matter more than wear", "back is not empty: 3–5 large flakes");
|
|
73
|
-
- the measurement caveats (what the masks over/under-count on this object);
|
|
73
|
+
- the measurement caveats (what the masks over/under-count on this object; zones a mask cannot judge, e.g. striped awnings or dark roofs, which the reviewer judges by eye). Coverage measurements saturate: where a patch is above ~40% of a local window the reference itself shifts and the number stops growing, so give ranges, and do not let a reviewer push a builder past what the eye shows;
|
|
74
74
|
- a short "do not" list.
|
|
75
75
|
3. **Rubric** `brief/rubric.json` (template `assets/templates/rubric.json`): keep the generic criteria (shape, paint, chips, edge_wear, drips, grime, style), replace `parts_*` with the object's key parts, weights sum to 1. The reviewer scores each 0–10; the script computes the weighted total, so scores are comparable between rounds.
|
|
76
76
|
|
|
@@ -85,8 +85,17 @@ What every builder must know (put it in the brief):
|
|
|
85
85
|
- **Textures**: optional, via `tools/gen_texture.sh <out> <WxH> <x|xy|none> "<description>"` (Codex image generation, concept attached). A generated texture is only the paint base: clean out baked chips, moss and stains (hue/lightness filter) so wear comes only from the procedural layer tied to geometry; discard a texture with 20%+ "chips".
|
|
86
86
|
- **Wear language**: `references/wear-language.md` (chips as flakes, edges first, drip clusters with bell-curve lengths, grime only low, dull marks) with implementations in `references/examples/` and in the scene's style library. Copy functions; keep the scene's language.
|
|
87
87
|
- **Self-check before any review**: 5-view sheets (`tools/sheet.py`), 2x close-ups of every part, `python3 tools/wear_stats.py out/<pipeline>` against `out/wear_stats_concept.json`, `python3 tools/metrics.py <pipeline>` (silhouette IoU ≥ 0.9 per view, zone ΔE).
|
|
88
|
+
- **Extra renders**: anything the 5 views cannot show (interiors as floor-plan cutaways, sections, close-ups of key parts) goes to `out/<pipeline>/extra_*.png`; the review attaches them with no concept counterpart.
|
|
88
89
|
- **Decisions log** `reviews/<pipeline>_decisions.md`: what was done and why, deliberate deviations from the spec or description. The reviewer reads it.
|
|
89
90
|
|
|
91
|
+
### Large and composite objects
|
|
92
|
+
|
|
93
|
+
A building, a kiosk or anything with an interior is still one asset for this skill, built from parts in one script; concept-scene-builder decomposes larger things (a street block) before calling it.
|
|
94
|
+
- Spec: give the plan (rooms, stairs, partitions with door openings) next to the façades; interiors that are not visible from outside still need correct geometry (walls never cross windows, openings are walkable) and are judged from the extra cutaway renders.
|
|
95
|
+
- Framing: set `cameras.image` wider than tall (e.g. 1400 × 1000) for wide objects; the studios fit both axes.
|
|
96
|
+
- Performance: repeated elements (roof tiles, slats, bricks) as arrays/instances, not thousands of unique objects.
|
|
97
|
+
- Expect about twice the time of a small prop (the shop: ~2.5 h for one builder and 3 review rounds) and the same ceiling: massing, roof and openings reach 8–9, stains and grime stay around 6–8.
|
|
98
|
+
|
|
90
99
|
## 5. Review loop
|
|
91
100
|
|
|
92
101
|
`tools/codex_review.sh <pipeline> <round>` (rounds 1..max_review_rounds; 3–10 minutes; run in the background and wait). The reviewer is a different model (Codex gpt-6.2-sol, high, read-only sandbox) with no context but: concept|render sheets per view, 2x close-ups, the description, the scene style, the rubric, the measurements of both, its own previous review and the builder's decisions log. It must keep its earlier requirements unless it explains why, and report fixed/improved/open for its previous top list. Output: `reviews/<pipeline>_r<n>.md` and `.json` with the weighted total.
|
|
@@ -16,7 +16,8 @@ pipeline; never touch its files or anything outside the workspace.
|
|
|
16
16
|
|
|
17
17
|
## Inputs (read only)
|
|
18
18
|
- `reference/concept.png`, `reference/crops/{3q,front,back,left,right,detail}.png` — look at them at 2x.
|
|
19
|
-
- `spec/object.json` — measured geometry, palette, cameras.
|
|
19
|
+
- `spec/object.json` — measured geometry, palette, cameras. Its `constraints` block holds the owner's hard numbers:
|
|
20
|
+
they always win over the sheet. The measured rest is a draft: if you find a clear error, do not edit the spec;
|
|
20
21
|
log the deviation in `reviews/<PIPELINE>_decisions.md` and apply it in your code.
|
|
21
22
|
- `brief/wear_description.md` — numeric target per zone, part and side (source of truth for the surface).
|
|
22
23
|
- `brief/scene_style.md` — scene style rules (mandatory). `brief/rubric.json` — how the reviewer scores you.
|
|
@@ -43,7 +44,9 @@ Blender (x, -z, y)); finish with `studio.setup(SPEC); studio.save(ROOT, "object"
|
|
|
43
44
|
## Process
|
|
44
45
|
1. Study the concept, spec, description, style. Write your plan into the report: parts, materials, how you do wear.
|
|
45
46
|
2. Geometry (all edges rounded, nothing intersects or floats) → materials → wear → render 5 views → self-check
|
|
46
|
-
(sheets, 2x close-ups of every part, measurements, IoU/ΔE).
|
|
47
|
+
(sheets, 2x close-ups of every part, `tools/overlay_masks.py` on your renders, measurements, IoU/ΔE).
|
|
48
|
+
Render what the 5 views cannot show (interior cutaways, sections, close-ups) to `out/<PIPELINE>/extra_*.png`;
|
|
49
|
+
the reviewer receives them.
|
|
47
50
|
3. Keep `reviews/<PIPELINE>_decisions.md` up to date (the reviewer reads it).
|
|
48
51
|
4. Review rounds 1..<N> with fixes after each; stop early at a weighted score ≥ <TARGET>. After the last round only
|
|
49
52
|
obvious small fixes.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
- Post box, hand-iterated with the owner: silhouette IoU 0.84 → 0.96 after measuring; independent reviewer 4–6.5 → 7.5/10 over 3 rounds; the owner still found 7 issues per round for 3 more rounds, mostly wear.
|
|
5
5
|
- Post box, agents + Codex reviewer, no owner: three.js 5 → 7, Blender 6 → 6.5 (reviewer v1, no rubric, no memory).
|
|
6
6
|
- Vending machine from scratch through the conveyor (style file + reviewer v2): Blender 6.3 → 6.9 → 7.1 → 7.2, three.js 6.25 → 6.85 → 6.9 → 6.9; none of the pilot's owner complaints repeated. Shape 8–9, paint 8, parts 7–8, chips 6, drips 5–6.
|
|
7
|
+
- Two-storey shop (8 × 6 m, rooms inside), one Blender builder, ~2.5 h: 6.99 → 7.44 → 7.87, final 7.92; shape and interior 9, roof/shop front/openings/plaster 8, stains 6. Accepted by the owner without remarks.
|
|
7
8
|
|
|
8
9
|
## Measuring
|
|
9
10
|
- Geometry measured from pixels beat eyeballing immediately (IoU 0.84–0.93 on the first build). The two corrections later were base height (a contact shadow is part of the silhouette) and body radius.
|
|
@@ -12,13 +13,21 @@
|
|
|
12
13
|
- Silhouette masks must exclude the ground shadow (background scaled by a near-constant factor).
|
|
13
14
|
- Colour statistics matching is not the look matching; the reviewer and close-ups decide.
|
|
14
15
|
|
|
16
|
+
- Wear darker than the surface (peeling plaster over a darker layer) was invisible to a "lighter than the paint" chip mask; with a median reference it caught only patch edges, because a third of the wall was peeled. A high-percentile reference in a ~1 m window fixed it; goods behind shop glazing read as "moss" until the glazing was excluded per view.
|
|
17
|
+
- Coverage saturates above ~40% of a local window: the builder could not raise the measured number further even when the eye said enough. Give ranges and trust the overlay.
|
|
18
|
+
- Back and side positions written in image coordinates mirrored a whole façade; measure in object coordinates per view.
|
|
19
|
+
- Owner constraints (8 × 6 m, 3 m floors) disagreed with the generated sheet (a floor seam at 3.45 m); without a separate constraints block the builder had to decide which to trust.
|
|
20
|
+
|
|
15
21
|
## Reviewers
|
|
16
22
|
- Without a rubric and memory, the reviewer contradicted itself between rounds ("lips overloaded" → "lips too fresh") and gave the same score four times while major issues dropped from 9 to 6. A weighted rubric computed by a script + the previous review + the builder's decisions log fixed it: monotonic scores, no reversals.
|
|
17
23
|
- A reviewer of the same model that also built the thing anchors on its intentions; use another model or a fresh context with only the inputs.
|
|
18
24
|
- The reviewer trusts numbers it is given; give it only numbers you have validated by overlay.
|
|
19
25
|
- The owner's eye still catches things the reviewer does not (mould on a hood, a too-white sign, a door that reads noisy, sharp three.js edges). Keep the owner checkpoint on the pilot and on wear.
|
|
20
26
|
|
|
27
|
+
- The reviewer can only judge what it sees: an interior got a 9 only because the builder rendered floor-plan cutaways and a section through the stair as extra images.
|
|
28
|
+
|
|
21
29
|
## Textures from image models
|
|
30
|
+
- A generated asset sheet drew peeling plaster as a regular diamond lattice: shape and layout were usable, the wear was a stamp. Name the scene concept as the wear reference.
|
|
22
31
|
- Albedo textures from Codex image generation are good paint bases but bake in chips, moss, stains and "panel seams". One cap texture had 23% chips (concept ~8%) and was unusable. Clean with hue/lightness filters; never let the texture carry the wear.
|
|
23
32
|
- Box-projected textures sample random parts of a texture: a cap's top faces sampled the mossy bottom band → "mould on the cap". Map each part to a clean band of the texture.
|
|
24
33
|
|
|
@@ -52,8 +52,10 @@ def fit(az_deg):
|
|
|
52
52
|
d = 5.0
|
|
53
53
|
for _ in range(6):
|
|
54
54
|
place(az_deg, d)
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
pts = [world_to_camera_view(scene, cam, c) for c in corners]
|
|
56
|
+
ys = [q.y for q in pts]; xs = [q.x for q in pts]
|
|
57
|
+
# fit BOTH axes: a wide object (a building in 3/4) would otherwise leave the frame sideways
|
|
58
|
+
ext = max(max(ys) - min(ys), max(xs) - min(xs))
|
|
57
59
|
d *= ext / fill
|
|
58
60
|
place(az_deg, d)
|
|
59
61
|
# centre vertically
|
|
@@ -30,6 +30,8 @@ for v, fr, n in (("front", (0.0, 0.0, 1.0, 0.5), "detail_front_top"), ("front",
|
|
|
30
30
|
s = Image.new("RGB", (a.width + b.width + 16, max(a.height, b.height)), "black"); s.paste(a, (0, 0)); s.paste(b, (a.width + 16, 0))
|
|
31
31
|
s.save(f"{base}_{n}.png")
|
|
32
32
|
PY
|
|
33
|
+
# builder's extra renders (e.g. interior cutaways, close-ups) have no concept counterpart: attach them as they are
|
|
34
|
+
for f in "$ROOT/out/$PIPE"/extra_*.png; do [ -f "$f" ] && cp "$f" "$IMG/${TAG}_$(basename "$f")"; done
|
|
33
35
|
STATS_C=$(python3 "$ROOT/tools/wear_stats.py" 2>/dev/null | sed -n '/^\[/,$p')
|
|
34
36
|
STATS_R=$(python3 "$ROOT/tools/wear_stats.py" "$ROOT/out/$PIPE" 2>/dev/null | sed -n '/^\[/,$p')
|
|
35
37
|
PREV_TXT="(none: first round)"; [ -f "$ROOT/reviews/${PIPE}_r${PREV}.md" ] && PREV_TXT=$(cat "$ROOT/reviews/${PIPE}_r${PREV}.md")
|
|
@@ -40,7 +42,8 @@ command codex exec -m "$MODEL" -c model_reasoning_effort=high --skip-git-repo-ch
|
|
|
40
42
|
-C "$ROOT" "${IMGS[@]}" -o "$ROOT/reviews/${TAG}.md" > "$ROOT/reviews/${TAG}.log" 2>&1 <<PROMPT
|
|
41
43
|
You are an independent art reviewer. Your only context is this message and the attached images.
|
|
42
44
|
Images *_<view>.png: LEFT the reference concept, RIGHT a 3D render of the same object (views 3q, front, back, left, right).
|
|
43
|
-
*_detail_*.png: 2x close-ups, LEFT concept, RIGHT render.
|
|
45
|
+
*_detail_*.png: 2x close-ups, LEFT concept, RIGHT render. *_extra_*.png (if any): the builder's extra renders
|
|
46
|
+
(interior cutaways, close-ups) with no concept counterpart; judge them against the description. Lighting and camera are fixed by the studio and NOT under review.
|
|
44
47
|
|
|
45
48
|
OBJECT AND WEAR DESCRIPTION (source of truth, Russian):
|
|
46
49
|
$(cat "$ROOT/brief/wear_description.md")
|
|
@@ -106,9 +106,12 @@ func _run() -> void:
|
|
|
106
106
|
for i in 6:
|
|
107
107
|
_place(az, el, d, target)
|
|
108
108
|
var ys: Array = []
|
|
109
|
+
var xs: Array = []
|
|
109
110
|
for p in corners:
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
var q := cam.unproject_position(p)
|
|
112
|
+
ys.append(q.y); xs.append(q.x)
|
|
113
|
+
# fit BOTH axes: a wide object would otherwise leave the frame sideways
|
|
114
|
+
var ext: float = maxf((ys.max() - ys.min()) / size.y, (xs.max() - xs.min()) / size.x)
|
|
112
115
|
d *= ext / fill
|
|
113
116
|
_place(az, el, d, target)
|
|
114
117
|
for i in 4:
|
|
@@ -6,7 +6,7 @@ SK="$(cd "$(dirname "$0")" && pwd)"
|
|
|
6
6
|
W="$1"; C="$2"; STYLE="${3:-}"
|
|
7
7
|
mkdir -p "$W"/{reference/crops,spec,brief,tools,blender,threejs,out,reviews,reports,textures}
|
|
8
8
|
cp "$C" "$W/reference/concept.png"
|
|
9
|
-
cp "$SK"/{metrics.py,sheet.py,wear_stats.py,codex_review.sh,gen_texture.sh,capture.mjs,crop.py,measure_silhouette.py,compare_to.py,composite_godot.py} "$W/tools/"
|
|
9
|
+
cp "$SK"/{metrics.py,sheet.py,wear_stats.py,overlay_masks.py,codex_review.sh,gen_texture.sh,capture.mjs,crop.py,measure_silhouette.py,compare_to.py,composite_godot.py} "$W/tools/"
|
|
10
10
|
chmod +x "$W/tools/"*.sh
|
|
11
11
|
cp "$SK/blender/"{studio.py,render_views.py,bake_export.py} "$W/blender/"
|
|
12
12
|
cp "$SK/threejs/"{studio.js,index.html,model.js} "$W/threejs/"
|
|
@@ -4,7 +4,11 @@ Usage: python3 tools/measure_silhouette.py <view> --height <m> [--rows 24] [--da
|
|
|
4
4
|
<view>: front|back|left|right|3q (reference/crops/<view>.png)
|
|
5
5
|
Prints: silhouette bbox, metres per pixel, the width profile (row by row, metres from the ground),
|
|
6
6
|
and the largest dark / bright components (openings, panels, glowing windows, buttons) in metres:
|
|
7
|
-
height range from the ground and
|
|
7
|
+
height range from the ground and the horizontal range in OBJECT coordinates (spec convention: front +Z, +X to the
|
|
8
|
+
object's right as seen from the front): front -> x as in the image; back -> x mirrored (the image's left is +x);
|
|
9
|
+
left view (camera at -X, front on the image's right) -> z = image offset; right view -> z mirrored; 3q -> image
|
|
10
|
+
offset only (not an object axis). Writing back/side positions in image coordinates was a real bug (a mirrored
|
|
11
|
+
back façade). Read them, then LOOK at the crop
|
|
8
12
|
and decide what each component is. Watch out: a contact shadow under the object belongs to the silhouette
|
|
9
13
|
(subtract it from heights), and the top surface seen from the camera adds a little to the height.
|
|
10
14
|
"""
|
|
@@ -24,12 +28,21 @@ img = M.load(M.ROOT / f"reference/crops/{a.view}.png")
|
|
|
24
28
|
m = M.mask_of(img)
|
|
25
29
|
y0, y1, x0, x1 = M.bbox(m)
|
|
26
30
|
mpp = a.height / (y1 - y0); cx = (x0 + x1) / 2
|
|
31
|
+
AXIS, SIGN = {"front": ("x", 1), "back": ("x", -1), "left": ("z", 1), "right": ("z", -1)}.get(a.view, ("image x", 1))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def span(p0, p1):
|
|
35
|
+
"""image pixel range -> sorted object-axis range in metres"""
|
|
36
|
+
u0, u1 = SIGN * (p0 - cx) * mpp, SIGN * (p1 - cx) * mpp
|
|
37
|
+
return min(u0, u1), max(u0, u1)
|
|
27
38
|
print(f"bbox y {y0}-{y1} x {x0}-{x1}; {mpp * 1000:.2f} mm/px; width {(x1 - x0) * mpp:.3f} m; aspect {(x1 - x0) / (y1 - y0):.3f}")
|
|
28
|
-
print("
|
|
39
|
+
print(f"view {a.view}: horizontal positions are {AXIS} in object coordinates" + ("" if AXIS != "image x" else " (3/4 view: image offset, not an object axis)"))
|
|
40
|
+
print("width profile (height from ground m: width m, range):")
|
|
29
41
|
for y in np.linspace(y0, y1 - 1, a.rows).astype(int):
|
|
30
42
|
r = np.where(m[y])[0]
|
|
31
43
|
if len(r):
|
|
32
|
-
|
|
44
|
+
lo, hi = span(r.min(), r.max())
|
|
45
|
+
print(f" {(y1 - y) * mpp:6.3f}: {(r.max() - r.min()) * mpp:.3f} {AXIS} [{lo:+.3f}, {hi:+.3f}]")
|
|
33
46
|
L = img.mean(2)
|
|
34
47
|
for name, mask in (("dark", (L < a.dark) & m), ("bright", (img[..., 1] > a.bright) & (img[..., 2] > a.bright) & m)):
|
|
35
48
|
lab, n = ndi.label(ndi.binary_closing(mask, iterations=2))
|
|
@@ -37,4 +50,5 @@ for name, mask in (("dark", (L < a.dark) & m), ("bright", (img[..., 1] > a.brigh
|
|
|
37
50
|
key=lambda s: -(s[0].stop - s[0].start) * (s[1].stop - s[1].start))[:8]
|
|
38
51
|
print(f"{name} components (largest first):")
|
|
39
52
|
for s in comps:
|
|
40
|
-
|
|
53
|
+
lo, hi = span(s[1].start, s[1].stop)
|
|
54
|
+
print(f" y {(y1 - s[0].stop) * mpp:.3f}-{(y1 - s[0].start) * mpp:.3f} m {AXIS} {lo:+.3f}..{hi:+.3f} m")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Overlay the wear masks of tools/wear_stats.py on images: chips magenta, rust orange, grime green, excluded areas dimmed.
|
|
2
|
+
Usage: python3 tools/overlay_masks.py <out.png> [image_dir] [views] (default reference/crops, 3q,front,back,left)"""
|
|
3
|
+
import sys, pathlib
|
|
4
|
+
import numpy as np
|
|
5
|
+
from PIL import Image
|
|
6
|
+
HERE = pathlib.Path(__file__).resolve().parent
|
|
7
|
+
sys.path.insert(0, str(HERE))
|
|
8
|
+
import metrics as M
|
|
9
|
+
src_code = (HERE / "wear_stats.py").read_text().split("\nres = {}")[0]
|
|
10
|
+
src_code = src_code.replace('src = pathlib.Path(sys.argv[1]) if len(sys.argv) > 1 else ROOT / "reference/crops"', 'src = None')
|
|
11
|
+
ns = {"__file__": str(HERE / "wear_stats.py")}
|
|
12
|
+
exec(compile(src_code, "wear_stats", "exec"), ns)
|
|
13
|
+
out = sys.argv[1]
|
|
14
|
+
d = pathlib.Path(sys.argv[2]) if len(sys.argv) > 2 else M.ROOT / "reference/crops"
|
|
15
|
+
views = sys.argv[3].split(",") if len(sys.argv) > 3 else ["3q", "front", "back", "left"]
|
|
16
|
+
tiles = []
|
|
17
|
+
for v in views:
|
|
18
|
+
img = ns["normalise"](M.load(d / f"{v}.png")); sil = M.mask_of(img); y0, y1, x0, x1 = M.bbox(sil)
|
|
19
|
+
ns["VIEW"] = v; chip, rust, grime, keep = ns["masks"](img, ns["H"] / (y1 - y0), sil)
|
|
20
|
+
vis = img.copy(); vis[chip] = [255, 0, 200]; vis[rust] = [255, 140, 0]; vis[grime] = [0, 200, 0]
|
|
21
|
+
vis[~keep & sil] = vis[~keep & sil] * 0.4
|
|
22
|
+
tiles.append(Image.fromarray(np.concatenate([img, vis], 1).clip(0, 255).astype(np.uint8)))
|
|
23
|
+
W = sum(t.width for t in tiles) + 10 * (len(tiles) - 1); s = Image.new("RGB", (W, max(t.height for t in tiles)), "black"); x = 0
|
|
24
|
+
for t in tiles: s.paste(t, (x, 0)); x += t.width + 10
|
|
25
|
+
s.save(out); print(out, s.size)
|
|
@@ -50,6 +50,9 @@ class ToolsTest(unittest.TestCase):
|
|
|
50
50
|
for x in range(x0 + 40, x0 + 52):
|
|
51
51
|
for y in range(100, 116):
|
|
52
52
|
px[x, y] = (226, 205, 176)
|
|
53
|
+
for x in range(x0 + 20, x0 + 35): # a dark opening left of the centre, for view-aware measurement
|
|
54
|
+
for y in range(60, 80):
|
|
55
|
+
px[x, y] = (40, 40, 40)
|
|
53
56
|
self.boxes[v] = [x0, 20, x0 + 100, 260]
|
|
54
57
|
self.concept = self.dir / "sheet.png"
|
|
55
58
|
sheet.save(self.concept)
|
|
@@ -102,6 +105,47 @@ class ToolsTest(unittest.TestCase):
|
|
|
102
105
|
self.assertGreater(res["front"]["all"]["chip_pct"], 0.5)
|
|
103
106
|
self.assertEqual(res["front"]["all"]["chips"]["count"], 1)
|
|
104
107
|
|
|
108
|
+
def test_measure_silhouette_uses_object_coordinates_per_view(self):
|
|
109
|
+
def first_dark(view):
|
|
110
|
+
out = run(sys.executable, "-B", "tools/measure_silhouette.py", view, "--height", "2.0", cwd=self.ws).stdout
|
|
111
|
+
line = out.split("dark components")[1].splitlines()[1]
|
|
112
|
+
axis, rng = line.split("m")[1].split()[0], line.split()[-2]
|
|
113
|
+
return axis, float(rng.split("..")[0]), float(rng.split("..")[1])
|
|
114
|
+
# the opening sits left of the image centre: front -> -x, back -> +x (mirrored), left -> -z, right -> +z
|
|
115
|
+
ax, lo, hi = first_dark("front"); self.assertEqual(ax, "x"); self.assertLess(hi, 0)
|
|
116
|
+
ax, lo, hi = first_dark("back"); self.assertEqual(ax, "x"); self.assertGreater(lo, 0)
|
|
117
|
+
ax, lo, hi = first_dark("left"); self.assertEqual(ax, "z"); self.assertLess(hi, 0)
|
|
118
|
+
ax, lo, hi = first_dark("right"); self.assertEqual(ax, "z"); self.assertGreater(lo, 0)
|
|
119
|
+
|
|
120
|
+
@unittest.skipUnless(HAVE_SCIPY, "scipy is required")
|
|
121
|
+
def test_dark_mode_finds_peeling_and_exclusions_remove_it(self):
|
|
122
|
+
wall = Image.new("RGB", (100, 240), BG)
|
|
123
|
+
wp = wall.load()
|
|
124
|
+
for x in range(10, 90):
|
|
125
|
+
for y in range(40, 240):
|
|
126
|
+
wp[x, y] = (232, 200, 158) # light stucco
|
|
127
|
+
for x in range(25, 55):
|
|
128
|
+
for y in range(90, 140):
|
|
129
|
+
wp[x, y] = (196, 146, 100) # darker exposed plaster
|
|
130
|
+
wall.save(self.ws / "reference/crops/front.png")
|
|
131
|
+
zones = json.loads((self.ws / "reference/zones.json").read_text())
|
|
132
|
+
zones.update({"height_m": 2.0, "bands": {"all": [0.0, 2.0]},
|
|
133
|
+
"chip": {"mode": "dark", "dL": 8, "min_L": 50, "min_C": 15, "max_C": 60, "window_m": 0.8, "ref_pct": 80}})
|
|
134
|
+
(self.ws / "reference/zones.json").write_text(json.dumps(zones))
|
|
135
|
+
run(sys.executable, "-B", "tools/wear_stats.py", cwd=self.ws)
|
|
136
|
+
peel = json.loads((self.ws / "out/wear_stats_concept.json").read_text())["front"]["all"]["chip_pct"]
|
|
137
|
+
self.assertGreater(peel, 5.0) # the patch is ~9% of the wall
|
|
138
|
+
zones["exclude_rects"] = {"front": [[-1.0, 1.0, 0.0, 2.0]]}
|
|
139
|
+
(self.ws / "reference/zones.json").write_text(json.dumps(zones))
|
|
140
|
+
run(sys.executable, "-B", "tools/wear_stats.py", cwd=self.ws)
|
|
141
|
+
self.assertNotIn("all", json.loads((self.ws / "out/wear_stats_concept.json").read_text())["front"])
|
|
142
|
+
|
|
143
|
+
@unittest.skipUnless(HAVE_SCIPY, "scipy is required")
|
|
144
|
+
def test_overlay_masks_writes_an_image(self):
|
|
145
|
+
run(sys.executable, "-B", "tools/overlay_masks.py", "out/overlay.png", "reference/crops", "front,back", cwd=self.ws)
|
|
146
|
+
im = Image.open(self.ws / "out/overlay.png")
|
|
147
|
+
self.assertGreater(im.width, im.height)
|
|
148
|
+
|
|
105
149
|
def test_sheet_builds_concept_render_pairs(self):
|
|
106
150
|
(self.ws / "out/blender").mkdir(parents=True)
|
|
107
151
|
for v in VIEWS:
|
|
@@ -135,12 +135,14 @@ export function createStudio(spec, container = document.body, opts = {}) {
|
|
|
135
135
|
camera.position.copy(target).addScaledVector(dir, dist);
|
|
136
136
|
camera.lookAt(target);
|
|
137
137
|
camera.updateMatrixWorld();
|
|
138
|
-
let ymin = Infinity, ymax = -Infinity;
|
|
138
|
+
let ymin = Infinity, ymax = -Infinity, xmin = Infinity, xmax = -Infinity;
|
|
139
139
|
for (const c of corners) {
|
|
140
140
|
const p = c.clone().project(camera);
|
|
141
141
|
ymin = Math.min(ymin, p.y); ymax = Math.max(ymax, p.y);
|
|
142
|
+
xmin = Math.min(xmin, p.x); xmax = Math.max(xmax, p.x);
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
+
// fit BOTH axes: a wide object (a building in 3/4) would otherwise leave the frame sideways
|
|
145
|
+
dist *= Math.max(ymax - ymin, xmax - xmin) / (2 * fill);
|
|
144
146
|
// recentre vertically: shift target along camera up by the NDC offset
|
|
145
147
|
const mid = (ymax + ymin) / 2;
|
|
146
148
|
const halfH = Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) * dist;
|
|
@@ -7,9 +7,11 @@ Config: reference/zones.json
|
|
|
7
7
|
front_rects: {name: [x0, x1, y0, y1]} metres, x from the silhouette centre; front view only
|
|
8
8
|
chip: {dL, min_L, max_C, window_m} chip = lighter than the local paint by dL, L > min_L, chroma < max_C
|
|
9
9
|
or {mode: "hue", paint_hue: [h0, h1], neutral_C, min_L, max_C} for light paint: chip = not the paint hue
|
|
10
|
+
or {mode: "dark", dL, min_L, min_C, max_C, window_m} peeling over a darker layer (plaster): darker than the wall
|
|
10
11
|
rust: {mode: "dark"|"hue", hue: [h0, h1], min_C, dL} hue mode: orange-brown hue range (for non-red paint)
|
|
11
12
|
grime: {hue: [h0, h1], min_C, max_L} olive grime
|
|
12
13
|
exclude_emissive: true drop the glowing window (and what is inside it) from all measurements
|
|
14
|
+
exclude_rects: {view: [[x0, x1, y0, y1], ...]} metres; areas that are not surface (glazing, signs) per view
|
|
13
15
|
All images are resampled so the silhouette is 527 px tall; windows are in metres; vertical components longer
|
|
14
16
|
than 0.2 m are dropped from rust (edges/grooves, not drips).
|
|
15
17
|
"""
|
|
@@ -35,6 +37,15 @@ def normalise(img):
|
|
|
35
37
|
return np.asarray(im).astype(np.float32)
|
|
36
38
|
|
|
37
39
|
|
|
40
|
+
def up(a, shape):
|
|
41
|
+
"""bilinear upsample of a downscaled reference back to full size (block upsampling shifted the chip counts)"""
|
|
42
|
+
z = ndi.zoom(a, (shape[0] / a.shape[0], shape[1] / a.shape[1]), order=1)
|
|
43
|
+
out = np.empty(shape, z.dtype); h, w = min(shape[0], z.shape[0]), min(shape[1], z.shape[1])
|
|
44
|
+
out[:h, :w] = z[:h, :w]; out[h:, :] = out[h - 1:h, :] if h < shape[0] else out[h:, :]
|
|
45
|
+
out[:, w:] = out[:, w - 1:w] if w < shape[1] else out[:, w:]
|
|
46
|
+
return out
|
|
47
|
+
|
|
48
|
+
|
|
38
49
|
def masks(img, mpp, sil):
|
|
39
50
|
lab = M.srgb_to_lab(img); L, a, b = lab[..., 0], lab[..., 1], lab[..., 2]
|
|
40
51
|
C = np.hypot(a, b); hue = np.degrees(np.arctan2(b, a)) % 360
|
|
@@ -42,8 +53,25 @@ def masks(img, mpp, sil):
|
|
|
42
53
|
Lloc = ndi.median_filter(L, size=win)
|
|
43
54
|
ch = Z.get("chip", {}); dL, minL, maxC = ch.get("dL", 10), ch.get("min_L", 55), ch.get("max_C", 38)
|
|
44
55
|
# chips can be larger than the rust window: compare with a wider (8 cm) paint neighbourhood
|
|
45
|
-
|
|
56
|
+
if ch.get("mode") == "dark":
|
|
57
|
+
Lchip = Lloc # the dark mode builds its own percentile reference below
|
|
58
|
+
else:
|
|
59
|
+
# chips can be larger than the rust window: compare with a wider paint neighbourhood (at 1/k scale if wide)
|
|
60
|
+
wpx = ch.get("window_m", 0.08) / mpp
|
|
61
|
+
kk = max(1, int(np.ceil(wpx / 60))) # full resolution up to a 60 px window (keeps calibrated numbers)
|
|
62
|
+
Lchip = ndi.median_filter(L[::kk, ::kk], size=max(3, int(round(wpx / kk)) | 1))
|
|
63
|
+
Lchip = up(Lchip, L.shape) if kk > 1 else Lchip
|
|
46
64
|
chip = (L > np.minimum(Lloc, Lchip) + dL) & (L > minL) & (C < maxC)
|
|
65
|
+
if ch.get("mode") == "dark":
|
|
66
|
+
# peeling plaster / paint over a DARKER layer: compare with the intact wall = a high percentile of L in a wide
|
|
67
|
+
# window (when peeling covers a third of the wall the median itself is dragged down); computed at 1/4 scale
|
|
68
|
+
# downscale so the window stays <= ~25 px: percentile filters cost O(window^2) per pixel
|
|
69
|
+
win_px = ch.get("window_m", 1.0) / mpp
|
|
70
|
+
k = max(4, int(np.ceil(win_px / 25)))
|
|
71
|
+
win = max(3, int(round(win_px / k)) | 1)
|
|
72
|
+
ref = ndi.percentile_filter(L[::k, ::k], ch.get("ref_pct", 80), size=win)
|
|
73
|
+
ref = up(ref, L.shape)
|
|
74
|
+
chip = (L < ref - dL) & (L > minL) & (C > ch.get("min_C", 0)) & (C < maxC)
|
|
47
75
|
if ch.get("mode") == "hue":
|
|
48
76
|
# light paint: chips are not much lighter, they differ by hue (warm/neutral primer vs the paint hue)
|
|
49
77
|
ph0, ph1 = ch["paint_hue"]
|
|
@@ -70,6 +98,11 @@ def masks(img, mpp, sil):
|
|
|
70
98
|
if win_m.any():
|
|
71
99
|
ys, xs = np.where(win_m); win_m[ys.min():ys.max() + 1, xs.min():xs.max() + 1] = True
|
|
72
100
|
keep &= ~win_m
|
|
101
|
+
for xa, xb, ya, yb in Z.get("exclude_rects", {}).get(VIEW, []):
|
|
102
|
+
# per-view rectangles (metres, x from the silhouette centre) that are not surface: glazing, signs
|
|
103
|
+
ys, xs = np.where(sil)
|
|
104
|
+
y1, cx = ys.max() + 1, (xs.min() + xs.max() + 1) / 2
|
|
105
|
+
keep[max(0, int(y1 - yb / mpp)):int(y1 - ya / mpp), max(0, int(cx + xa / mpp)):int(cx + xb / mpp)] = False
|
|
73
106
|
lab_, n = ndi.label(rust)
|
|
74
107
|
for i, sl in enumerate(ndi.find_objects(lab_), 1):
|
|
75
108
|
if sl is not None and (sl[0].stop - sl[0].start) * mpp > 0.20:
|
|
@@ -106,6 +139,7 @@ for v in M.VIEWS:
|
|
|
106
139
|
continue
|
|
107
140
|
img = normalise(M.load(p)); sil = M.mask_of(img); y0, y1, x0, x1 = M.bbox(sil); mpp = H / (y1 - y0)
|
|
108
141
|
sil = ndi.binary_erosion(sil, iterations=3)
|
|
142
|
+
VIEW = v
|
|
109
143
|
chip, rust, grime, keep = masks(img, mpp, sil)
|
|
110
144
|
rv = {}
|
|
111
145
|
for z, (a, b) in Z["bands"].items():
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-manifesto-kit",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "CLI to discover and adopt Agent Manifesto Kit capabilities (skills, agents, pipelines) into your project for Claude, Codex, or AI-agnostic targets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|