common.title

Docs
Quantum Circuit
TYTAN CLOUD

QUANTUM GAMING


Overview
Contact
Event
Project
Research

Terms of service (Web service)

Terms of service (Quantum and ML Cloud service)

Privacy policy


Sign in
Sign up
common.title

blueqat cloudでStable Diffusion 2 を動かしてみる。

Yuichiro Minato

2023/02/25 05:05

blueqat cloudの企業有料版では、NVIDIA V100の32G VRAMが動いてますので、Stable Diffusionなどの拡散モデルを普通に動かして利用できます。

既に必要な環境はほぼ揃っているので、試してみます。

1、必要なライブラリをインストール

pytorchなどは既に入っていますので、残りは、

!pip install diffusers==0.13.1 transformers scipy ftfy accelerate

をすることで利用できます。

2、APIトークンを取得

こちらから取得しておきます。

https://huggingface.co/settings/tokens

3、早速動かす。

下記のTOKENのところには、HuggingFaceで取得したトークンを入れます。

import torch
from diffusers import StableDiffusionPipeline
from torch import autocast

model_id = "stabilityai/stable-diffusion-2"
#model_id = "CompVis/stable-diffusion-v1-4"

pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16", torch_dtype=torch.float16, use_auth_token=r'TOKEN')
pipe.to("cuda")

これで必要なモデルが読み込まれます。

4、画像を生成する

prompt = 'a photo of an astronaut riding a horse on mars'
image = pipe(prompt).images[0]
image

8秒ほどで生成されました。

50/50 [00:07<00:00, 6.30it/s]

Google colabが優秀すぎるのでアレですが、こちらでしたら24/365ずっと画像生成できるので。なんか使い道を考えてみたいですね。

© 2025, blueqat Inc. All rights reserved