🚀 中国水墨画生成モデル
このモデルは、現代中国水墨画を元にStable Diffusion XL をファインチューニングしたもので、テキストから中国水墨画風の画像を生成できます。
🚀 クイックスタート
必要ライブラリのインストール
推論プロセスは LCM - LORA を使用して高速化されています。必要なライブラリが最新版であることを確認してください。
pip install --upgrade pip
pip install --upgrade diffusers transformers accelerate peft
pip install matplotlib
テキストから画像への変換
ここでは、サンプルの高速化用の LCM - LORA と、スタイル付きレンダリング用の Chinese_Ink_LORA の2つのアダプターをベースモデル stabilityai/stable - diffusion - xl - base - 1.0 とともにロードする必要があります。次に、スケジューラを LCMScheduler に変更し、推論ステップ数を2〜8ステップに減らすことができます(実験では8ステップを使用)。
import torch
from diffusers import DiffusionPipeline, LCMScheduler
import matplotlib.pyplot as plt
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
variant="fp16",
torch_dtype=torch.float16
).to("cuda")
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl", adapter_name="lcm")
pipe.load_lora_weights("ming-yang/sdxl_chinese_ink_lora", adapter_name="Chinese Ink")
pipe.set_adapters(["lcm", "Chinese Ink"], adapter_weights=[1.0, 0.8])
prompts = ["Chinese Ink, mona lisa picture, 8k", "mona lisa, 8k"]
generator = torch.manual_seed(1)
images = [pipe(prompt, num_inference_steps=8, guidance_scale=1, generator=generator).images[0] for prompt in prompts]
fig, axs = plt.subplots(1, 2, figsize=(40, 20))
axs[0].imshow(images[0])
axs[0].axis('off')
axs[1].imshow(images[1])
axs[1].axis('off')
plt.show()
✨ 主な機能
- テキスト入力に基づいて中国水墨画風の画像を生成します。
- LCM - LORA を使用して推論速度を向上させます。
💻 使用例
基本的な使用法
画像生成をトリガーするには、Chinese Ink
を使用する必要があります。以下はいくつかの使用例です。
入力テキスト |
出力画像 |
Chinese Ink, The girl with a pearl earring, 8k |
[画像](images/Chinese Ink, The girl with a pearl earring, 8k.png) |
Chinese Ink,a cute fox |
[画像](images/Chinese Ink,a cute fox.png) |
Chinese Ink, Mona Lisa, 8k |
[画像](images/Chinese Ink, Mona Lisa, 8k.png) |
Chinese Ink,lotus pond in summer rain |
[画像](images/Chinese Ink,lotus pond in summer rain.png) |
Chinese Ink, Wild Geese Descending on a Sandbank, 8k |
[画像](images/Chinese Ink, Wild Geese Descending on a Sandbank, 8k.png) |
Chinese Ink, the Paris skyline and the Eiffel Tower |
[画像](images/Chinese Ink, the Paris skyline and the Eiffel Tower.png) |
Chinese Ink, a lovely rabbit (negative prompt: blurry, extra limb, bad anatomy) |
[画像](images/Chinese Ink, a lovely rabbit.png) |
Chinese Ink, a tree with colorful leaves in autumn, 8k (negative prompt: blurry, extra limb, bad anatomy) |
[画像](images/a tree with colorful leaves in autumn.png) |
📦 モデルのダウンロード
このモデルのウェイトは Safetensors 形式で利用可能です。
ダウンロード は「Files & versions」タブから行えます。
📄 ライセンス
このモデルは creativeml - openrail - m ライセンスの下で提供されています。