2
0

STable Diffusionとは

非常にわかりやすい記事があるので、そちらを参照

Stable Diffusion 3 Medium

Stable Diffusion 3は、マルチモーダル拡散トランスフォーマー(MMDiT)とRectified Flowを使用した新しい画像生成モデル。Stable Diffusion 3 Mediumは、その軽量かつ無料配布版。

Stable Diffusion 3 Medium
・medium 20億パラメーター
・出力画像はデフォルトで1024×1024px

ライセンス

学術研究などの非営利目的では自由に使用でき、商用利用は別の有料ライセンスがないとできないようです。

お客様は、本ソフトウェア製品または派生物を使用して、お客様がホストするサービスの一部として、またはお客様の API を介して、第三者が本ソフトウェア製品または派生物を使用できるようにすることはできません。

使い方

ライブラリをインストールする

pip install -U diffusers
pip install -U peft

Hugging Faceでアクセストークンを取得する

  1. Hugging Faceにログインする
  2. 下記にアクセスする
    https://huggingface.co/stabilityai/stable-diffusion-3-medium
  3. このモデルへのアクセス権を申請する
  4. 設定->アクセストークンを開く
  5. New tokenを押す
  6. Edit PermissionsでReposの権限を付ける

あとはアクセストークンを使用してHugging Hubへアクセスして、対象モデルを指定して使用する。

from diffusers import StableDiffusion3Pipeline
import torch
import datetime

from huggingface_hub import login
login(token='アクセストークン', add_to_git_credential=True)

pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = 'A digital Illustration of the Babel tower, 4k, detailed, trending in artstation, fantasy vivid colors, 8k'

image = pipe(
    prompt,
    negative_prompt="",
    num_inference_steps=28,
    guidance_scale=7.0,
).images[0]
image.save('stable-diffusion_3_medium.jpg')

生成画像の例

Claude 3 Sonnetにプロンプトを作ってもらって、Stable Diffusino 3 mediumに画像生成してもらった。生成時間はNVIDIA RTX A2000 12GBを使用して、だいたい5分ほどだった。

Stunning panoramic landscape photography, sweeping vistas, majestic cliffs, ancient forests, winding rivers, HDR, exquisite colors, lifelike

stable-diffusion_3_medium_20240627143001.jpg

'Photorealistic landscape, 4K resolution, detailed, epic mountains, lush green valleys, crystal clear lakes, dramatic lighting, cinematic atmosphere'

stable-diffusion_3_medium_20240627125353.jpg

Ultra-realistic nature scenery, 8K, highly detailed, snow-capped mountains, misty waterfalls, vibrant wildflowers, golden hour lighting, breathtaking view

stable-diffusion_3_medium_20240627130758_2.jpg

Photorealistic portrait, young Japanese woman, delicate facial features, natural makeup, detailed eyes and lips, black silky hair, soft lighting

stable-diffusion_3_medium_20240627140027.jpg

Photorealistic render of a delicious hamburger, 8K, highly detailed, ray-traced lighting, sharp focus, juicy beef patty, melted cheese, fresh lettuce, tomatoes, detailed sesame seed bun, mouthwatering

stable-diffusion_3_medium_20240711100537_0.jpg

A photorealistic image of a dog breed that looks like a calico cat, with patches of orange, black and white fur, highly detailed fur texture, realistic subsurface scattering, 8K resolution, from a front angle, studio lighting

stable-diffusion_3_medium_20240711102751_0.jpg

stable-diffusion_3_medium_20240711143248_0.jpg

stable-diffusion_3_medium_20240711145918_0.jpg

stable-diffusion_3_medium_20240711150648_0.jpg

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0