ComfyUI-3D-Pack

repository·main·Indexed 25 days ago

https://github.com/mrforexample/comfyui-3d-pack

An extensive node suite for ComfyUI version 0.1.6 that enables 3D asset generation. It supports processing 3D inputs such as Mesh and UV Textures using 3DGS and NeRF algorithms, and integrates models including InstantMesh, CRM, TripoSR, CharacterGen, TRELLIS, and Hunyuan3D-1.0.

Tokens
12.1K
Snippets
30
Records
75
Agent score
87%

What's inside ComfyUI-3D-Pack

  1. Project structure overview for developers

    main

    For developers looking to extend the pack, the following directory structure is used:

    • nodes.py: Interface code for all ComfyUI nodes. Add new nodes here.
    • Gen_3D_Modules/: Code for generative models (e.g., multi-view diffusion, 3D reconstruction).
    • MVs_Algorithms/: Multi-view stereo algorithms (e.g., Gaussian Splatting, NeRF, FlexiCubes).
    • web/: Browser UI files (HTML, JS, CSS) for 3D mesh/Gaussian previews.
    • webserver/: Web server logic for handling client requests and sending 3D data.
    • Configs/: Configuration files for various modules (e.g., Configs/Unique3D_configs).
    • Checkpoints/: Pre-trained models and architecture configs. Files here can be automatically downloaded by the Load_Diffusers Pipeline node.
    • install.py: Main installation script that handles pre-builds and automatic builds via ComfyUI-Manager.
    • _Pre_Builds/: Files and code used to build required dependencies.
  2. Install and run ComfyUI-3D-Pack with Docker (Linux)

    main

    To run Comfy3D in a Docker container on Linux, you must have GPU support configured via nvidia-container-runtime.

    1. Install Runtime: sudo apt-get install nvidia-container-runtime.
    2. Configure Docker: Edit or create /etc/docker/daemon.json to include the NVIDIA runtime as the default:
      {
          "runtimes": {
              "nvidia": {
                  "path": "/usr/bin/nvidia-container-runtime",
                  "runtimeArgs": []
              } 
          },
          "default-runtime": "nvidia" 
      }
    3. Restart Docker: sudo systemctl restart docker.
    4. Build and Run: Use docker build and docker run with the --gpus all flag.
    # Configure daemon.json first, then:
    sudo systemctl restart docker
    docker build -t comfy3d . && docker run --rm -it -p 8188:8188 --gpus all comfy3d
  3. Run the Comfy3D Docker container

    main

    You can run the container using docker run with specific volume mappings for models and outputs, or simply use docker compose up.

    # Using docker run
    docker run -d \
      --name comfy3d \
      --platform linux/amd64 \
      --runtime=nvidia \
      -p 8188:8188 \
      -e NVIDIA_VISIBLE_DEVICES=all \
      -e NVIDIA_DRIVER_CAPABILITIES=all \
      -e COMFYUI_PATH=/app \
      -v $(pwd)/output:/app/output \
      -v $(pwd)/models/diffusion_pytorch_model.safetensors:/app/models/controlnet/control_unique3d_sd15_tile.safetensors \
      -v $(pwd)/models/ip-adapter_sd15.safetensors:/app/models/ipadapter/ip-adapter_sd15.safetensors \
      -v $(pwd)/models/RealESRGAN_x4plus.pth:/app/models/upscale_models/RealESRGAN_x4plus.pth \
      -v $(pwd)/models/v1-5-pruned-emaonly.ckpt:/app/models/checkpoints/v1-5-pruned-emaonly.ckpt \
      -v $(pwd)/models/model.safetensors:/app/models/clip_vision/OpenCLIP-ViT-H-14.safetensors \
      comfy3d
    
    # Using Docker Compose
    docker compose up
  4. Set up Blender requirements for rendering

    main

    The rendering scripts require Blender 4.1 and specific Python packages (opencv, OpenEXR, and Imath) installed within Blender's internal Python environment.

    On macOS, you can install these dependencies using the following command (adjusting the path to your Blender installation if necessary):

    /Applications/Blender.app/Contents/Resources/4.1/python/bin/python3.11 -m pip install OpenEXR Imath opencv-python
  5. Manual Installation of ComfyUI-3D-Pack

    main

    To install manually, clone the repository into your ComfyUI custom nodes directory and run the provided installation scripts using your ComfyUI embedded Python executable. This process attempts to download pre-built binaries for your environment or triggers an automatic build if pre-builds are unavailable.

    # Fetch newest version of Comfy3D
    cd Your ComfyUI Root Directory\ComfyUI\custom_nodes\
    git clone https://github.com/MrForExample/ComfyUI-3D-Pack.git
    cd ComfyUI-3D-Pack
    
    # Install all dependencies
    Your ComfyUI Root Directory\python_embeded\python.exe -s -m pip install -r requirements.txt
    Your ComfyUI Root Directory\python_embeded\python.exe install.py