sylym / comfy_vid2vid

Apache License 2.0
67 stars 12 forks source link

was updated: ComfyUI/comfy/sd.py please adapt routine and import #9

Closed noo300 closed 1 year ago

noo300 commented 1 year ago

a function inside comfyUI was updated: def load_lora_for_models(model, clip, lora, strength_model, strength_clip) please adapt D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy_vid2vid\sd.py accordingly

https://github.com/sylym/comfy_vid2vid/blob/main/sd.py#L263-L272 https://github.com/comfyanonymous/ComfyUI/blob/90aa59709985ffa1b02b6330b7720ed399fbf4df/comfy/sd.py#L432-446

def load_lora_for_models(model, clip, lora, strength_model, strength_clip): key_map = _model_lora_keysunet(model.model) key_map = _model_lora_keysclip(clip.cond_stage_model, key_map) loaded = load_lora(lora, key_map) new_modelpatcher = model.clone() k = new_modelpatcher.add_patches(loaded, strength_model) new_clip = clip.clone() k1 = new_clip.add_patches(loaded, strength_clip) k = set(k) k1 = set(k1) for x in loaded: if (x not in k) and (x not in k1): print("NOT LOADED", x) return (new_modelpatcher, new_clip)

https://github.com/sylym/comfy_vid2vid/blob/main/sd.py#L3C2-L3C2 from comfy.sd import load_model_weights, ModelPatcher, VAE, CLIP, _model_lora_keys_unet, model_lora_keysclip

elsewise error get's thrown:

Traceback (most recent call last): File "D:\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1647, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy_vid2vid__init__.py", line 8, in from .sd import load_checkpoint_guess_config, load_lora_for_models File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy_vid2vid\sd.py", line 3, in from comfy.sd import load_model_weights, ModelPatcher, VAE, CLIP, model_lora_keys ImportError: cannot import name 'model_lora_keys' from 'comfy.sd' (D:\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

Cannot import D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy_vid2vid module for custom nodes: cannot import name 'model_lora_keys' from 'comfy.sd' (D:\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

newone111 commented 10 months ago

solution: \ComfyUI\custom_nodes\comfy_vid2vid\sd.py need to be changed:

from comfy import model_management from comfy.model_patcher import ModelPatcher from comfy.lora import model_lora_keys_unet, model_lora_keys_clip from comfy.sd import load_model_weights, VAE, CLIP from comfy import utils from comfy import clip_vision from comfy.ldm.util import instantiate_from_config from .convert_from_ckpt import convert_unet_checkpoint from omegaconf import OmegaConf