![見出し画像](https://assets.st-note.com/production/uploads/images/86864894/rectangle_large_type_2_e776d6b5d0cfc632f5f664a81a8d7b7e.png?width=1200)
Deforum Diffusion と Waifu Diffusion によるAI動画生成
「Deforum Diffusion」と「Waifu Diffusion」によるAI動画生成を試したので、手順をまとめました。
・Deforum Stable Diffusion v0.4
・Waifu Diffusion v1.2
#DeforumDiffusion #deforum #stablediffusion pic.twitter.com/OIEcVsKMCI
— 布留川英一 / Hidekazu Furukawa (@npaka123) September 14, 2022
1. Deforum Stable Diffusion
「Deforum Stable Diffusion」は、「Stable Diffusion」でズームやシフトさせながら画像生成を繰り返すことで、印象的な動画を作成できるColabノートブックです。
以下のColabノートブックを開いて、上から順番に実行していくことで動画生成することができます。
・Deforum Stable Diffusion v0.4
2. Setup
(1) 「NVIDIA GPU」のセルを実行。
Colabに割り当てられたGPUの情報が表示されます。
Tesla P100-PCIE-16GB, 16280 MiB, 16280 MiB
(2) 「Model and Output Paths」のセルを実行。
Googleドライブにマウントし、以下のフォルダが生成されます。
・モデルフォルダ : /content/drive/MyDrive/AI/models
・出力フォルダ : /content/drive/MyDrive/AI/StableDiffusion
モデルフォルダに使用する「Waifu Diffusion」のモデル (wd-v1-2-full-ema.chkpt) を配置します。以下のリンク先の「Download Link」からダウンロードできます。
・wd-v1-2-full-ema.chkpt
「Stable Diffusion」を使いたい場合は、以下のサイトから「Stable Diffusion」のモデル (sd-v1-4-full-ema.chkpt) を取得して配置します。
・sd-v1-4-full-ema.chkpt
(3) 「Setup Environment」のセルを実行。
パッケージがインストールされます。
(4) 「Python Definitions」のセルを実行。
パッケージがインストールされます。
(5) 「Select and Load Model」のセルを以下のように設定して実行。
「Waifu Diffusion」のモデルを設定します。
・model_checkpoint : custom
・model_checkpoint_path : /content/drive/MyDrive/AI/models/wd-v1-2-full-ema.ckpt
「Stable Diffusion」を使いたい場合は、以下のように設定します。
・model_checkpoint : sd-v1-4-full-ema.chkpt
3. Settings
(1) 「Animation Settings」のセルを次のように設定して実行。
アニメの各種設定を行います。
・Animation : アニメの基本設定
None / 2D / 3D / Video Input / Interpolation の5つのアニメ種類から選択
・Motion Parameters : モーション (ズーム、移動、回転など)
・Coherence : 位相
・3D Depth Warping : 3Dアニメ
・Vide Input : ビデオ入力
・Interpolation : 補完
・Resume Animation : アニメを再開
今回は、ズームのみを行うので、以下のように設定します。
・Animation :
・animation_mode : 2D
・max_frames : 50 ※ 50枚の画像を生成
・Motion Parameters :
・zoom : 0:(1.04) ※ 初期値のまま
(2) 「Prompts」のセルを次のように設定して実行。
「prompts」はアニメ種別がNoneの時、「animation_prompts」はそれ以外の時に利用するプロンプトを設定します。「animation_prompts」には何フレーム目に適用するかも指定します。
今回は、ファンタジー世界の動画を作成したいので、「animation_prompts」を「0: "world of made in abyss"」としました。
prompts = [
"a beautiful forest by Asher Brown Durand, trending on Artstation", #the first prompt I want
"a beautiful portrait of a woman by Artgerm, trending on Artstation", #the second prompt I want
#"the third prompt I don't want it I commented it with an",
]
animation_prompts = {
0: "world of made in abyss",
}
4. Run
(1) 「Run」のセルを次のように設定して実行。
出力フォルダに50枚 (max_framesの数) の画像ファイルが生成されます。
5. Create video from frames
(1) 「Create video from frames」のセルを「skip_video_for_run_all」のチェックをはずしてから実行。
出力フォルダの画像ファイルから動画ファイルが生成されます。