mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-04-24 15:06:17 +00:00
sdxl modelcode
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import torch
|
||||
|
||||
def SDXLTextEncoder2StateDictConverter(state_dict):
|
||||
new_state_dict = {}
|
||||
for key in state_dict:
|
||||
if key.startswith("text_model.") and "position_ids" not in key:
|
||||
if key == "text_projection.weight":
|
||||
val = state_dict[key]
|
||||
new_state_dict["model.text_projection.weight"] = val.float() if val.dtype == torch.float16 else val
|
||||
elif key.startswith("text_model.") and "position_ids" not in key:
|
||||
new_key = "model." + key
|
||||
new_state_dict[new_key] = state_dict[key]
|
||||
val = state_dict[key]
|
||||
new_state_dict[new_key] = val.float() if val.dtype == torch.float16 else val
|
||||
return new_state_dict
|
||||
|
||||
Reference in New Issue
Block a user