modly icon indicating copy to clipboard operation
modly copied to clipboard

feat(extensions): support scene-directory model inputs with UI-managed weights

Open DrHepa opened this issue 2 months ago • 1 comments

What problem does this solve?

Some model extensions generate one mesh from a structured scene, not from one image. WorldSculpt is a concrete case: its published inference path expects a scene directory with transforms.json, RGB frames, instance masks, and per-instance metric 3D AABBs (with optional pose/scale metadata); it reconstructs objects and composes a scene GLB. Multiple image ports alone do not provide those annotations.

Today Modly's model-extension workflow submits an image to /generate/from-image and invokes generate(image_bytes, params, ...). A process extension can receive a filesystem path, but it cannot use the model-extension model_sources download flow. Encoding the scene directory in a string/text parameter would require a fake text connection and a placeholder image request, while leaving users without a clear required scene input. This blocks an honest WorldSculpt node whose Pixal3D base and WorldSculpt adapter weights are managed from Models/Extensions.

Proposed solution

Add an opt-in, versioned scene-directory input contract for model nodes. The manifest should declare a required scene/directory input distinct from image; the workflow UI should present a folder input/picker and route one selected local scene directory through the job API and extension subprocess without fabricating an image. An optional scene-generation entry point (or equivalent versioned dispatch) should receive the validated directory path, params, progress, and cancellation, while existing generate(image_bytes, ...) nodes stay unchanged. Older hosts must reject unsupported scene-input manifests explicitly instead of silently treating them as image nodes.

The host should enforce path boundaries and access rules (canonicalize paths, reject missing/non-directory paths and unsafe symlink escapes, never mutate the selected input, and use a separate output directory). The extension must also resolve every frame/mask path referenced by transforms.json within the selected scene root before upstream code opens it, rejecting traversal and symlink escapes. WorldSculpt-specific validation would check cameras, instance IDs and metric AABBs, and reject incomplete reconstruction rather than return a partial GLB.

Keep weights in the normal Models/Extensions lifecycle: the model node can declare model_sources for AlayaLab/WorldSculpt, with required checkpoint checks. Reusing the Pixal3D base without duplicate downloads depends separately on the pending shared-weight-group contract; this issue should not reimplement it. Setup/Repair should not silently download model weights.

Acceptance criteria

  • A model extension can declare a required scene-directory input; the UI and saved workflows represent it without a fake image or text edge.
  • The selected scene path reaches the correct extension node through API/job/subprocess dispatch; legacy image nodes retain their current behavior.
  • Invalid, missing, or escaping scene paths and nested frame/mask references fail before inference with actionable errors. The host does not mutate selected input, and outputs are written separately.
  • The existing Models/Extensions download/readiness flow continues to manage node-private model_sources; shared Pixal3D base reuse is handled by the separate shared-weight-group work.
  • A host contract fixture proves scene-path transport, progress/cancellation, failures, and legacy compatibility without requiring WorldSculpt's GPU weights. Unsupported older hosts fail closed on the new manifest contract.
  • Separately, real WorldSculpt acceptance verifies valid scene input produces a loadable scene.glb and that missing annotations or failed object reconstruction cannot return a partial success.
  • Manifest, workflow UI, transport, path-security, downloader, and compatibility tests cover the new contract.

This request is about a general extension input contract, not hard-coding WorldSculpt's scene schema into Modly. It should be additive to, or reuse, the port schema discussed in #228, not compete with it. Shared Pixal3D weight reuse is covered separately by #343; neither issue should assume the other has merged.

Alternatives considered

  • inputs: ["image", ...] / extra_image_paths: provides RGB views, not calibrated cameras, masks, or object boxes.
  • A string folder parameter on a text-only model node: technically possible, but requires a spurious text connection and placeholder image upload; it does not express a required scene input.
  • A separate process extension: has natural file-path I/O, but currently lacks UI-managed model weight sources and shared-weight references.

Confirmation

  • [x] I have searched existing issues for this feature.

DrHepa avatar Sep 18 '26 20:09 DrHepa

Implemented and validated a private prototype for the scene-directory contract described here, stacked on the shared-weight work in #348:

  • typed scene -> model -> mesh workflow edges and a Load Scene node;
  • versioned, workspace-contained scene manifest validation across the Electron IPC, API, runner, and extension boundary;
  • generic typed /generate/from-artifact dispatch while preserving the existing image routes;
  • canonical path, traversal, symlink, mask, output-root, and no-pre-validation-mutation checks;
  • token-owned cancellation spanning load, nested subprocesses, blocking workers, and every cancellation endpoint;
  • UI-managed shared Pixal3D/WorldSculpt weight groups.

The same prototype also adds an optional capture -> scene preparation lane (SAM3 + DA3 Base) and a separate annotated-scene normalizer; those are extension features layered on the generic host contract, not WorldSculpt-specific host logic.

Evidence completed on Linux ARM64/CUDA:

  • exact Electron 42 UI routing;
  • real 3-view Scene Prep output with cameras, masks, relative-scale provenance, and AABB;
  • real WorldSculpt GLB generation and Add-to-Scene propagation;
  • final 50,000-face request produced a valid 49,593-face GLB;
  • 157 host Python, 29 host Node, 80 extension Python, and 3 extension Node tests pass; production build passes;
  • independent fresh review found no remaining P0/P1/P2 blockers.

Prototype branch: https://github.com/DrHepa/modly/tree/codex/worldsculpt-scene-private

The implementation remains intentionally stacked on #348 until shared weight groups land. Could this issue be reviewed for status:approved so a focused upstream PR can be prepared once that dependency is available?

DrHepa avatar Sep 20 '26 06:09 DrHepa