The Tale of the Princess Kaguya 🎥 Wan2.1-T2V-14B

詳細

ファイルをダウンロード

モデル説明

概要

『かぐや姫の物語』(2013年)は、高畑勲が日本の最古の伝承『竹取物語』を美しく再解釈した作品である。物語は、貧しい竹取りとその妻が竹の茎から見つけた天界の存在の赤ん坊を主人公としている。彼女が見事な若女房へと成長するにつれ、高貴な社会の厳格な期待に抗いながら、簡素な田舎での幼少期に求めた自由を切望する。本作は、アイデンティティ、自由、人生の儚さという問いを掘り下げ、私たちが本当に人生から何を求めており、幸せを本当に得ることができるのかを省察する作品となっている。

この映画を真に特別なものにしているのは、伝統的な日本の墨絵や木版画から多くの影響を受けた驚異的な視覚スタイルである。高畑は、時に「未完成」にすら見えるミニマリストで手描きのアプローチを意図的に選んだ。この「粗さ」が却って物語に深く引き込む。水彩による背景は柔らかく夢幻的であり、キャラクターのアニメーションは書道的な線で構成され、感情の高まりに応じて流れるように優雅に、あるいは鋭く不規則に変化する。この芸術的選択は単に美しく見えるだけでなく、何世紀にもわたる日本の芸術伝統とつながりながら、私たちが慣れ親しんできた洗練されたコンピュータ生成のアニメーションから一線を画している。高畑が不完全さを受け入れ、観客の想像力に隙間を埋めさせる点に力強さがある。その結果、古代的でありながらまったく新鮮に感じられる映画が生まれ、広範な批評的称賛を浴び、史上最高のアニメーション映画の一つとして確立された。

説明

このLoRAは、Redlineと同様に、単一の静止フレームでは完全に表現できないアニメーションスタイルのシリーズを継承している。また、Wanのデフォルトの3Dレンダリングバイアスからさらに離脱しようと試みている(完全には成功していないが)——完全に2D手描きアニメーションスタイルに置き換えようとしている。目標は、視覚的審美だけでなく、動き、テンポ、構図、全体的なエネルギーを変革することだった。もちろん、小さなLoRA一つだけではこれらすべてを達成することはできない。

🙂 しかし、このモデルは予想以上に良好にスタイルを学習し、『かぐや姫の物語』のスタイルにおける以下の特徴をコピーしている:簡素化された風景、余白の賢明な使い方、墨絵風の描き方、未完成な絵画の効果、衣装の曲線、感情の描写、動き、静けさ、ミニマリズムである。このモデルは、本物の風景や人物だけでなく、未来のシーン、中世の風景、現代の風景などもよく一般化して描写する。

🙁 テスト中にのみ発見し、修正できなかった小さな欠点がある:一部の動画で、特定のオブジェクトに奇妙な光沢が現れることがある。以前のチェックポイント(15K〜19Kステップなど)でもこの効果が見られるため、これは過学習ではない(LoRAは特定の構造のフレーム存在に対してバイアスを持たず、過学習を示唆するようなものではない。データセットのキャプション自体がプロンプトとして使用されると、元のデータセットとはまったく異なる動画を生成する可能性がある)。最適化(Sage Attentionなど)を無効にしたり、サンプリングパラメータを調整しても大きな効果はない。LoRAの強度を下げればこの効果を軽減できるが、ターゲットスタイルからさらに遠ざかってしまう。LoRAのブロックを一部無効にしてこの効果を打ち消そうとしたが、効果は得られなかった。

この効果の最も悪い点は、まったく予測不能であり、その原因を理解できないという点である。私の最良の推測は、このスタイルに内在するある暗黙のパターン(たとえば、ほとんど影のない柔らかく拡散した照明)を、モデルがデータセットに含まれていない対象物に補間・再現しようとして、不適切に処理しているということだ。『かぐや姫の物語』のスタイルでは、太陽の眩しさ、ブローム、鏡面ハイライトのような強い方向性照明は存在しない。そのため、モデルに照明源を示唆するシーンをプロンプトすると、学習された表現と事前知識の間で矛盾が生じ、「幻覚」的に柔らかい光、エッジのブローム、薄い光沢といった視覚的要素を生成してしまう。

