Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
eb96ff0d
Unverified
Commit
eb96ff0d
authored
Apr 29, 2024
by
Dhruv Nair
Committed by
GitHub
Apr 29, 2024
Browse files
Safetensor loading in AnimateDiff conversion scripts (#7764)
* update * update
parent
a38dd795
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
scripts/convert_animatediff_motion_lora_to_diffusers.py
scripts/convert_animatediff_motion_lora_to_diffusers.py
+5
-2
scripts/convert_animatediff_motion_module_to_diffusers.py
scripts/convert_animatediff_motion_module_to_diffusers.py
+6
-1
No files found.
scripts/convert_animatediff_motion_lora_to_diffusers.py
View file @
eb96ff0d
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
):
...
...
@@ -34,6 +34,9 @@ def get_args():
if
__name__
==
"__main__"
:
args
=
get_args
()
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
():
...
...
scripts/convert_animatediff_motion_module_to_diffusers.py
View file @
eb96ff0d
import
argparse
import
torch
from
safetensors.torch
import
load_file
from
diffusers
import
MotionAdapter
...
...
@@ -38,7 +39,11 @@ def get_args():
if
__name__
==
"__main__"
:
args
=
get_args
()
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"
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment