Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions scripts/convert_animatediff_motion_lora_to_diffusers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse

import torch
from safetensors.torch import save_file
from safetensors.torch import load_file, save_file


def convert_motion_module(original_state_dict):
Expand Down Expand Up @@ -34,7 +34,10 @@ def get_args():
if __name__ == "__main__":
args = get_args()

state_dict = torch.load(args.ckpt_path, map_location="cpu")
if args.ckpt_path.endswith(".safetensors"):
state_dict = load_file(args.ckpt_path)
else:
state_dict = torch.load(args.ckpt_path, map_location="cpu")

if "state_dict" in state_dict.keys():
state_dict = state_dict["state_dict"]
Expand Down
7 changes: 6 additions & 1 deletion scripts/convert_animatediff_motion_module_to_diffusers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse

import torch
from safetensors.torch import load_file

from diffusers import MotionAdapter

Expand Down Expand Up @@ -38,7 +39,11 @@ def get_args():
if __name__ == "__main__":
args = get_args()

state_dict = torch.load(args.ckpt_path, map_location="cpu")
if args.ckpt_path.endswith(".safetensors"):
state_dict = load_file(args.ckpt_path)
else:
state_dict = torch.load(args.ckpt_path, map_location="cpu")

if "state_dict" in state_dict.keys():
state_dict = state_dict["state_dict"]

Expand Down