Skip to content

pipeLoaderSDXL v1 (Legacy)

Documentation

  • Class name: ttN pipeLoaderSDXL
  • Category: 🌏 tinyterra/legacy
  • Output node: False

The ttN pipeLoaderSDXL node is designed for loading and initializing the state of a pipeline specifically tailored for SDXL models within the tinyterra ecosystem. It plays a crucial role in setting up the pipeline's initial state, managing data flow, and ensuring that the pipeline is ready for subsequent operations, such as sampling and image generation.

Input types

Required

  • ckpt_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • vae_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • lora1_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • lora1_model_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • lora1_clip_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • lora2_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • lora2_model_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • lora2_clip_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • refiner_ckpt_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • refiner_vae_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • refiner_lora1_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • refiner_lora1_model_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • refiner_lora1_clip_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • refiner_lora2_name
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • refiner_lora2_model_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • refiner_lora2_clip_strength
    • unknown
    • Comfy dtype: FLOAT
    • Python dtype: unknown
  • clip_skip
    • unknown
    • Comfy dtype: INT
    • Python dtype: unknown
  • positive
    • unknown
    • Comfy dtype: STRING
    • Python dtype: unknown
  • positive_token_normalization
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • positive_weight_interpretation
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • negative
    • unknown
    • Comfy dtype: STRING
    • Python dtype: unknown
  • negative_token_normalization
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • negative_weight_interpretation
    • unknown
    • Comfy dtype: COMBO[STRING]
    • Python dtype: unknown
  • empty_latent_width
    • unknown
    • Comfy dtype: INT
    • Python dtype: unknown
  • empty_latent_height
    • unknown
    • Comfy dtype: INT
    • Python dtype: unknown
  • batch_size
    • unknown
    • Comfy dtype: INT
    • Python dtype: unknown
  • seed
    • unknown
    • Comfy dtype: INT
    • Python dtype: unknown

Output types

  • sdxl_pipe
    • Comfy dtype: PIPE_LINE_SDXL
    • unknown
    • Python dtype: unknown
  • model
    • Comfy dtype: MODEL
    • unknown
    • Python dtype: unknown
  • positive
    • Comfy dtype: CONDITIONING
    • unknown
    • Python dtype: unknown
  • negative
    • Comfy dtype: CONDITIONING
    • unknown
    • Python dtype: unknown
  • vae
    • Comfy dtype: VAE
    • unknown
    • Python dtype: unknown
  • clip
    • Comfy dtype: CLIP
    • unknown
    • Python dtype: unknown
  • refiner_model
    • Comfy dtype: MODEL
    • unknown
    • Python dtype: unknown
  • refiner_positive
    • Comfy dtype: CONDITIONING
    • unknown
    • Python dtype: unknown
  • refiner_negative
    • Comfy dtype: CONDITIONING
    • unknown
    • Python dtype: unknown
  • refiner_vae
    • Comfy dtype: VAE
    • unknown
    • Python dtype: unknown
  • refiner_clip
    • Comfy dtype: CLIP
    • unknown
    • Python dtype: unknown
  • latent
    • Comfy dtype: LATENT
    • unknown
    • Python dtype: unknown
  • seed
    • Comfy dtype: INT
    • unknown
    • Python dtype: unknown
  • ui
    • Provides a user interface component, typically for displaying images generated by the pipeline, depending on the 'image_output' parameter settings.

Usage tips

  • Infra type: GPU
  • Common nodes: unknown

Source code

