Skip to content

feat(ll_brepnet): B-Rep face-segmentation package — trained (test mIoU 0.71)#14

Merged
LayerDynamics merged 2 commits into
mainfrom
feat/ll-brepnet-impl
Jun 10, 2026
Merged

feat(ll_brepnet): B-Rep face-segmentation package — trained (test mIoU 0.71)#14
LayerDynamics merged 2 commits into
mainfrom
feat/ll-brepnet-impl

Conversation

@LayerDynamics

Copy link
Copy Markdown
Collaborator

What this is

Turns the empty ll_brepnet/ scaffold into a working, trained B-Rep
face-segmentation package
— STEP solid → coedge graph + UV-grid geometry →
per-face semantic segmentation. Built across 8 verified milestones (M0–M7).

It is an independent, MIT-licensed implementation on the toolkit's own MIT
machinery (cadling). It is inspired by BRepNet
(arXiv:2104.00706, licensed CC BY-NC-SA) and
UV-Net, but copies no code from them — see ll_brepnet/ATTRIBUTION.md. The
architecture deliberately uses the monorepo's existing coedge encoder rather
than BRepNet's kernel convolution, keeping the package MIT.

Result (real, reproducible)

Trained on a real subset of the Fusion 360 Gallery segmentation set (s2.0.0)
3,400 train / 600 val / 800 test solids, official 8 manufacturing-feature classes
and train/test split, 35 epochs CPU.

Held-out test split (800 real solids): mIoU = 0.709, accuracy = 0.912.

Per-class IoU: Fillet 0.94 · ExtrudeSide 0.89 · ExtrudeEnd 0.86 · Chamfer 0.84 ·
CutEnd 0.71 · RevolveSide 0.66 · CutSide 0.66 · RevolveEnd 0.11. Competitive with
the BRepNet paper's reported ~0.65–0.72 mIoU.

Honest scope: a subset of the full 35,680 solids, bounded CPU epochs. The
rare RevolveEnd class (IoU 0.11) is under-represented in the subset. The package
ships the training/eval code, not a production checkpoint.

Milestones

M0 Package scaffold, MIT LICENSE+ATTRIBUTION, OpenMP-guarded conftest
M1 pipelines/: STEP → coedge graph + features + UV-grids → .npz; manifest builder; JSON front-end; parallel extraction
M2 dataloaders/: BRepDataset, offset-aware collate (mate involution survives batching), face-count sampler, BRepDataModule
M3 models/: UV-Net surface/curve encoders + reused coedge BRepNetEncoder + per-face seg head
M4 train.py: pytorch-lightning Trainer + checkpoint/TensorBoard
M5 Fusion 360 quickstart orchestration + the real training run above
M6 eval/: evaluate_folder — checkpoint + STEP folder → per-face .logits
M7 21 tests, lazy public API, root-env wiring, docs site flip

Verification

  • 21/21 tests pass on real STEP fixtures (extraction topology/grids, dataset+collate offset & mate-survival, model forward/learning, JSON front-end, slow end-to-end segment).
  • ruff + black clean across the package (22 files).
  • Docs site builds, all internal links valid; the roadmap "Planned" page is flipped to real Overview/Installation/Usage pages.
  • No stubs, no fabricated metrics, no NC-SA code copied.

Note on cadling

While building this I found two latent cadling bugs on pythonocc 7.8
(ShapeIdentityRegistry registered nothing; face UV-grids always failed).
ll_brepnet is self-contained and works around both, so this PR is independent.
The underlying fixes are in #13 (fix/cadling-pythonocc-7.8).

Plan: docs/plans/2026-06-10-implement-ll-brepnet.md.

🤖 Generated with Claude Code

LayerDynamics and others added 2 commits June 10, 2026 11:34
Turn the empty ll_brepnet scaffold into a working, MIT-clean B-Rep
face-segmentation package, verified end-to-end on real STEP fixtures.
Independent implementation on the toolkit's own MIT machinery; inspired
by BRepNet (arXiv:2104.00706) but no CC BY-NC-SA code copied (see
ll_brepnet/ATTRIBUTION.md).

- M0 scaffold: pyproject/env/__init__/conftest (torch-first OpenMP guard),
  MIT LICENSE + ATTRIBUTION; installs + imports; ruff/black clean.
- M1 extraction (pipelines/): STEP -> unit-box scale -> coedge graph
  (next/prev/mate/face/edge incidence via cadling CoedgeExtractor) +
  per-face/edge features + UV-grids -> .npz; manifest builder with
  train-only standardization; JSON front-end. Self-contained indexing +
  uvgrid("inside") trim mask to bypass two latent cadling pythonocc-7.8
  bugs (face_identity topods import; uv_grid_extractor numpy gp_Pnt2d).
- M2 dataset (dataloaders/): BRepDataset + BRepBatch + offset-aware
  collate (mate involution survives batching) + MaxNumFacesSampler +
  BRepDataModule.
- M3 model (models/): UV-Net surface/curve encoders + feature fusion ->
  reused cadling BRepNetEncoder coedge message passing -> per-face seg
  head; cross-entropy + torchmetrics mIoU/accuracy.
- M4 training (train.py): pytorch-lightning Trainer + ModelCheckpoint +
  TensorBoard/CSV logging. Proof-of-life on 12 real fixtures: train loss
  2.13 -> 0.72, real val mIoU computed, checkpoint saved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, tests, docs (M5-M7)

- M5: real training on a Fusion 360 Gallery segmentation s2.0.0 subset
  (3400 train / 600 val / 800 test, official 8 classes + train/test split,
  35 epochs CPU). Honest held-out result: test mIoU 0.709, accuracy 0.912
  (per-class IoU in the plan/docs; rare RevolveEnd weak at 0.11). Competitive
  with the BRepNet paper (~0.65-0.72) using the MIT-clean reused-coedge encoder.
  Adds parallel STEP extraction (extract_step_files, ProcessPoolExecutor) and a
  quickstart.prepare_fusion360 orchestrator (extract -> copy labels -> manifest).
- M6: eval/evaluate.py evaluate_folder -- checkpoint + STEP folder -> per-face
  .logits (softmax rows); reuses the training manifest's standardization+classes.
- M7: 21 tests on real fixtures (extraction topology/grids, dataset+collate
  offset & mate-survival, model forward/learning, JSON front-end, slow
  end-to-end segment); lazy public API in __init__ (cheap import); add
  -e ./ll_brepnet + pytorch-lightning/tensorboard to root environment.yml;
  flip the site roadmap page to real Overview/Installation/Usage pages
  (site builds; all internal links valid).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @LayerDynamics, your pull request is larger than the review limit of 150000 diff characters

@LayerDynamics LayerDynamics merged commit feba8f5 into main Jun 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant