【Image2Video】Diffusers に新たに実装された I2VGenXL で動画を作成してみる

github.com

はじめに

「I2VGenXL」は以前からあるモデルです。

Diffusersが v0.26.0 にアップデートされて「I2VGenXL」が実装されました。

入力画像は1280x720(16:9)の画像なので比較的大きい動画が作れます。
(しかし、なぜか作成された動画は1280x704になります)

用意した画像


作成された動画


感想

動きの多い動画は苦手のようです。

FreeInitが使えれば良いのですが、今のところ使えません。

Pythonスクリプト

非常に短いです。

import torch
from diffusers import I2VGenXLPipeline
from diffusers.utils import load_image, export_to_gif

# from https://huggingface.co/ali-vilab/i2vgen-xl
repo_id = "i2vgen-xl" 
pipeline = I2VGenXLPipeline.from_pretrained(
    repo_id,
    torch_dtype=torch.float16
).to("cuda")

image_url = "cat.png"
image = load_image(image_url)
prompt = "a cat is sitting in the forest, best quality"
negative_prompt = "worst quality, low quality"

generator = torch.manual_seed(20000)
frames = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=image,
    num_inference_steps=35,
    num_frames=12,
    generator=generator
).frames[0]

export_to_gif(frames, "result.gif")

猫の画像の作り方

import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "model/blue_pencil-XL-v3.1.0",
    torch_dtype=torch.float16,
    variant="fp16",
).to("cuda")

#prompt = "a cat playing with a white ball in the forest, best quality"
prompt = "a cat is sitting in the forest, best quality"
negative_prompt = "worst quality, low quality"

seed = 20000
generator = torch.manual_seed(seed)
    
image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    num_inference_steps=35,
    width=1280,
    height=720,
    generator=generator
    ).images[0]

image.save("cat.png")





このエントリーをはてなブックマークに追加