【Diffusers】 Kandinsky-2 というモデルを使ってみる

最終更新日:2023年6月10日


Kandinsky-2とは

github.com
上記レポジトリにはこのように記載されています。

Kandinsky 2.1 inherits best practicies from Dall-E 2 and Latent diffusion, while introducing some new ideas.

日本語訳(DeepLで翻訳)

Kandinsky 2.1は、Dall-E 2とLatent diffusionのベストプラクティスを継承しつつも、いくつかの新しいアイデアを導入しています。



Diffusersから使えるようになったのでさっそく使ってみました。

結果


Pythonスクリプト

from diffusers import DiffusionPipeline
import torch

pipe_prior = DiffusionPipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-1-prior", torch_dtype=torch.float16
)
pipe_prior.to("cuda")

prompt = "Einstein in space around the logarithm scheme"
negative_prompt = "low quality, bad quality"

image_embeds, negative_image_embeds = pipe_prior(prompt, negative_prompt, guidance_scale=1.0).to_tuple()

pipe = DiffusionPipeline.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
pipe.to("cuda")

image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image_embeds=image_embeds,
    negative_image_embeds=negative_image_embeds,
    num_images_per_prompt=1,
    height=768,
    width=768
).images[0]

image.save("kandinsky_result.png")

補足

「multilingual」と書かれているので日本語でもいけるのか試してみました。

プロンプトは以下のようにしました。

富士山と猫




日本語もいけるようです。