⌛ もし私がこの効果の明確な原因を突き止められれば、LoRAを再学習(またはキャリブレーション後のチューニング)します。 しかし、このモデルの作成は長く疲労を伴い、今はさらに2〜3週間の無駄な実験を続ける余裕がありません。

使用方法

プロンプトに「Kaguya-hime style」を追加してください。トリガーワードなしでも動作する可能性がありますが、私はいつも追加しており、トリガーワードなしでの動作はテストしていないため、その挙動は不明です。

私はKijaiのラッパーを使用していますが、ネイティブワークフローでも動作するはずです。

すべての動画はベースモデルのWanVideo2.1-14B-T2Vで生成され、それぞれの動画には組み込まれたComfyUIワークフローが含まれています。

ワークフローのJSON例はこちらにあります。

データセット

データセットは映画『かぐや姫の物語』から取得しました。PySceneDetectで分割し、クリップを16fpsに変換して、手動で295本を選択しました。より良い選択は、その数を削減(100〜150本程度)することだったかもしれません。このような大量のクリップは、多様なデータセットの場合にのみ正当化されます。私の場合は、各クリップが芸術的な一画であり、どの部分を残し、どの部分を削るかを決めるのが非常に難しかったため、減らすことができませんでした。また、これらの動画からffmpegで約1000フレームを抽出し、その中から手動で240枚を選んで高解像度画像データセットを構成しました。

データセットの構造は、Wanが学習に使用した元データのバケット構造(公式WanVideoレポートによると)を模倣するように意図されました。元データには720p、480p、192pの動画と画像が含まれていたため、以下のように構成しました:

1️⃣ データセットの第一部分は、255枚の画像で、元解像度は1920x1040、訓練解像度は1328x720px(720p)です。

画像は以下のプロンプトでQwen2.5-VL-7B-Instructを用いてキャプション付けました:

You are an expert visual-scene describer.
For the following animated frame (a still extracted from a video scene), write a detailed, highly descriptive caption that:
- Is around 80-100 words long.
- Begins with the exact phrase: "Kaguya-hime style".
- Uses present-tense, simple, concise and concrete language that describes only what is visible in the frame.
- Follows the order "Subject → Scene → Implied Motion/Atmosphere" (e.g., "Kaguya-hime style, a small boy in a gray tunic stands beside a wooden gate at dawn, morning mist wafts around the thatched roofs behind him.").
- Includes precise details (age, gender, clothing color, major objects, environment, weather, time of day).
- Contains no emotional adjectives, no abstract narrative, and no style words except the required prefix.
- For scenes with multiple subjects, focuses on the primary figure(s) in the action.
Use the following template: "Kaguya-hime style, [optional shot type (close-up, medium shot, wide shot)] of a [subject with visual details] [pose/static position or gentle implied action]. [Detailed setting]. [Subtle dynamic element or atmospheric cue (wind, drifting petals, rippling water, lantern glow) to avoid static feel]. [Additional visual context or background detail]." (example: "Kaguya-hime style, an elderly craftsman in a worn gray kimono carves a wooden figure in a humble workshop. Light dust particles floating in the sunbeams. Tools and wood shavings scatter across the low table. Shadows lengthen across the tatami floor.")

2️⃣ データセットの第二部分は、295本のクリップで、元解像度は1920x1040、訓練解像度は880x480px(480p)です。データセット構成では以下のように指定しました:

  • frame_extraction = "head" および target_frames = [13]

    (この解像度でのRTX 3090でのトレーニング速度を落とさずに使用可能な最大フレーム数です。)

この部分のデータセットもQwen2.5-VL-7B-Instructと以下のプロンプト(詳細なキャプションを強制し、細部に焦点を当てる)でキャプション付けました:

