Refactor and enhance DA3 and BEN2 debug panels, introduce mesh export functionality
- Renamed DA3 and BEN2 debug panels for clarity and consistency. - Added a new function to draw DA3 input settings to reduce code duplication. - Implemented mesh export functionality, including confidence thresholding and edge filtering. - Updated export format options to include new mesh type and adjusted related properties. - Enhanced job handling to move generated inputs into job root and manage temporary directories. - Improved error handling and file management during export processes. - Added unit tests for new mesh functionality and ensured existing tests cover changes.
This commit is contained in:
@@ -23,13 +23,15 @@
|
||||
- 视频按顺序截取前若干帧,可设置参与重建的最大帧数
|
||||
- `Host > Models` 默认折叠,展开后可逐项查看和下载所有可用模型
|
||||
- Runtime 已就绪时不额外占用面板空间;模型列表每个模型只占一行
|
||||
- `Debug` 默认折叠,内部的 DA3 与 BEN2 测试项也分别默认折叠
|
||||
- 使用一个导出类型下拉菜单和一个 `Export` 按钮
|
||||
- `Debug` 默认折叠,内部的 `DA3 Output Test` 与 `BEN2 Removal Test` 也分别默认折叠
|
||||
- 使用一个输出类型下拉菜单和一个 `Generate Output` 按钮
|
||||
- 只显示当前格式的专属参数;GLB 与 PLY 设置不会同时出现
|
||||
- Debug 的模型选项按格式过滤;PLY 只提供两个带 Gaussian head 的 Giant 模型
|
||||
- Debug 与 Convert to Depth Plane 的模型选项直接显示下载状态;未下载模型带
|
||||
`(Missing)`,已下载模型保持原名
|
||||
- 分别调用 DA3 的 `glb`、`gs_ply`、`depth_vis` 和 `mini_npz` exporter
|
||||
- `Textured Mesh (GLB)` 直接使用 DA3 Prediction 中的深度、置信度和相机参数,把相邻像素
|
||||
组成三角面并写入 `mesh.glb`;每个输入帧生成一张独立纹理网格,不做多视图融合
|
||||
- Image Empty 右键菜单可直接运行 DA3,根据 `mini_npz` 深度生成面片
|
||||
- Image Empty 右键菜单可直接运行 BEN2,保留原图并换用新建的透明背景图片
|
||||
- Image Empty 支持视频与序列帧输入:`Convert to Depth Plane` 逐帧估计深度,
|
||||
@@ -39,7 +41,7 @@
|
||||
- 使用浮点深度贴图、Simple Subdivision、Displace Modifier 和原图 Bump
|
||||
构建立体面片
|
||||
- 转换对话框可选择推理模式、处理分辨率和面片网格细分
|
||||
- Debug 的 DA3 导出或 BEN2 背景剔除完成后只打开对应 job 文件夹,不向当前 Blender 文件添加任何数据
|
||||
- Debug 的 DA3 输出或 BEN2 背景剔除完成后只打开对应 job 文件夹,不修改当前场景
|
||||
- 完整保留每次任务生成的所有官方文件
|
||||
- 安装和模型下载使用后台子进程;推理提交给常驻 AI Host,状态栏实时显示阶段、百分比进度条与取消按钮
|
||||
- 后台任务运行时,Install、Download 和 Export 按钮保持原位置并变灰,任务完成后恢复
|
||||
@@ -69,10 +71,10 @@
|
||||
自行探测回退到 HF 镜像;需要手动指定镜像时可通过 `PIP_INDEX_URL` 环境变量覆盖。
|
||||
5. 在 3D View 按 `N`,打开 `SnapForm` 页签。
|
||||
6. 如需其他模型,展开 `Host > Models`,找到模型并点击该行的 `Download`。
|
||||
7. 展开默认收起的 `Debug`,选择 `Export Format` 和本次执行使用的模型。
|
||||
8. 选择一张图片或一个视频文件。视频可设置从头截取的帧数,然后点击 `Export`。
|
||||
7. 展开默认收起的 `Debug`,选择 `Output Type` 和本次执行使用的模型。
|
||||
8. 选择一张图片或一个视频文件。视频可设置从头截取的帧数,然后点击 `Generate Output`。
|
||||
9. 测试背景剔除时,确认 `Host > Models` 中的 `BEN2 Base` 已就绪,然后在 `Debug` 的
|
||||
`BEN2 Background Removal` 区域选择单张图片并点击 `Remove Background`。
|
||||
`BEN2 Removal Test` 区域选择单张图片并点击 `Remove Background`。
|
||||
完成后会打开 job 文件夹,其中的 `foreground.png` 带透明 Alpha;状态栏显示
|
||||
BEN2 推理、模型加载与任务总耗时。当前测试固定关闭较慢的 foreground refinement。
|
||||
|
||||
@@ -218,33 +220,52 @@ Image Empty 使用 Packed Image 时,SnapForm 会通过 Blender 写出临时 PN
|
||||
`DA3 Nested Giant Large 1.1`。Small、Base 和 Large 没有 Gaussian head,无法由
|
||||
DA3 生成 `gs_ply`。
|
||||
|
||||
每个任务在 `~/.snapform/jobs/` 下用独立文件夹包裹(命名格式为 `任务类型_时间号`,例如
|
||||
`depth-plane_20260807-153000`),日志、状态与输出产物都放在该文件夹内:
|
||||
每个任务在 `~/.snapform/jobs/` 下用独立文件夹包裹。文件夹统一采用
|
||||
`动作-对象_日期-时间-微秒`,每种任务都有唯一名称,例如
|
||||
`generate-depth-plane_20260807-153000-123456`。微秒用于避免同一秒启动的任务共用目录。
|
||||
|
||||
Blender 为 Packed Image 或序列帧生成的输入副本也归档到对应 job 根目录:单图命名为
|
||||
`input.png`,序列帧命名为 `frame.0001.*`。它们以前暂存在 `jobs/inputs/`,现在不再创建这个
|
||||
公共中转文件夹。普通磁盘文件和视频仍直接读取原文件,不额外复制。
|
||||
|
||||
日志、运行中的状态文件、归档输入与输出产物均直接放在 job 根目录。各类任务名称为:
|
||||
|
||||
- `install-runtime`
|
||||
- `download-model`
|
||||
- `export-reconstruction`
|
||||
- `generate-depth-plane`
|
||||
- `remove-background`
|
||||
- `remove-image-background`
|
||||
- `generate-original-depth-plane`
|
||||
- `extract-original-frames`
|
||||
|
||||
DA3 官方 exporter 产生的 `gs_ply/`、`depth_vis/`、`exports/mini_npz/` 会在完成后自动平铺,
|
||||
不会保留只含一层产物的子目录:
|
||||
|
||||
```text
|
||||
reconstruct_20260807-153000/
|
||||
├── reconstruct_20260807-153000.log
|
||||
├── reconstruct_20260807-153000.json
|
||||
export-reconstruction_20260807-153000-123456/
|
||||
├── export-reconstruction_20260807-153000-123456.log
|
||||
├── export-reconstruction_20260807-153000-123456.json
|
||||
└── scene.glb
|
||||
|
||||
reconstruct_20260807-153000/
|
||||
├── reconstruct_20260807-153000.log
|
||||
├── reconstruct_20260807-153000.json
|
||||
└── gs_ply/*.ply
|
||||
export-reconstruction_20260807-153000-123456/
|
||||
├── export-reconstruction_20260807-153000-123456.log
|
||||
├── export-reconstruction_20260807-153000-123456.json
|
||||
└── *.ply
|
||||
|
||||
reconstruct_20260807-153000/
|
||||
├── reconstruct_20260807-153000.log
|
||||
├── reconstruct_20260807-153000.json
|
||||
└── depth_vis/*.jpg
|
||||
export-reconstruction_20260807-153000-123456/
|
||||
├── export-reconstruction_20260807-153000-123456.log
|
||||
├── export-reconstruction_20260807-153000-123456.json
|
||||
└── *.jpg
|
||||
|
||||
reconstruct_20260807-153000/
|
||||
├── reconstruct_20260807-153000.log
|
||||
├── reconstruct_20260807-153000.json
|
||||
export-reconstruction_20260807-153000-123456/
|
||||
├── export-reconstruction_20260807-153000-123456.log
|
||||
├── export-reconstruction_20260807-153000-123456.json
|
||||
└── results.npz
|
||||
|
||||
remove-background_20260807-153000/
|
||||
├── remove-background_20260807-153000.log
|
||||
├── remove-background_20260807-153000.json
|
||||
remove-background_20260807-153000-123456/
|
||||
├── remove-background_20260807-153000-123456.log
|
||||
├── remove-background_20260807-153000-123456.json
|
||||
├── foreground.png 单图结果
|
||||
├── foreground.0001.png… 视频/序列帧结果
|
||||
├── frame.0001.jpg… 视频/序列帧的源帧副本
|
||||
@@ -256,15 +277,16 @@ CC BY-NC 4.0,仅限非商业用途。
|
||||
|
||||
## 输出格式说明
|
||||
|
||||
`Export Format` 下拉菜单分别把以下原始 `export_format` 传给 DA3:
|
||||
`Output Type` 提供以下结果:
|
||||
|
||||
- GLB:`glb`
|
||||
- PLY:`gs_ply`,同时传入 `infer_gs=True`
|
||||
- Depth Images:`depth_vis`
|
||||
- Mini NPZ:`mini_npz`
|
||||
- Point Cloud (GLB):DA3 `glb`
|
||||
- Gaussian Splats (PLY):DA3 `gs_ply`,同时传入 `infer_gs=True`
|
||||
- Depth Preview (Images):DA3 `depth_vis`
|
||||
- Depth Data (NPZ):DA3 `mini_npz`
|
||||
- Textured Mesh (GLB):SnapForm 根据 DA3 Prediction 构建并输出 `mesh.glb`
|
||||
|
||||
界面使用 DA3 API 的参数名、选项和默认值。GLB 专属设置仅在选择 `GLB` 时显示,
|
||||
`gs_views_interval` 仅在选择 `PLY (3DGS)` 时显示:
|
||||
Point Cloud 专属设置仅在对应类型下显示,`gs_views_interval` 仅用于 Gaussian Splats。
|
||||
Textured Mesh 使用 0–100% 的 Confidence Threshold 删除置信度最低的一定比例:
|
||||
|
||||
- `process_res=504`
|
||||
- `process_res_method="upper_bound_resize"`
|
||||
@@ -277,7 +299,7 @@ CC BY-NC 4.0,仅限非商业用途。
|
||||
|
||||
DA3 官方 `glb` 是彩色点云与可选相机线框;`gs_ply` 是带 Gaussian 属性的 PLY;
|
||||
`depth_vis` 是原图与着色深度图的并排预览;`mini_npz` 保存深度、置信度和可用的相机参数。
|
||||
GLB 任务会关闭其默认附带的深度预览,使四种 job 产物保持分离。
|
||||
Point Cloud GLB 任务会关闭其默认附带的深度预览,使五种输出产物保持分离。
|
||||
|
||||
官方格式与限制可参阅
|
||||
[DA3 Python API 文档](https://github.com/ByteDance-Seed/Depth-Anything-3/blob/main/docs/API.md)。
|
||||
|
||||
Reference in New Issue
Block a user