feat: Add surface generation and media handling

- Implemented surface generation functionality in `surface.py`, including geometry estimation and texture writing.
- Introduced media input handling in `input.py`, supporting image and video frame extraction.
- Added model management for geometry adapters in `models/__init__.py`.
- Created BEN2 and DA3 model inference logic in `ben2.py` and `da3.py`, respectively.
- Developed ONNX model inference utilities for BEN2 and DA3 in `onnx_ben2.py` and `onnx_da3.py`.
- Added support for MoGe-2 model inference in `moge2.py` with necessary ONNX utilities.
- Implemented output handling for depth and surface data in `depth.py` and `surface.py`.
- Created debug output utilities for DA3 and MoGe-2 predictions in `debug_da3.py` and `debug_moge2.py`.
- Enhanced ONNX runtime session management in `onnx_runtime.py`.
- Updated `__init__.py` files to include new modules and functions for better organization.
This commit is contained in:
2026-08-18 23:27:10 +08:00
parent 9dfa49602c
commit 835225d264
62 changed files with 2126 additions and 2318 deletions

View File

@@ -24,9 +24,14 @@ flowchart LR
- `blender/depth_plane.py` 与 `blender/surface.py` 实现 Image Empty 输入检查、几何构建和资产挂载
- `job_runtime.py` 以入口字符串声明独立 Server,并配置 Environment、Storage Root 与首次安装后的推荐模型下载
- `server/__init__.py` 创建 `JobServer`、注册公开 Job,并把 `ModelManager` 注册为 Resource
- `server/media.py`、`background.py`、`da3.py`、`moge2.py` 负责业务流程;`onnx_*.py` 只处理模型输入、推理和输出恢复
- `server/jobs/` 按任务组织完整流程;DA3、MoGe-2、BEN2 Debug 各自拥有独立模块和 Job,不用模型分支总控函数
- `server/models/` 包含三个模型适配器及其 ONNX 实现,只负责模型载入、推理和 Prediction;不接收 Job Context、不写文件
- `server/geometry/` 包含投影、像素网格和唯一 Surface Builder,均为纯数据转换;不负责 Debug 或文件输出
- `server/outputs/` 只负责 Depth、Surface 与各模型 Debug 的序列化;Debug writer 原样保存 API 字段,不构建派生几何
- `server/media/input.py` 只处理图片、序列和视频输入;共享的可选前景流程保留在 `jobs/foreground.py`
- 根目录 `model_catalog.py` 供 Blender UI 与本地就绪检查使用;`server/model_catalog.py` 独立声明下载与推理所需模型,二者的模型键、目录名和 `ready_patterns` 由测试约束一致
- `server/geometry.py` 生成 NPZ、预览、点云和纹理网格;所有任务产物写入 Runtime 分配的 opaque-ID Job 目录
- `server/__init__.py` 只注册 Job 与 Resource;`jobs/background.py`、`jobs/frames.py` 分别实现去背景和帧提取
- 所有任务产物写入 Runtime 分配的 opaque-ID Job 目录
功能细节继续按主题维护:[Depth Plane](depth-plane.md)、[Surface](surface.md)、[输出格式](outputs.md) 和 [Job Server](server.md)。
@@ -56,18 +61,37 @@ flowchart LR
│ ├── model_catalog.py
│ ├── server/
│ │ ├── __init__.py
│ │ ├── background.py
│ │ ├── da3.py
│ │ ├── geometry.py
│ │ ├── media.py
│ │ ├── jobs/
│ │ │ ├── background.py
│ │ │ ├── debug_ben2.py
│ │ │ ├── debug_da3.py
│ │ │ ├── debug_moge2.py
│ │ │ ├── depth.py
│ │ │ ├── foreground.py
│ │ │ ├── frames.py
│ │ │ └── surface.py
│ │ ├── geometry/
│ │ │ ├── projection.py
│ │ │ ├── grid_mesh.py
│ │ │ └── surface.py
│ │ ├── media/
│ │ │ └── input.py
│ │ ├── model_download.py
│ │ ├── model_catalog.py
│ │ ├── model_manager.py
│ │ ├── moge2.py
│ │ ├── onnx_ben2.py
│ │ ├── onnx_da3.py
│ │ ├── onnx_moge2.py
│ │ └── onnx_runtime.py
│ │ ├── models/
│ │ │ ├── ben2.py
│ │ │ ├── da3.py
│ │ │ ├── moge2.py
│ │ │ ├── onnx_ben2.py
│ │ │ ├── onnx_da3.py
│ │ │ ├── onnx_moge2.py
│ │ │ └── onnx_runtime.py
│ │ └── outputs/
│ │ ├── debug_da3.py
│ │ ├── debug_moge2.py
│ │ ├── depth.py
│ │ └── surface.py
│ └── wheels/
│ └── blendjob-0.1.13-py3-none-any.whl
├── tests/
@@ -106,6 +130,9 @@ BLENDER_BIN="/c/Program Files/Blender Foundation/Blender 4.5/blender.exe"
"$BLENDER_BIN" --background --python tools/validate_moge_surface.py
```
验证脚本会自动把 `src/snapform/wheels/` 中的 BlendJob wheel 加入 Blender Python 路径,因此可在
`--factory-startup` 的干净环境中直接运行。
只改 Python、文档或打包逻辑时不需要重建 `.blend` 资产;修改节点组、材质组或其接口时,应运行相应资产验证脚本,并再次运行完整测试。
## 上游与许可证