made available comfyui clip

No more need to download tokenizers and text encoders, now we can use comfyui clip loader
This commit is contained in:
GiusTex
2024-10-20 20:37:29 +02:00
committed by GitHub
parent a5e413b575
commit 74cf628e4e
+2 -17
View File
@@ -8,7 +8,7 @@ from PIL import Image
from folder_paths import map_legacy, folder_names_and_paths
from .controlnet_union import ControlNetModel_Union
from .pipeline_fill_sd_xl import encode_prompt, StableDiffusionXLFillPipeline
from .pipeline_fill_sd_xl import StableDiffusionXLFillPipeline
from diffusers import AutoencoderKL, TCDScheduler
from diffusers.models.model_loading_utils import load_state_dict
from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
@@ -94,22 +94,6 @@ def clearVram(device):
# torch.ipc_collect() not available, and ipc_collect seems available only for cuda
def encodeDiffOutpaintPrompt(model_path, dtype, final_prompt, device):
tokenizer, tokenizer_2, text_encoder, text_encoder_2 = loadDiffModels1(model_path, dtype, device)
(prompt_embeds,
negative_prompt_embeds,
pooled_prompt_embeds,
negative_pooled_prompt_embeds,
) = encode_prompt(final_prompt, tokenizer, tokenizer_2, text_encoder, text_encoder_2, device, True)
del tokenizer, tokenizer_2, text_encoder, text_encoder_2
clearVram(device)
return prompt_embeds, negative_prompt_embeds, pooled_prompt_embeds, negative_pooled_prompt_embeds
def loadControlnetModel(device, dtype, controlnet_path):
config_file = f"{controlnet_path}/config_promax.json"
config = ControlNetModel_Union.load_config(config_file)
@@ -179,6 +163,7 @@ def diffuserOutpaintSamples(model_path, controlnet_model, diffuser_outpaint_cnet
controlnet_conditioning_scale=controlnet_strength,
guidance_scale=guidance_scale,
device=device,
dtype=dtype,
keep_model_device=keep_model_device,
))