Skip to content

Commit

Permalink
improve: PreviewBridgeLatent - add Latent2RGB-LTXV
Browse files Browse the repository at this point in the history
improve: LatentSender - add multiple latent formats
  • Loading branch information
ltdrdata committed Nov 30, 2024
1 parent 1ec3037 commit 348c3dc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
12 changes: 11 additions & 1 deletion modules/impact/bridge_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def decode_latent(latent, preview_method, vae_opt=None):
elif preview_method == "Latent2RGB-FLUX.1":
latent_format = latent_formats.Flux()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-LTXV":
latent_format = latent_formats.LTXV()
method = LatentPreviewMethod.Latent2RGB
else:
print(f"[Impact Pack] PreviewBridgeLatent: '{preview_method}' is unsupported preview method.")
latent_format = latent_formats.SD15()
Expand All @@ -211,6 +214,7 @@ def INPUT_TYPES(s):
"Latent2RGB-SDXL", "Latent2RGB-SD15", "Latent2RGB-SD3",
"Latent2RGB-SD-X4", "Latent2RGB-Playground-2.5",
"Latent2RGB-SC-Prior", "Latent2RGB-SC-B",
"Latent2RGB-LTXV",
"TAEF1", "TAESDXL", "TAESD15", "TAESD3"],),
},
"optional": {
Expand Down Expand Up @@ -274,7 +278,13 @@ def load_image(pb_id):

def doit(self, latent, image, preview_method, vae_opt=None, block=False, unique_id=None, restore_mask='never', prompt=None, extra_pnginfo=None):
latent_channels = latent['samples'].shape[1]
preview_method_channels = 16 if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method or 'TAEF1' == preview_method else 4

if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method or 'TAEF1' == preview_method:
preview_method_channels = 16
elif 'LTXV' in preview_method:
preview_method_channels = 128
else:
preview_method_channels = 4

if vae_opt is None and latent_channels != preview_method_channels:
print(f"[PreviewBridgeLatent] The version of latent is not compatible with preview_method.\nSD3, SD1/SD2, SDXL, SC-Prior, SC-B and FLUX.1 are not compatible with each other.")
Expand Down
2 changes: 1 addition & 1 deletion modules/impact/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
import os

version_code = [7, 13]
version_code = [7, 14]
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')

dependency_version = 24
Expand Down
40 changes: 32 additions & 8 deletions modules/impact/impact_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,12 @@ def INPUT_TYPES(s):
"samples": ("LATENT", ),
"filename_prefix": ("STRING", {"default": "latents/LatentSender"}),
"link_id": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
"preview_method": (["Latent2RGB-SDXL", "Latent2RGB-SD15", "TAESDXL", "TAESD15"],)
"preview_method": (["Latent2RGB-FLUX.1",
"Latent2RGB-SDXL", "Latent2RGB-SD15", "Latent2RGB-SD3",
"Latent2RGB-SD-X4", "Latent2RGB-Playground-2.5",
"Latent2RGB-SC-Prior", "Latent2RGB-SC-B",
"Latent2RGB-LTXV",
"TAEF1", "TAESDXL", "TAESD15", "TAESD3"],)
},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
}
Expand Down Expand Up @@ -2069,15 +2074,34 @@ def prepare_preview(latent_tensor, preview_method):
if preview_method == "Latent2RGB-SD15":
latent_format = latent_formats.SD15()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "TAESD15":
latent_format = latent_formats.SD15()
method = LatentPreviewMethod.TAESD
elif preview_method == "TAESDXL":
latent_format = latent_formats.SDXL()
method = LatentPreviewMethod.TAESD
else: # preview_method == "Latent2RGB-SDXL"
elif preview_method == "Latent2RGB-SDXL":
latent_format = latent_formats.SDXL()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-SD3":
latent_format = latent_formats.SD3()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-SD-X4":
latent_format = latent_formats.SD_X4()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-Playground-2.5":
latent_format = latent_formats.SDXL_Playground_2_5()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-SC-Prior":
latent_format = latent_formats.SC_Prior()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-SC-B":
latent_format = latent_formats.SC_B()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-FLUX.1":
latent_format = latent_formats.Flux()
method = LatentPreviewMethod.Latent2RGB
elif preview_method == "Latent2RGB-LTXV":
latent_format = latent_formats.LTXV()
method = LatentPreviewMethod.Latent2RGB
else:
print(f"[Impact Pack] LatentSender: '{preview_method}' is unsupported preview method.")
latent_format = latent_formats.SD15()
method = LatentPreviewMethod.Latent2RGB

previewer = core.get_previewer("cpu", latent_format=latent_format, force=True, method=method)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-impact-pack"
description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
version = "7.13"
version = "7.14"
license = { file = "LICENSE.txt" }
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]

Expand Down

0 comments on commit 348c3dc

Please sign in to comment.