変換用スクリプト
ファイル名は「convert_animatediff_motion_module_to_diffusers.py」です。こちらのスクリプトです。github.com
変換方法
python convert_animatediff_motion_module_to_diffusers.py ` --ckpt_path v3_sd15_mm.ckpt ` --use_motion_mid_block ` --output_path animatediff-motion-module-v1-5-3 ` --motion_max_seq_length 32
「use_motion_mid_block」に関しては良くわかりませんが、付けても付けなくても生成動画の結果はあまり変わりませんでした。
Domain Adapter LoRAについて
v3では「v3_sd15_adapter.ckpt」というLoRAファイルを使った方が良いとされています。こちらのファイルは変換なしで、そのままDiffusersで読み込めました。Pythonスクリプト
import torch from diffusers import MotionAdapter, AnimateDiffPipeline, DDIMScheduler, AutoencoderKL from diffusers.utils import export_to_gif adapter = MotionAdapter.from_pretrained("animatediff-motion-module-v1-5-3") model_id = "model/yabalMixTrue25Dv4_ema" pipe = AnimateDiffPipeline.from_pretrained( model_id, motion_adapter=adapter, vae=AutoencoderKL.from_single_file("vae/vae-ft-mse-840000-ema-pruned.safetensors") ) pipe.scheduler = DDIMScheduler.from_pretrained( model_id, subfolder="scheduler", beta_schedule="linear", clip_sample=False, timestep_spacing="linspace", steps_offset=1 ) pipe.load_lora_weights("lora/more_details.safetensors", adapter_name="details") pipe.load_lora_weights("lora/v3_sd15_adapter.ckpt", adapter_name="domain") pipe.set_adapters(["details", "domain"], adapter_weights=[0.6, 1.0]) # enable memory savings pipe.enable_vae_slicing() pipe.enable_model_cpu_offload() output = pipe( prompt="a girl, dancing, blue denim, white plain t-shirt, best quality, extremely detailed", negative_prompt="longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", num_frames=16, guidance_scale=8.5, num_inference_steps=40, generator=torch.manual_seed(1000000000), ) frames = output.frames[0] export_to_gif(frames, "animation.gif")
結果
v2との比較
v2の結果はこちらです。support-touchsp.blogspot.com
「a girl, dancing, blue denim, white plain t-shirt」というプロンプトですがTシャツまで青くなってしまっていました。
v3ではプロンプトに忠実になっています。
「guidance_scale」などの設定で何とでもなるのかも知れませんが・・・。