Kandinsky 3.1

詳細

ファイルをダウンロード

モデル説明

これはステーブル・ディフュージョンモデルではありません。独自のWeb UIを必要とします。詳細は以下をご覧ください。

注:私はこのモデルの作者ではありません。元のHFリポジトリへのリンクは以下です。

Kandinsky 3.1 は現在利用可能です:

リポジトリの元の説明:

license: apache-2.0

Kandinsky-3: テキストから画像へのディフュージョンモデル

Kandinsky 3.0 ポスト | Kandinsky 3.1 ポスト | プロジェクトページ | 生成 | Telegram ボット | 技術レポート | HuggingFace

Kandinsky 3.1:

説明:

Kandinsky 3.1 は、Kandinsky 3.0 モデルの後継であり、潜在的ディフュージョンに基づく大規模なテキストから画像への生成モデルです。本モデルは、テキストから画像へのKandinskyモデルのシリーズを継承し、生成画像の品質と現実感を向上させた成果を反映しています。さらに、ユーザーが新モデルの力を最大限に活用できるよう、さまざまな有用な機能とモードを追加・強化しました。

Kandinsky Flash (Kandinsky 3.0 リファイナー)

ディフュージョンモデルは高速画像生成に課題を抱えています。この問題に対応するために、敵対的ディフュージョン蒸留 のアプローチに基づき、いくつかの修正を加えたKandinsky Flashモデルを訓練しました。具体的には、潜在空間でモデルを訓練することでメモリオーバーヘッドを削減し、蒸留損失を除去しました(これは訓練に影響を与えなかったため)。また、Kandinsky FlashモデルをKandinsky 3.0で生成された画像に適用することで、生成画像の視覚的品質を改善しました。

アーキテクチャ

Kandinsky Flashの訓練には、次のディスクリミネータアーキテクチャを使用しました。これはKandinsky 3.0のU-Netエンコーダの半分に、追加のヘッド予測を組み合わせたものです。

使用方法:

./examples フォルダ内の例を含むJupyterノートブックをご確認ください。

from kandinsky3 import get_T2I_Flash_pipeline

device_map = torch.device('cuda:0')
dtype_map = {
    'unet': torch.float32,
    'text_encoder': torch.float16,
    'movq': torch.float32,
}

t2i_pipe = get_T2I_Flash_pipeline(
    device_map, dtype_map
)

res = t2i_pipe("A cute corgi lives in a house made out of sushi.")

Kandinsky インペインティング

さらに、物体検出データセットで追加訓練した新しいバージョンのインペインティングモデルをリリースしました。これにより、物体の生成がより安定するようになりました。新しい重みは ai-forever/Kandinsky3.1 で利用可能です。使用方法の例は こちら をご確認ください。

プロンプトの美化

テキストから画像への生成において、プロンプトは非常に重要な役割を果たします。そこでKandinsky 3.1では、言語モデルを使用してプロンプトを改善することにしました。LLMとして、Intelの neural-chat-7b-v3-1 を、以下のシステムプロンプトと共に使用しました:

### System: You are a prompt engineer. Your mission is to expand prompts written by user. You should provide the best prompt for text to image generation in English.
### User:
{prompt}
### Assistant:
{answer of the model}

KandiSuperRes

KandiSuperResの詳細については、以下をご確認ください:https://github.com/ai-forever/KandiSuperRes/

Kandinsky IP-Adapter および Kandinsky ControlNet

Kandinskyモデルで画像を条件として使用できるように、IP-AdapterとHEDベースのControlNetモデルを訓練しました。詳細は https://github.com/ai-forever/kandinsky3-diffusers をご確認ください。

Kandinsky 3.0:

説明:

Kandinsky 3.0 は、Kandinsky2-xモデルファミリーを基盤とするオープンソースのテキストから画像へのディフュージョンモデルです。従来のバージョンと比較して、Kandinsky 3.0 はより多くのデータ、特にロシア文化に関連するデータを統合しており、ロシア文化に関連する画像の生成が可能になりました。さらに、テキストエンコーダとディフュージョンU-Netモデルのサイズを拡張することで、テキスト理解と視覚的品質を向上させました。

詳細については、私たちのポストをご覧ください。英語版は数日中にリリースされます。

アーキテクチャの詳細:

アーキテクチャは以下の3部分で構成されています:

  • テキストエンコーダ Flan-UL2(エンコーダ部分) - 8.6B

  • 潜在的ディフュージョン U-Net - 3B

  • MoVQ エンコーダ/デコーダ - 267M

モデル

以下の2つのモデルをリリースしました:

  • Base: 基本的なテキストから画像へのディフュージョンモデル。400枚のA100を使用して2Mステップ訓練しました。

  • Inpainting: インペインティング版モデル。ベースモデルの最終チェックポイントから初期化し、300枚のA100を使用して250kステップ訓練しました。

インストール

リポジトリをインストールするには、まずconda環境を作成してください:

conda create -n kandinsky -y python=3.8;
source activate kandinsky;
pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu113/torch_stable.html;
pip install -r requirements.txt;

正確な依存関係は pip freeze で取得でき、exact_requirements.txt に記載されています。

使用方法:

./examples フォルダ内のJupyterノートブックをご確認ください。

1. text2image

import sys
sys.path.append('..')

import torch
from kandinsky3 import get_T2I_pipeline

device_map = torch.device('cuda:0')
dtype_map = {
    'unet': torch.float32,
    'text_encoder': torch.float16,
    'movq': torch.float32,
}

t2i_pipe = get_T2I_pipeline(
    device_map, dtype_map,
)
res = t2i_pipe("A cute corgi lives in a house made out of sushi.")

res[0]

2. inpainting

from kandinsky3 import get_inpainting_pipeline

device_map = torch.device('cuda:0')
dtype_map = {
    'unet': torch.float16,
    'text_encoder': torch.float16,
    'movq': torch.float32,
}

pipe = get_inpainting_pipeline(
    device_map, dtype_map,
)

image = ... # PIL Image
mask = ... # Numpy array (HxW). Set 1 where image should be masked
image = inp_pipe( "A cute corgi lives in a house made out of sushi.", image, mask)

著者

引用

@misc{arkhipkin2023kandinsky,
      title={Kandinsky 3.0 Technical Report}, 
      author={Vladimir Arkhipkin and Andrei Filatov and Viacheslav Vasilev and Anastasia Maltseva and Said Azizov and Igor Pavlov and Julia Agafonova and Andrey Kuznetsov and Denis Dimitrov},
      year={2023},
      eprint={2312.03511},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

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

画像が見つかりません。