🚀 SD3 Controlnet Inpainting
このモデルはテキストから画像を生成するモデルで、SD3ベースのControlnet Inpainting機能を備えています。Diffusersライブラリと統合され、便利に使用できます。
🚀 クイックスタート
このモデルはDiffusersに統合されており、便利に使用することができます。
✨ 主な機能
画像生成例

白いジャケット、黒い帽子、黒いズボンを着た女性が畑に立っている、帽子にはSD3と書かれている

白い靴を履き、「alibaba」と書かれた白いバケツを持った人
SD3 Controlnet Inpaintingの特長
sd3 - mediumをベースに微調整されたControlnet Inpaintingモデルで、以下の利点があります。
- SD3の16チャンネルVAEと1024の高解像度生成能力を活用し、非インペイント領域(テキストを含む)の完全性を効果的に維持します。
- インペイントによるテキスト生成が可能です。
- 肖像画生成において優れた美学的性能を示します。
SDXL - Inpaintingとの比較。
左から右へ:入力画像、マスク画像、SDXLインペイント、当モデル。

公園のベンチに座っている虎

公園のベンチに座っている犬

青とピンクの花柄のドレスを着た若い女性

白いジャケット、黒い帽子、黒いズボンを着た女性が畑に立っている、帽子にはSD3と書かれている

寝室の壁に取り付けられたエアコン
📦 インストール
ソースからインストールして実行します。
pip uninstall diffusers
pip install git+https://github.com/huggingface/diffusers
💻 使用例
基本的な使用法
import torch
from diffusers.utils import load_image, check_min_version
from diffusers.pipelines import StableDiffusion3ControlNetInpaintingPipeline
from diffusers.models.controlnet_sd3 import SD3ControlNetModel
controlnet = SD3ControlNetModel.from_pretrained(
"alimama-creative/SD3-Controlnet-Inpainting", use_safetensors=True, extra_conditioning_channels=1
)
pipe = StableDiffusion3ControlNetInpaintingPipeline.from_pretrained(
"stabilityai/stable-diffusion-3-medium-diffusers",
controlnet=controlnet,
torch_dtype=torch.float16,
)
pipe.text_encoder.to(torch.float16)
pipe.controlnet.to(torch.float16)
pipe.to("cuda")
image = load_image(
"https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog.png"
)
mask = load_image(
"https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog_mask.png"
)
width = 1024
height = 1024
prompt = "A cat is sitting next to a puppy."
generator = torch.Generator(device="cuda").manual_seed(24)
res_image = pipe(
negative_prompt="deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, mutated hands and fingers, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, NSFW",
prompt=prompt,
height=height,
width=width,
control_image=image,
control_mask=mask,
num_inference_steps=28,
generator=generator,
controlnet_conditioning_scale=0.95,
guidance_scale=7,
).images[0]
res_image.save(f"sd3.png")
🔧 技術詳細
学習詳細
このモデルは12Mのlaion2Bと内部ソース画像を使用して、解像度1024x1024で20kステップ学習されました。
プロパティ |
詳細 |
混合精度 |
FP16 |
学習率 |
1e - 4 |
バッチサイズ |
192 |
タイムステップサンプリングモード |
'logit_normal' |
損失関数 |
Flow Matching |
制限事項
学習段階では1024 * 1024ピクセルの解像度のみを使用しているため、推論はこのサイズで最適な結果が得られ、他のサイズでは結果が劣ります。将来的にはマルチ解像度学習を開始し、その際に新しいウェイトをオープンソース化します。
📄 ライセンス
このモデルはSD3をベースに微調整されているため、ライセンスは元のSD3ライセンスに従います。