Skip to content

Commit c5a32f7

Browse files
authored
Merge pull request #509 from modelscope/wan-lora-converter
Update lora.py
2 parents 803ddcc + c4ed3d3 commit c5a32f7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

diffsynth/models/lora.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,22 @@ def guess_block_id(name):
365365
else:
366366
state_dict_[name] = param
367367
return state_dict_
368+
369+
370+
class WanLoRAConverter:
371+
def __init__(self):
372+
pass
373+
374+
@staticmethod
375+
def align_to_opensource_format(state_dict, **kwargs):
376+
state_dict = {"diffusion_model." + name.replace(".default.", "."): param for name, param in state_dict.items()}
377+
return state_dict
368378

379+
@staticmethod
380+
def align_to_diffsynth_format(state_dict, **kwargs):
381+
state_dict = {name.replace("diffusion_model.", "").replace(".lora_A.weight", ".lora_A.default.weight").replace(".lora_B.weight", ".lora_B.default.weight"): param for name, param in state_dict.items()}
382+
return state_dict
383+
369384

370385
def get_lora_loaders():
371386
return [SDLoRAFromCivitai(), SDXLLoRAFromCivitai(), FluxLoRAFromCivitai(), HunyuanVideoLoRAFromCivitai(), GeneralLoRAFromPeft()]

0 commit comments

Comments
 (0)