Add VAE encode nodes and fix default parameters
- Add TT VAE Encode (Context) node with documentation - Add TT VAE Encode Tiled node with documentation - Fix default parameter types in TT_ImagePreviewSave (string to int) - Update inputs in TT_VaeDecodeTiled
This commit is contained in:
@@ -26,6 +26,8 @@ from .nodes.text_encoders.clip_text_encode_sdxl import TT_ClipTextEncodeSdxl
|
||||
from .nodes.text_encoders.clip_text_encode_sdxl_context import TT_ClipTextEncodeSdxlContext
|
||||
from .nodes.vae.vae_decode_context import TT_VaeDecodeContext
|
||||
from .nodes.vae.vae_decode_tiled import TT_VaeDecodeTiled
|
||||
from .nodes.vae.vae_encode_context import TT_VaeEncodeContext
|
||||
from .nodes.vae.vae_encode_tiled import TT_VaeEncodeTiled
|
||||
from .nodes.workflow.flux_workfow_settings import TT_FluxWorkflowSettings
|
||||
from .nodes.workflow.flux_workfow_settings_advanced import TT_FluxWorkflowSettingsAdvanced
|
||||
from .nodes.workflow.sdxl_workfow_settings import TT_SdxlWorkflowSettings
|
||||
@@ -69,6 +71,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
# VAE
|
||||
"TT_VaeDecodeContext": TT_VaeDecodeContext,
|
||||
"TT_VaeDecodeTiled": TT_VaeDecodeTiled,
|
||||
"TT_VaeEncodeContext": TT_VaeEncodeContext,
|
||||
"TT_VaeEncodeTiled": TT_VaeEncodeTiled,
|
||||
# Workflow
|
||||
"TT_FluxWorkflowSettings": TT_FluxWorkflowSettings,
|
||||
"TT_FluxWorkflowSettingsAdvanced": TT_FluxWorkflowSettingsAdvanced,
|
||||
@@ -113,6 +117,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
# VAE
|
||||
"TT_VaeDecodeContext": "TT VAE Decode (Context)",
|
||||
"TT_VaeDecodeTiled": "TT VAE Decode (Tiled)",
|
||||
"TT_VaeEncodeContext": "TT Vae Encode (Context)",
|
||||
"TT_VaeEncodeTiled": "TT Vae Encode (Tiled)",
|
||||
# Workflow
|
||||
"TT_FluxWorkflowSettings": "TT FLUX Workflow Settings",
|
||||
"TT_FluxWorkflowSettingsAdvanced": "TT FLUX Workflow Settings (Advanced)",
|
||||
|
||||
@@ -14,8 +14,8 @@ def _save(
|
||||
output_path,
|
||||
filename_format="name-###",
|
||||
image_format="PNG",
|
||||
quality="50",
|
||||
compress_level="4"
|
||||
quality=50,
|
||||
compress_level=4
|
||||
):
|
||||
height, width = images[0].shape[:2]
|
||||
save_path, filename, counter, subfolder, _ = FP.get_save_image_path(
|
||||
|
||||
@@ -8,9 +8,9 @@ class TT_VaeDecodeTiled:
|
||||
"required": {
|
||||
"vae": ("VAE",),
|
||||
"latent": ("LATENT",),
|
||||
"tile_width": ("INT", {"default": 512, "min": 320, "max": 4096, "step": 64}),
|
||||
"tile_height": ("INT", {"default": 512, "min": 320, "max": 4096, "step": 64}),
|
||||
"overlap": ("INT", {"default": 64, "min": 0, "max": 256, "step": 8}),
|
||||
"tile_width": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"tile_height": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"overlap": ("INT", {"default": 64, "min": 0, "max": 4096, "step": 32}),
|
||||
"circular": ("BOOLEAN", {"default": False, "label_on": "Enabled", "label_off": "Disabled"}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
class TT_VaeEncodeContext:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"context": ("TT_CONTEXT",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("TT_CONTEXT", "LATENT",)
|
||||
RETURN_NAMES = ("CONTEXT", "LATENT",)
|
||||
FUNCTION = "vae_encode"
|
||||
CATEGORY = "TenserTensor/VAE"
|
||||
|
||||
def vae_encode(self, context):
|
||||
vae = context["vae"]
|
||||
image = context["image"]
|
||||
|
||||
if vae is None:
|
||||
raise ValueError("VAE is required for encode")
|
||||
if image is None:
|
||||
raise ValueError("Pixel image is required for encode")
|
||||
|
||||
samples = vae.encode(image)
|
||||
latent_dict = {"samples": samples}
|
||||
context["latent"] = latent_dict
|
||||
|
||||
return (context, latent_dict,)
|
||||
@@ -0,0 +1,28 @@
|
||||
class TT_VaeEncodeTiled:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"vae": ("VAE",),
|
||||
"image": ("IMAGE",),
|
||||
"tile_width": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"tile_height": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"overlap": ("INT", {"default": 64, "min": 0, "max": 4096, "step": 32}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("LATENT",)
|
||||
RETURN_NAMES = ("LATENT",)
|
||||
FUNCTION = "vae_encode"
|
||||
CATEGORY = "TenserTensor/VAE"
|
||||
|
||||
def vae_encode(self, image, vae, tile_width, tile_height, overlap):
|
||||
samples = vae.encode_tiled(
|
||||
image,
|
||||
tile_x=tile_width,
|
||||
tile_y=tile_height,
|
||||
overlap=overlap
|
||||
)
|
||||
latent_dict = {"samples": samples}
|
||||
|
||||
return (latent_dict,)
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
[project]
|
||||
name = "ComfyUI-TenserTensor"
|
||||
description = "A collection of custom nodes for ComfyUI that streamline common workflows. The main goal is to reduce visual clutter by combining frequently used node chains into single, convenient loaders."
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = []
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
## TT VAE Encode (Context) *TT_VaeEncodeContext*
|
||||
|
||||
*This description was generated with AI assistance. If you spot any errors, please create an issue on GitHub.*
|
||||
|
||||
Encodes pixel image to latent space using VAE from context.
|
||||
|
||||
### Inputs
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------------|----------|----------------------------------|
|
||||
| `context` | TT_CONTEXT | Yes | Context containing VAE and image |
|
||||
|
||||
### Outputs
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------------|-------------------------------------|
|
||||
| `CONTEXT` | TT_CONTEXT | Updated context with encoded latent |
|
||||
| `LATENT` | LATENT | Encoded latent representation |
|
||||
|
||||
### Usage
|
||||
|
||||
Encodes pixel-space images into latent representations for diffusion processing. Extracts VAE and image from context,
|
||||
performs encoding, and stores the result back in context.
|
||||
|
||||
Requires context to contain both `vae` and `image` components. Raises error if either is missing.
|
||||
|
||||
---
|
||||
|
||||
[View on GitHub](https://github.com/tenser-tensor/ComfyUI-TenserTensor)
|
||||
@@ -0,0 +1,34 @@
|
||||
## TT VAE Encode (Tiled) *TT_VaeEncodeTiled*
|
||||
|
||||
*This description was generated with AI assistance. If you spot any errors, please create an issue on GitHub.*
|
||||
|
||||
Encodes large images to latent space using tiled processing to reduce VRAM usage.
|
||||
|
||||
### Inputs
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|---------------|-------|----------|-----------------------------------------------------|
|
||||
| `vae` | VAE | Yes | VAE model for encoding |
|
||||
| `image` | IMAGE | Yes | Input image to encode |
|
||||
| `tile_width` | INT | Yes | Width of processing tiles in pixels (default: 512) |
|
||||
| `tile_height` | INT | Yes | Height of processing tiles in pixels (default: 512) |
|
||||
| `overlap` | INT | Yes | Overlap between tiles in pixels (default: 64) |
|
||||
|
||||
### Outputs
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|--------|-------------------------------|
|
||||
| `LATENT` | LATENT | Encoded latent representation |
|
||||
|
||||
### Usage
|
||||
|
||||
Processes large images in smaller tiles to reduce memory requirements during VAE encoding. Useful for encoding
|
||||
high-resolution images that would otherwise cause out-of-memory errors.
|
||||
|
||||
Tile size should be set based on available VRAM (smaller tiles = less memory). Overlap prevents visible seams at tile
|
||||
boundaries - higher overlap produces smoother results but increases processing time. Recommended overlap is 10-15% of
|
||||
tile size.
|
||||
|
||||
---
|
||||
|
||||
[View on GitHub](https://github.com/tenser-tensor/ComfyUI-TenserTensor)
|
||||
Reference in New Issue
Block a user