class ttN_pipeLoaderSDXL:
    version = '1.1.2'
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": { 
                        "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
                        "vae_name": (["Baked VAE"] + folder_paths.get_filename_list("vae"),),

                        "lora1_name": (["None"] + folder_paths.get_filename_list("loras"),),
                        "lora1_model_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
                        "lora1_clip_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),

                        "lora2_name": (["None"] + folder_paths.get_filename_list("loras"),),
                        "lora2_model_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
                        "lora2_clip_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),

                        "refiner_ckpt_name": (["None"] + folder_paths.get_filename_list("checkpoints"), ),
                        "refiner_vae_name": (["Baked VAE"] + folder_paths.get_filename_list("vae"),),

                        "refiner_lora1_name": (["None"] + folder_paths.get_filename_list("loras"),),
                        "refiner_lora1_model_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
                        "refiner_lora1_clip_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),

                        "refiner_lora2_name": (["None"] + folder_paths.get_filename_list("loras"),),
                        "refiner_lora2_model_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
                        "refiner_lora2_clip_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),

                        "clip_skip": ("INT", {"default": -2, "min": -24, "max": 0, "step": 1}),

                        "positive": ("STRING", {"default": "Positive","multiline": True}),
                        "positive_token_normalization": (["none", "mean", "length", "length+mean"],),
                        "positive_weight_interpretation": (["comfy", "A1111", "compel", "comfy++", "down_weight"],),

                        "negative": ("STRING", {"default": "Negative", "multiline": True}),
                        "negative_token_normalization": (["none", "mean", "length", "length+mean"],),
                        "negative_weight_interpretation": (["comfy", "A1111", "compel", "comfy++", "down_weight"],),

                        "empty_latent_width": ("INT", {"default": 1024, "min": 64, "max": MAX_RESOLUTION, "step": 8}),
                        "empty_latent_height": ("INT", {"default": 1024, "min": 64, "max": MAX_RESOLUTION, "step": 8}),
                        "batch_size": ("INT", {"default": 1, "min": 1, "max": 64}),
                        "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
                        },
                "hidden": {"prompt": "PROMPT", "ttNnodeVersion": ttN_pipeLoaderSDXL.version, "my_unique_id": "UNIQUE_ID"}}

    RETURN_TYPES = ("PIPE_LINE_SDXL" ,"MODEL", "CONDITIONING", "CONDITIONING", "VAE", "CLIP", "MODEL", "CONDITIONING", "CONDITIONING", "VAE", "CLIP", "LATENT", "INT",)
    RETURN_NAMES = ("sdxl_pipe","model", "positive", "negative", "vae", "clip", "refiner_model", "refiner_positive", "refiner_negative", "refiner_vae", "refiner_clip", "latent", "seed",)

    FUNCTION = "adv_pipeloader"
    CATEGORY = "🌏 tinyterra/legacy"

    def adv_pipeloader(self, ckpt_name, vae_name,
                       lora1_name, lora1_model_strength, lora1_clip_strength,
                       lora2_name, lora2_model_strength, lora2_clip_strength,
                       refiner_ckpt_name, refiner_vae_name,
                       refiner_lora1_name, refiner_lora1_model_strength, refiner_lora1_clip_strength,
                       refiner_lora2_name, refiner_lora2_model_strength, refiner_lora2_clip_strength,
                       clip_skip,
                       positive, positive_token_normalization, positive_weight_interpretation, 
                       negative, negative_token_normalization, negative_weight_interpretation, 
                       empty_latent_width, empty_latent_height, batch_size, seed, prompt=None, my_unique_id=None):

        def SDXL_loader(ckpt_name, vae_name,
                            lora1_name, lora1_model_strength, lora1_clip_strength,
                            lora2_name, lora2_model_strength, lora2_clip_strength,
                            positive, positive_token_normalization, positive_weight_interpretation, 
                            negative, negative_token_normalization, negative_weight_interpretation,):

            model: ModelPatcher | None = None
            clip: CLIP | None = None
            vae: VAE | None = None

            # Load models
            model, clip, vae = loader.load_checkpoint(ckpt_name)

            if lora1_name != "None":
                model, clip = loader.load_lora(lora1_name, model, clip, lora1_model_strength, lora1_clip_strength)

            if lora2_name != "None":
                model, clip = loader.load_lora(lora2_name, model, clip, lora2_model_strength, lora2_clip_strength)

            # Check for custom VAE
            if vae_name not in ["Baked VAE", "Baked-VAE"]:
                vae = loader.load_vae(vae_name)

            # CLIP skip
            if not clip:
                raise Exception("No CLIP found")

            clipped = clip.clone()
            if clip_skip != 0:
                clipped.clip_layer(clip_skip)

            positive = loader.nsp_parse(positive, seed, title="pipeLoaderSDXL positive", my_unique_id=my_unique_id)

            positive_embeddings_final, positive_pooled = advanced_encode(clipped, positive, positive_token_normalization, positive_weight_interpretation, w_max=1.0, apply_to_pooled='enable')
            positive_embeddings_final = [[positive_embeddings_final, {"pooled_output": positive_pooled}]]

            negative = loader.nsp_parse(negative, seed)

            negative_embeddings_final, negative_pooled = advanced_encode(clipped, negative, negative_token_normalization, negative_weight_interpretation, w_max=1.0, apply_to_pooled='enable')
            negative_embeddings_final = [[negative_embeddings_final, {"pooled_output": negative_pooled}]]

            return model, positive_embeddings_final, negative_embeddings_final, vae, clip

        # Create Empty Latent
        latent = sampler.emptyLatent(None, batch_size, empty_latent_width, empty_latent_height)
        samples = {"samples":latent}

        model, positive_embeddings, negative_embeddings, vae, clip = SDXL_loader(ckpt_name, vae_name,
                                                                                    lora1_name, lora1_model_strength, lora1_clip_strength,
                                                                                    lora2_name, lora2_model_strength, lora2_clip_strength,
                                                                                    positive, positive_token_normalization, positive_weight_interpretation,
                                                                                    negative, negative_token_normalization, negative_weight_interpretation)

        if refiner_ckpt_name != "None":
            refiner_model, refiner_positive_embeddings, refiner_negative_embeddings, refiner_vae, refiner_clip = SDXL_loader(refiner_ckpt_name, refiner_vae_name,
                                                                                                                                refiner_lora1_name, refiner_lora1_model_strength, refiner_lora1_clip_strength,
                                                                                                                                refiner_lora2_name, refiner_lora2_model_strength, refiner_lora2_clip_strength, 
                                                                                                                                positive, positive_token_normalization, positive_weight_interpretation,
                                                                                                                                negative, negative_token_normalization, negative_weight_interpretation)
        else:
            refiner_model, refiner_positive_embeddings, refiner_negative_embeddings, refiner_vae, refiner_clip = None, None, None, None, None

        image = ttNsampler.pil2tensor(Image.new('RGB', (1, 1), (0, 0, 0)))

        pipe = {"model": model,
                "positive": positive_embeddings,
                "negative": negative_embeddings,
                "vae": vae,
                "clip": clip,

                "refiner_model": refiner_model,
                "refiner_positive": refiner_positive_embeddings,
                "refiner_negative": refiner_negative_embeddings,
                "refiner_vae": refiner_vae,
                "refiner_clip": refiner_clip,

                "samples": samples,
                "images": image,
                "seed": seed,

                "loader_settings": {"ckpt_name": ckpt_name,
                                    "vae_name": vae_name,

                                    "lora1_name": lora1_name,
                                    "lora1_model_strength": lora1_model_strength,
                                    "lora1_clip_strength": lora1_clip_strength,
                                    "lora2_name": lora2_name,
                                    "lora2_model_strength": lora2_model_strength,
                                    "lora2_clip_strength": lora2_clip_strength,
                                    "lora3_name": None,
                                    "lora3_model_strength": None,
                                    "lora3_clip_strength": None,

                                    "refiner_ckpt_name": refiner_ckpt_name,
                                    "refiner_vae_name": refiner_vae_name,
                                    "refiner_lora1_name": refiner_lora1_name,
                                    "refiner_lora1_model_strength": refiner_lora1_model_strength,
                                    "refiner_lora1_clip_strength": refiner_lora1_clip_strength,
                                    "refiner_lora2_name": refiner_lora2_name,
                                    "refiner_lora2_model_strength": refiner_lora2_model_strength,
                                    "refiner_lora2_clip_strength": refiner_lora2_clip_strength,

                                    "clip_skip": clip_skip,
                                    "positive_balance": None,
                                    "positive": positive,
                                    "positive_l": None,
                                    "positive_g": None,
                                    "positive_token_normalization": positive_token_normalization,
                                    "positive_weight_interpretation": positive_weight_interpretation,
                                    "negative_balance": None,
                                    "negative": negative,
                                    "negative_l": None,
                                    "negative_g": None,
                                    "negative_token_normalization": negative_token_normalization,
                                    "negative_weight_interpretation": negative_weight_interpretation,
                                    "empty_latent_width": empty_latent_width,
                                    "empty_latent_height": empty_latent_height,
                                    "batch_size": batch_size,
                                    "seed": seed,
                                    "empty_samples": samples,}
        }

        return (pipe, model, positive_embeddings, negative_embeddings, vae, clip, refiner_model, refiner_positive_embeddings, refiner_negative_embeddings, refiner_vae, refiner_clip, samples, seed)