You are an expert visual-scene describer.
For the following animated video clip, write a detailed, highly descriptive caption that:
- Is around 80-100 words long.
- Begins with the exact phrase: "Kaguya-hime style".
- Uses present-tense, simple, concise and concrete language that describes only what is visible on-screen.
- Follows the order "Subject → Scene → Motion/Camera" (e.g., "Kaguya-hime style, a young woman in a white kimono. She walks through a moonlit bamboo grove. Camera pans slowly as fireflies drift around her.")
- Includes camera movement when visible (pans, zooms, tilts). If no obvious camera movement, focus on subject and environmental motion
- Includes precise details (age, gender, clothing color, major objects, environment, weather, time of day, camera movement).
- Contains no emotional adjectives, no abstract narrative, and no style words except the required prefix.
- For scenes with multiple subjects, focuses on the primary figure(s) in the action.
- Emphasizes any visible motion, including subtle movements like fabric swaying, particle effects, or environmental changes.
Use the following template: "Kaguya-hime style, [optional shot type, if clear] of a [subject description with visual details] [action/motion]. [Detailed setting description]. [Camera movement]. [Additional background elements or atmospheric details]." (example: "Kaguya-hime style, medium shot of a young woman with long black hair in a simple white kimono walking slowly through a bamboo forest at dusk. Camera panning alongside her. Golden light filters through the swaying bamboo stalks. Fallen leaves scatter in her path.")

3️⃣ 第三部分では、同じ295本の動画を使用し、訓練解像度は352x192px(192p)としました。使用可能な最大フレーム数は49でした。これらの動画は3つのグループに分けられました:

  • 34〜49フレーム:target_frames = [33], frame_extraction = "uniform", frame_sample = 2

  • 50〜100フレーム:target_frames = [49], frame_extraction = "uniform", frame_sample = 2

  • 101〜160フレーム:target_frames = [49], frame_extraction = "uniform", frame_sample = 3

この部分のデータセットもQwen2.5-VL-7B-Instructと以下のプロンプト(簡潔なキャプションを強制し、細部には焦点を当てない)でキャプション付けました:

You are an expert visual-scene describer for animated video clips in the elegant, ink-wash-inspired aesthetic. Write a one-sentence caption, 15-30 words, following this template:
"Kaguya-hime style, [main subject] [action/movement or state] in/on [specific location with background elements], with [vivid details: color, lighting, weather, atmosphere], during [time of day or context-appropriate temporal description]."
Example: "Kaguya-hime style, a lone samurai wanders through a misty bamboo grove, with moonlight casting soft shadows, during a tranquil midnight, evoking timeless ink-wash serenity."
Requirements:
- Identify the primary subject (e.g., character, animal, object).
- Describe its main action, movement, or state (use vivid verbs or adjectives).
- Specify the setting, including background elements (e.g., forests, rivers, architecture, or abstract motifs if minimal).
- Include rich visual details (e.g., shimmering moonlight, vibrant hues, misty air).
- Indicate time of day (e.g., dawn, twilight) or a fitting temporal context (e.g., "eternal night" for fantastical scenes).
- If the scene lacks a clear subject or time, prioritize vivid setting and atmosphere.
- Ensure captions are concise, evocative, and flow naturally.

すべてのキャプションは手動でチェックし(多くの修正が必要でした)。一部のキャラクターには明示的にタグ付けしました(「Takenoko」、「Menowarawa」、「Sutemaru」)が、これは単なる趣味の範囲です。これらのタグを使用しても、正確なキャラクターが再現されることは保証されません。実際、スタイルLoRAのキャラクターキャプションとして理想的な方法ではありません。より適切な方法は、フレーム内でキャラクターが唯一の主役である場合にのみタグを付けることです。しかし、今回は「平均的なスタイル」を再現することが主目的だったため、この方法でも十分でした。

🗃️ 以下はデータセット構成の完全なtomlファイルです(注:データセットの第二部分(480p動画)も、構成内では3つのセクションに分かれていますが、すべてのセクションでパラメータは同一です。これは、192pバージョンでクリップが3つの期間別フォルダ(34–49、50–100、101–160フレーム)に既に分類されていたため、480pバージョンでも一貫性と管理の容易さを確保するため同じフォルダ構造を再利用したためです):

[general]
enable_bucket = true
bucket_no_upscale = true

