Custom nodes for ComfyUI to generate empty latent space compatible with Hunyuan models for both image and video generation.
- Fixed aspect ratio selection from common formats (1:1, 16:9, 9:16, etc.)
- Support for both image and video latent generation
- All dimensions are automatically adjusted to be multiples of 16
- Maintains compatibility with Hunyuan model tensor format
Creates an empty latent space for image generation with the following parameters:
- resolution: Dropdown selection of common aspect ratios and resolutions
- batch_size: Number of images to generate in parallel (default: 1)
Creates an empty latent space for video generation with the following parameters:
- resolution: Same resolution options as image node
- frames: Number of frames to generate (default: 16, range: 1-256)
- batch_size: Number of videos to generate in parallel (default: 1)
The nodes support various standard resolutions with their aspect ratios:
- Portrait formats:
- 576x1024 (9:16)
- 704x1408 (1:2)
- 768x1344 (4:7)
- And more...
- Square format:
- 1024x1024 (1:1)
- Landscape formats:
- 1024x576 (16:9)
- 1344x704 (16:9)
- 1408x704 (2:1)
- And more...
- Create a custom_nodes directory in ComfyUI if it doesn't exist
cd ComfyUI/custom_nodes
- Clone this repository:
git clone https://github.com/ShmuelRonen/ComfyUI-Hunyuan-Latent.git
- Restart ComfyUI
The nodes will appear in the node menu under:
latent
for EmptyHunyuanLatentForImagelatent/video
for EmptyHunyuanLatentForVideo
- Right-click in the ComfyUI workspace
- Navigate to:
latent → EmptyHunyuanLatentForImage
for image generationlatent/video → EmptyHunyuanLatentForVideo
for video generation
- Select desired resolution from the dropdown
- Connect to other nodes in your workflow
Both nodes output a latent dictionary with the key "samples" containing a torch tensor with the following dimensions:
- Image:
[batch_size, 4, 1, height//8, width//8]
- Video:
[batch_size, 4, frames, height//8, width//8]
- ComfyUI
- PyTorch
- Hunyuan model dependencies
https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged/tree/main/split_files/text_encoders
https://drive.google.com/file/d/1BvGHjR4Mb60ZPx9tqzA1AabAwZc47ctx/view?usp=sharing
MIT
Contributions are welcome! Please feel free to submit a Pull Request.