Skip to content
7 changes: 7 additions & 0 deletions src/diffusers/loaders/single_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,13 @@ def swap_scale_shift(weight):


def convert_cosmos_transformer_checkpoint_to_diffusers(checkpoint, **kwargs):

for k in list(checkpoint.keys()):
if "llm_adapter" in k:
_ = checkpoint.pop(k)
else:
checkpoint[k.removeprefix("model.diffusion_model.")] = checkpoint.pop(k)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if it would be more appropriate to implement the prefix removal below where the net. prefix is removed. Not sure about this


converted_state_dict = {key: checkpoint.pop(key) for key in list(checkpoint.keys())}

def remove_keys_(key: str, state_dict):
Expand Down
Loading