From 85bd6dfccbf7ff85ad50d9569c725d2cb39a4b03 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Fri, 3 May 2024 01:00:33 +0300 Subject: [PATCH] import fixes --- nodes/intrinsic_lora_nodes.py | 4 ++-- nodes/nodes.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nodes/intrinsic_lora_nodes.py b/nodes/intrinsic_lora_nodes.py index 3e41181..798cf74 100644 --- a/nodes/intrinsic_lora_nodes.py +++ b/nodes/intrinsic_lora_nodes.py @@ -2,7 +2,7 @@ import folder_paths import os import torch import torch.nn.functional as F -from comfy.utils import ProgressBar +from comfy.utils import ProgressBar, load_torch_file import comfy.sample from nodes import CLIPTextEncode @@ -82,7 +82,7 @@ with this node pack. #load lora model_clone = model.clone() lora_path = folder_paths.get_full_path("intristic_loras", lora_name) - lora = comfy.utils.load_torch_file(lora_path, safe_load=True) + lora = load_torch_file(lora_path, safe_load=True) self.loaded_lora = (lora_path, lora) model_clone_with_lora = comfy.sd.load_lora_for_models(model_clone, None, lora, 1.0, 0)[0] diff --git a/nodes/nodes.py b/nodes/nodes.py index f0c653f..154345a 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -2195,9 +2195,10 @@ class StableZero123_BatchSchedule: CATEGORY = "KJNodes/experimental" def encode(self, clip_vision, init_image, vae, width, height, batch_size, azimuth_points_string, elevation_points_string, interpolation): + from comfy.utils import common_upscale output = clip_vision.encode_image(init_image) pooled = output.image_embeds.unsqueeze(0) - pixels = comfy.utils.common_upscale(init_image.movedim(-1,1), width, height, "bilinear", "center").movedim(1,-1) + pixels = common_upscale(init_image.movedim(-1,1), width, height, "bilinear", "center").movedim(1,-1) encode_pixels = pixels[:,:,:,:3] t = vae.encode(encode_pixels) @@ -2488,9 +2489,10 @@ class LoadResAdapterNormalization: raise Exception("Invalid model path") else: print("ResAdapter: Loading ResAdapter normalization weights") + from comfy.utils import load_torch_file prefix_to_remove = 'diffusion_model.' model_clone = model.clone() - norm_state_dict = comfy.utils.load_torch_file(resadapter_full_path) + norm_state_dict = load_torch_file(resadapter_full_path) new_values = {key[len(prefix_to_remove):]: value for key, value in norm_state_dict.items() if key.startswith(prefix_to_remove)} print("ResAdapter: Attempting to add patches with ResAdapter weights") try: