見出し画像

HunyuanVideoのimg2vidを試してみた@ComfyUI

HunyuanVideoのimg2vidについて、leapfusion-image2vid-testのLoraを合わせることでComfyUIのネイティブノードでも行えるという話があり、試してみました。
ワークフローは、おなじみのKijaiさんが公開されていました。
ComfyUI-KJNodes/example_workflows/leapfusion_hunyuuanvideo_i2v_native_testing.json at main · kijai/ComfyUI-KJNodes

リンクの所にもありますが、「KJ Node」にあるカスタムノードを追加で使用する必要があるようです。

この設定で行うと、最初のフレームは元の画像なのですが、すぐに違うのが挿入されて

以下のものを試してみました。

A young girl stands beneath a vast, starry night sky, her delicate figure illuminated by the soft glow of distant stars. The deep indigo sky stretches endlessly above her, with the Milky Way faintly flowing across the horizon. A gentle breeze moves through her long, flowing hair and the hem of her white dress, shimmering subtly as if woven with golden threads.

She slowly lifts her hand, her fingers reaching out as if tracing the constellations. With delicate precision, she pinches the air, as if grasping a star. In that fleeting moment, a tiny golden light flickers between her fingertips, shimmering like cosmic dust before dissolving into the night. Her lips curl into a soft, knowing smile, as if she holds a secret shared only with the universe.

The camera smoothly pans in, focusing on her glowing fingertips, capturing the ethereal beauty of the moment. The background stars softly blur, enhancing the magical radiance of her gesture. A gentle piano melody drifts in the background, accompanied by the faint rustle of the night breeze. As the light fades from her fingers, the scene gently transitions into a vast expanse of twinkling stars, leaving behind a sense of quiet wonder and enchantment

最初、Betaスケジューラーを使用していると、うまくいかない感じでしたので、スケジューラーなどの選択で変わるのかもしれません。

GPTさんにスクリプトを解析して、「LeapfusionHunyuanI2V Patcher」のパラメータについて調べてもらいました。

Index:潜在変数の中で置き換え対象となるチャンネル番号。たとえば、0 なら最初のフレーム、-1 なら最後のフレーム
start_percent / end_percent: 拡散ステップ全体の中で、どのパーセンテージ範囲において置き換えを適用するか(例:0.0~1.0で全体に適用)
strength: 置き換えに用いる値に乗算される強度パラメータ(負の値も許容される)

<概略>
このノードは、Diffusion モデルの拡散過程中の特定のステップ範囲において、入力 latent の特定チャンネルを強制的に(またはゼロに)置き換えることで、生成過程に外部からの影響(例:特定の特徴の注入)を与えるためのものです。

<仕組み>
与えられた latent を特定のスケール(0.476986 × strength)で処理し、置き換え用のサンプルを作成
UNet の forward 関数をラップして、拡散ステップのパーセンテージに応じて該当チャンネルを置き換える(指定範囲内なら injection、範囲外ならゼロ埋め)
こうしてパッチ処理されたモデルを返す
このような仕組みにより、ユーザーは生成過程の任意のタイミングで特定の latent 情報を注入できるようになり、例えば映像生成や条件付き生成において特殊な効果を得ることが可能になります。


失敗例
ワークフローの

Strengthを上げると元の画像が反映されやすくなるようですが、背景が固定されたり、人物の動きが小さくなります。

パラメータを少し変えるだけで変化が見られるので、いろいろと試してみると面白いと感じました。

サムネの画像を動かす
これはstrengthとendをわずかに下げた


いいなと思ったら応援しよう!