mirror of
https://github.com/jags111/efficiency-nodes-comfyui.git
synced 2026-03-25 15:15:45 -03:00
Efficient Loader SDXL Patch
Fixed issue where conditioning was not properly encoded by Efficient Loader and XY-Plots.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# by Luciano Cirino (Discord: TSC#9184) - April 2023
|
# by Luciano Cirino (Discord: TSC#9184) - April 2023
|
||||||
|
|
||||||
from comfy.sd import ModelPatcher, CLIP, VAE
|
from comfy.sd import ModelPatcher, CLIP, VAE
|
||||||
from nodes import common_ksampler, CLIPSetLastLayer
|
from nodes import common_ksampler, CLIPSetLastLayer, CLIPTextEncode
|
||||||
|
|
||||||
from torch import Tensor
|
from torch import Tensor
|
||||||
from PIL import Image, ImageOps, ImageDraw, ImageFont
|
from PIL import Image, ImageOps, ImageDraw, ImageFont
|
||||||
@@ -117,15 +117,16 @@ class TSC_EfficientLoader:
|
|||||||
###print_loaded_objects_entries()
|
###print_loaded_objects_entries()
|
||||||
|
|
||||||
# CLIP skip
|
# CLIP skip
|
||||||
if not clip:
|
clip = CLIPSetLastLayer().set_last_layer(clip, clip_skip)[0]
|
||||||
raise Exception("No CLIP found")
|
|
||||||
clip = clip.clone()
|
# Encode Conditionings
|
||||||
clip.clip_layer(clip_skip)
|
positive_encoded = CLIPTextEncode().encode(clip, positive)[0]
|
||||||
|
negative_encoded = CLIPTextEncode().encode(clip, negative)[0]
|
||||||
|
|
||||||
# Data for XY Plot
|
# Data for XY Plot
|
||||||
dependencies = (vae_name, ckpt_name, clip, clip_skip, positive, negative, lora_params)
|
dependencies = (vae_name, ckpt_name, clip, clip_skip, positive, negative, lora_params)
|
||||||
|
|
||||||
return (model, [[clip.encode(positive), {}]], [[clip.encode(negative), {}]], {"samples":latent}, vae, clip, dependencies, )
|
return (model, positive_encoded, negative_encoded, {"samples":latent}, vae, clip, dependencies, )
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
# TSC LoRA Stacker
|
# TSC LoRA Stacker
|
||||||
@@ -733,7 +734,9 @@ class TSC_KSampler:
|
|||||||
# Encode prompt and apply clip_skip. Return new conditioning.
|
# Encode prompt and apply clip_skip. Return new conditioning.
|
||||||
def encode_prompt(positive_prompt, negative_prompt, clip, clip_skip):
|
def encode_prompt(positive_prompt, negative_prompt, clip, clip_skip):
|
||||||
clip = CLIPSetLastLayer().set_last_layer(clip, clip_skip)[0]
|
clip = CLIPSetLastLayer().set_last_layer(clip, clip_skip)[0]
|
||||||
return [[clip.encode(positive_prompt), {}]], [[clip.encode(negative_prompt), {}]]
|
positive_encoded = CLIPTextEncode().encode(clip, positive_prompt)[0]
|
||||||
|
negative_encoded = CLIPTextEncode().encode(clip, negative_prompt)[0]
|
||||||
|
return positive_encoded, negative_encoded
|
||||||
|
|
||||||
# Variable to track wether to encode prompt or not
|
# Variable to track wether to encode prompt or not
|
||||||
encode = False
|
encode = False
|
||||||
|
|||||||
Reference in New Issue
Block a user