Skip to content

Commit

Permalink
fix: don't abandon job on bad lora file
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Sep 17, 2024
1 parent 4be1548 commit ba9456e
Showing 1 changed file with 12 additions and 8 deletions.
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}

0 comments on commit ba9456e

Please sign in to comment.