ComfyUI Extension: ComfyUI-Image-Latent-

Authored by GIlinQ

Created

Updated

0 stars

Run ComfyUI workflows without the setup

No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.

Custom ComfyUI node for image upload, upscaling, VAE encoding, and empty latent creation with dynamic scaling support. (Description by CC)

Looking for a different extension?

Custom Nodes (1)

README

ComfyUI Image Upload & Latent Node

这是一个自定义的 ComfyUI 节点,集成了图像上传、超分辨率放大、VAE 编码以及直接创建空 Latent 的功能。

功能特性

  1. 图像上传与放大
    • 支持 PNG, JPG, WEBP 等常见格式上传。
    • 支持多种超分辨率算法:nearest-exact, bilinear, area, bicubic, lanczos
    • 动态放大倍数:提供浮点数滑块 (0.5 - 8.0),步长 0.1。
    • 集成 VAE 编码,直接输出 Latent 张量。
  2. 创建空 Latent
    • 可切换模式直接生成指定尺寸的空 Latent 张量。
    • 支持自定义宽、高 (64 - 2048 像素)。
    • 输出符合 SD 模型要求的 Latent 格式 (NCHW, 4通道)。
  3. 模式互斥
    • 通过 mode 选项切换 "Upload & Upscale" 和 "Create Empty Latent"。
    • 切换模式时会自动处理缓存。

安装说明

  1. 将本项目文件夹克隆或复制到 ComfyUI 的 custom_nodes 目录下。
    cd ComfyUI/custom_nodes
    git clone https://github.com/your-repo/comfyui-image-latent.git
    # 或者直接复制文件夹
    
  2. 重启 ComfyUI。

使用方法

在 ComfyUI 界面中,右键点击 -> image -> custom -> Image Upload & Latent 添加节点。

输入参数

  • image: 点击上传按钮选择图片 (仅在 "Upload & Upscale" 模式下生效)。
  • vae: 连接一个加载好的 VAE 模型 (如 Load VAE 节点的输出)。
  • mode:
    • Upload & Upscale: 上传图片并放大/编码。
    • Create Empty Latent: 忽略上传图片,直接生成空 Latent。
  • upscale_method: 选择放大算法 (如 bicubic, lanczos 等)。
  • scale_factor: 放大倍数 (0.5 - 8.0)。
  • width / height: 空 Latent 的像素尺寸 (仅在 "Create Empty Latent" 模式下生效)。
  • batch_size: Latent 的 batch 大小。

输出

  • LATENT: 编码后或生成的 Latent 对象,可直接连接到 KSampler 等节点。

验证与测试

本项目包含单元测试脚本,可验证节点逻辑的正确性。

运行测试:

python -m unittest tests/test_node.py

测试覆盖:

  • 空 Latent 生成尺寸正确性。
  • 图像放大后尺寸与 VAE 编码输出形状正确性。
  • 文件大小限制 (20MB) 校验。

注意事项

  • 上传文件大小限制为 20MB。
  • "Create Empty Latent" 模式下,生成的 Latent 尺寸为输入像素尺寸除以 8 (SD 模型标准)。

Run ComfyUI workflows without the setup

No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.

Learn more