[[datasets]]
image_directory = "H:/datasets/princess_kaguya/images/1920x1040/1"
cache_directory = "H:/datasets/princess_kaguya/images/1920x1040/1/cache_highres"
caption_extension = ".highres"
resolution = [1328, 720]
batch_size = 1
num_repeats = 1

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/34-49" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/34-49/cache_mediumres" caption_extension = ".mediumres" resolution = [880, 480] batch_size = 1 num_repeats = 1 frame_extraction = "head" target_frames = [13]

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/50-100" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/50-100/cache_mediumres" caption_extension = ".mediumres" resolution = [880, 480] batch_size = 1 num_repeats = 1 frame_extraction = "head" target_frames = [13]

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/101-160" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/101-160/cache_mediumres" caption_extension = ".mediumres" resolution = [880, 480] batch_size = 1 num_repeats = 1 frame_extraction = "head" target_frames = [13]

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/34-49" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/34-49/cache_lowres" caption_extension = ".lowres" resolution = [352, 192] batch_size = 1 num_repeats = 1 frame_extraction = "uniform" target_frames = [33] frame_sample = 2

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/50-100" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/50-100/cache_lowres" caption_extension = ".lowres" resolution = [352, 192] batch_size = 1 num_repeats = 1 frame_extraction = "uniform" target_frames = [49] frame_sample = 2

[[datasets]] video_directory = "H:/datasets/princess_kaguya/videos/1920x1040/101-160" cache_directory = "H:/datasets/princess_kaguya/videos/1920x1040/101-160/cache_lowres" caption_extension = ".lowres" resolution = [352, 192] batch_size = 1 num_repeats = 1 frame_extraction = "uniform" target_frames = [49] frame_sample = 3


(ソースデータセット全体もアップロードしました。)

### **学習**

学習には[musubi-tuner](https://github.com/kohya-ss/musubi-tuner)を使用しました(Windows 11、64GB RAM、RTX 3090)。

学習パラメータ自体に特に興味深い点はなく、ほとんどは[Studio Ghibli LoRA](https://civitai.com/models/1404755/studio-ghibli-style-wan21-t2v-14b)から取得しました。

🗃️ 以下は、学習を起動するために使用したバッチスクリプトの例です:

accelerate launch --num_cpu_threads_per_process 1 --mixed_precision fp16 wan_train_network.py ^ --task t2v-14B ^ --vae G:/samples/musubi-tuner/wan14b/vae/wan_2.1_vae.safetensors ^ --t5 G:/samples/musubi-tuner/wan14b/tenc/models_t5_umt5-xxl-enc-bf16.pth ^ --dit E:/ComfyUI_windows_portable/ComfyUI/models/diffusion_models/wan/wan2.1_t2v_14B_fp16.safetensors ^ --blocks_to_swap 15 ^ --flash_attn ^ --mixed_precision fp16 ^ --fp8_base ^ --fp8_scaled ^ --dataset_config G:/samples/musubi-tuner/_kaguya_wan14b_dataset.toml ^ --gradient_checkpointing ^ --max_data_loader_n_workers 2 ^ --persistent_data_loader_workers ^ --learning_rate 6e-5 ^ --lr_scheduler constant_with_warmup ^ --lr_warmup_steps 100 ^ --optimizer_type adamw8bit ^ --optimizer_args weight_decay=0.01 ^ --network_module networks.lora_wan ^ --network_dim 32 ^ --network_alpha 32 ^ --timestep_sampling shift ^ --discrete_flow_shift 3.0 ^ --output_dir G:/samples/musubi-tuner/output ^ --output_name kaguya_wan14b ^ --log_config ^ --log_with all ^ --wandb_api_key MY_WANDB_API_KEY ^ --wandb_run_name kaguya ^ --logging_dir G:/samples/musubi-tuner/logs ^ --sample_prompts G:/samples/musubi-tuner/_kaguya_wan14b_sampling.txt ^ --save_state ^ --sample_every_n_steps 500 ^ --save_every_n_steps 500 ^ --max_train_epochs 50


学習は42,000ステップまで実行し、その後さまざまなチェックポイントを試して、34,000ステップのものを最良のものとして選択しました。損失値にはそれほど注目していませんでした(学習サンプルはポジティブな動的変化を示しており、データの暗記ではなく、モデルが効果的に学習していることを確認できたため、損失値よりもこれが重要でした)。ただし、学習期間中に損失は約0.1から0.09へと安定して低下し、過適合の兆候なく一貫して収束していることがわかりました。

P.S. 最終的なLoRA重みを、冒頭で言及した影響を軽減するために小さな合成データセットでポストファインチューニングしようとしましたが、効果がなかっただけでなく、モデルの品質を悪化させました。

このモデルで生成された画像

画像が見つかりません。