Text-to-Image
Diffusers
TensorBoard
Safetensors
StableDiffusionPipeline
dreambooth
diffusers-training
stable-diffusion
stable-diffusion-diffusers
Instructions to use NadaGh/working with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use NadaGh/working with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("NadaGh/working", dtype=torch.bfloat16, device_map="cuda") prompt = "tst chair" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 3,766 Bytes
dde5d93 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
# Habana Gaudi์์ Stable Diffusion์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
๐ค Diffusers๋ ๐ค [Optimum Habana](https://huggingface.co/docs/optimum/habana/usage_guides/stable_diffusion)๋ฅผ ํตํด์ Habana Gaudi์ ํธํ๋ฉ๋๋ค.
## ์๊ตฌ ์ฌํญ
- Optimum Habana 1.4 ๋๋ ์ดํ, [์ฌ๊ธฐ](https://huggingface.co/docs/optimum/habana/installation)์ ์ค์นํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
- SynapseAI 1.8.
## ์ถ๋ก ํ์ดํ๋ผ์ธ
Gaudi์์ Stable Diffusion 1 ๋ฐ 2๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ค๋ฉด ๋ ์ธ์คํด์ค๋ฅผ ์ธ์คํด์คํํด์ผ ํฉ๋๋ค:
- [`GaudiStableDiffusionPipeline`](https://huggingface.co/docs/optimum/habana/package_reference/stable_diffusion_pipeline)์ด ํฌํจ๋ ํ์ดํ๋ผ์ธ. ์ด ํ์ดํ๋ผ์ธ์ *ํ
์คํธ-์ด๋ฏธ์ง ์์ฑ*์ ์ง์ํฉ๋๋ค.
- [`GaudiDDIMScheduler`](https://huggingface.co/docs/optimum/habana/package_reference/stable_diffusion_pipeline#optimum.habana.diffusers.GaudiDDIMScheduler)์ด ํฌํจ๋ ์ค์ผ์ค๋ฌ. ์ด ์ค์ผ์ค๋ฌ๋ Habana Gaudi์ ์ต์ ํ๋์ด ์์ต๋๋ค.
ํ์ดํ๋ผ์ธ์ ์ด๊ธฐํํ ๋, HPU์ ๋ฐฐํฌํ๊ธฐ ์ํด `use_habana=True`๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค.
๋ํ ๊ฐ๋ฅํ ๊ฐ์ฅ ๋น ๋ฅธ ์์ฑ์ ์ํด `use_hpu_graphs=True`๋ก **HPU ๊ทธ๋ํ**๋ฅผ ํ์ฑํํด์ผ ํฉ๋๋ค.
๋ง์ง๋ง์ผ๋ก, [Hugging Face Hub](https://huggingface.co/Habana)์์ ๋ค์ด๋ก๋ํ ์ ์๋ [Gaudi configuration](https://huggingface.co/docs/optimum/habana/package_reference/gaudi_config)์ ์ง์ ํด์ผ ํฉ๋๋ค.
```python
from optimum.habana import GaudiConfig
from optimum.habana.diffusers import GaudiDDIMScheduler, GaudiStableDiffusionPipeline
model_name = "stabilityai/stable-diffusion-2-base"
scheduler = GaudiDDIMScheduler.from_pretrained(model_name, subfolder="scheduler")
pipeline = GaudiStableDiffusionPipeline.from_pretrained(
model_name,
scheduler=scheduler,
use_habana=True,
use_hpu_graphs=True,
gaudi_config="Habana/stable-diffusion",
)
```
ํ์ดํ๋ผ์ธ์ ํธ์ถํ์ฌ ํ๋ ์ด์์ ํ๋กฌํํธ์์ ๋ฐฐ์น๋ณ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
```python
outputs = pipeline(
prompt=[
"High quality photo of an astronaut riding a horse in space",
"Face of a yellow cat, high resolution, sitting on a park bench",
],
num_images_per_prompt=10,
batch_size=4,
)
```
๋ ๋ง์ ์ ๋ณด๋ฅผ ์ป๊ธฐ ์ํด, Optimum Habana์ [๋ฌธ์](https://huggingface.co/docs/optimum/habana/usage_guides/stable_diffusion)์ ๊ณต์ GitHub ์ ์ฅ์์ ์ ๊ณต๋ [์์](https://github.com/huggingface/optimum-habana/tree/main/examples/stable-diffusion)๋ฅผ ํ์ธํ์ธ์.
## ๋ฒค์น๋งํฌ
๋ค์์ [Habana/stable-diffusion](https://huggingface.co/Habana/stable-diffusion) Gaudi ๊ตฌ์ฑ(ํผํฉ ์ ๋ฐ๋ bf16/fp32)์ ์ฌ์ฉํ๋ Habana first-generation Gaudi ๋ฐ Gaudi2์ ์ง์ฐ ์๊ฐ์
๋๋ค:
| | Latency (๋ฐฐ์น ํฌ๊ธฐ = 1) | Throughput (๋ฐฐ์น ํฌ๊ธฐ = 8) |
| ---------------------- |:------------------------:|:---------------------------:|
| first-generation Gaudi | 4.29s | 0.283 images/s |
| Gaudi2 | 1.54s | 0.904 images/s |
|