1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

効率的とは

Devices that everyone in the future will have
未来のみんながつけているデバイス

1ab5e77f-be5a-4d0d-9639-ecfe9225450d.jpeg

StableDiffusionより、トレーニング時間も推論時間も短くて済むらしい。
効率的なアーキテクチャを使っているらしい。

コンパクトな潜在表現により、最終的なパフォーマンスを損なうことなく、2 倍以上の速度で推論を実行できるようになり、最先端 (SOTA) 拡散モデルの通常のコストと二酸化炭素排出量を大幅に削減できます。

【二酸化炭素排出量を大幅に削減できます。】というのが2024年っぽい。
ちなみにA100GPUで11秒かかった。速いのかはちょっとわからない。

使用方法

インストール

GitHubリポジトリでもサンプルノートブックがアップされているが、うまくいかなかったのでdiffuserからインストールする。

pip install git+https://github.com/kashif/diffusers.git@a3dc21385b7386beb3dab3a9845962ede6765887

HuggingFaceには
pip install git+https://github.com/kashif/diffusers.git@wuerstchen-v3
とあったけど、壊れていたので過去のコミットを参照した。

実行

import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline

device = "cuda"
num_images_per_prompt = 2

prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=torch.float16).to(device)

prompt = "Clothes that make you popular"
negative_prompt = "illustration"

prior_output = prior(
    prompt=prompt,
    height=1024,
    width=1024,
    negative_prompt=negative_prompt,
    guidance_scale=4.0,
    num_images_per_prompt=num_images_per_prompt,
    num_inference_steps=20
)
decoder_output = decoder(
    image_embeddings=prior_output.image_embeddings.half(),
    prompt=prompt,
    negative_prompt=negative_prompt,
    guidance_scale=0.0,
    output_type="pil",
    num_inference_steps=10
).images

#Now decoder_output is a list with your PIL images
for i,image in enumerate(decoder_output):
  image.save(f"{i}.jpg")
Clothes that make you popular
モテモテになる服

b87983f9-dd43-436d-a42b-6fa511d2cf90.jpeg

🐣


フリーランスエンジニアです。
AIについて色々記事を書いていますのでよかったらプロフィールを見てみてください。

もし以下のようなご要望をお持ちでしたらお気軽にご相談ください。
AIサービスを開発したい、ビジネスにAIを組み込んで効率化したい、AIを使ったスマホアプリを開発したい、
ARを使ったアプリケーションを作りたい、スマホアプリを作りたいけどどこに相談したらいいかわからない…

いずれも中間コストを省いたリーズナブルな価格でお請けできます。

お仕事のご相談はこちらまで
rockyshikoku@gmail.com

機械学習やAR技術を使ったアプリケーションを作っています。
機械学習/AR関連の情報を発信しています。

X
Medium
GitHub

相棒

note

1
2
0

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?