Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't abandon job on bad lora file #331

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions hordelib/nodes/node_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
return (model, clip)

lora_path = folder_paths.get_full_path("loras", lora_name)

lora = None
if self.loaded_lora is not None:
if self.loaded_lora[0] == lora_path:
Expand All @@ -69,13 +68,18 @@ def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
self.loaded_lora = None
del temp

if lora is None:
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
self.loaded_lora = (lora_path, lora)

model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
log_free_ram()
return (model_lora, clip_lora)
try:
with logger.catch(reraise=True):
if lora is None:
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
self.loaded_lora = (lora_path, lora)

model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
log_free_ram()
return (model_lora, clip_lora)
except Exception as e:
logger.error(f"Error loading lora {lora_name}: {e}")
return (model, clip)


NODE_CLASS_MAPPINGS = {"HordeLoraLoader": HordeLoraLoader}
Loading