3.2 KiB
3.2 KiB
Product Requirements Document (PRD): ComfyUI-DAP
1. Project Overview
Goal: Create a native ComfyUI extension for the Insta360 DAP model (Depth Any Panorama).
Repository: https://github.com/Insta360-Research-Team/DAP
Model Weights: https://huggingface.co/Insta360-Research/DAP-weights
2. User Stories
- US-01: As a user, I want to use the DAP model without manually downloading weights or setting up complex python paths.
- US-02: As a user, I want to input a panoramic image and receive a high-quality depth map mask.
- US-03: As a user, I want to select different model sizes (Small/Base/Large) to balance VRAM usage and quality.
3. Node Specifications
Node A: DAP_Loader
- Category:
DAP/Loaders - Inputs:
model_size(Enum):["vitl", "vitb", "vits", "vitg"](Default:vitl)precision(Enum):["fp16", "fp32", "bf16"](Default:fp16)
- Outputs:
DAP_MODEL: A custom object containing the loaded PyTorch model and config.
- Logic:
- Check
ComfyUI/models/dapfor weights. - If missing, download from HF
Insta360-Research/DAP-weights. - Temporarily inject
dap_coreintosys.path. - Instantiate
DAPclass (with path patch). - Load state dict.
- Check
Node B: DAP_Inference
- Category:
DAP/Inference - Inputs:
dap_model: (DAP_MODEL)image: (IMAGE)invert_output: (BOOLEAN, Default:True)
- Outputs:
depth: (IMAGE) - The normalized depth map.mask: (MASK) - Raw 1-channel output.
- Logic:
- Move model to GPU.
- Resize input image to nearest multiple of 14 (patch size).
- Run inference.
- Resize output back to original dimensions.
- Normalize values for visualization.
4. Technical Constraints & Risks
- Hardcoded Paths: The
DAPclass innetworks/dap.pyhas a hardcoded relative path:dinov3_repo_dir="./depth_anything_v2_metric/...".- Solution: We must either modify the file on first run or monkey-patch
DAP.__init__to accept a dynamic path.
- Solution: We must either modify the file on first run or monkey-patch
- Imports: The codebase assumes it is the root module.
- Solution: Use
sys.path.append(os.path.join(current_dir, "dap_core"))inside the node initialization.
- Solution: Use
- Dependencies:
open3dis inrequirements.txt. It is heavy and often causes conflicts.- Solution: Check if we can run inference without importing
open3d. If it's only for visualization, we can mock it or remove the import.
- Solution: Check if we can run inference without importing
5. Development Backlog
| ID | Task | Priority | Status |
|---|---|---|---|
| BL-01 | Environment Verification: Create verify_dap.py to test imports and weight loading. |
P0 | Pending |
| BL-02 | Project Skeleton: Create __init__.py, nodes/, and basic project structure. |
P0 | Pending |
| BL-03 | DAP Loader Implementation: Implement auto-download and model loading with path patching. | P1 | Pending |
| BL-04 | DAP Inference Implementation: Implement image tensor conversion and inference loop. | P1 | Pending |
| BL-05 | Optimization: Implement model offloading (CPU/GPU switching). | P2 | Pending |
| BL-06 | UI/Docs: Add "invert" option and README.md. |
P3 | Pending |