Text-to-Image
Diffusers
TensorBoard
Safetensors
stable-diffusion
stable-diffusion-diffusers
diffusers-training
lora
Instructions to use ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 3,934 Bytes
e5f5575 | 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 | <!--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.
-->
# Apple Silicon (M1/M2)μμ Stable Diffusionμ μ¬μ©νλ λ°©λ²
Diffusersλ Stable Diffusion μΆλ‘ μ μν΄ PyTorch `mps`λ₯Ό μ¬μ©ν΄ Apple μ€λ¦¬μ½κ³Ό νΈνλ©λλ€. λ€μμ Stable Diffusionμ΄ μλ M1 λλ M2 μ»΄ν¨ν°λ₯Ό μ¬μ©νκΈ° μν΄ λ°λΌμΌ νλ λ¨κ³μ
λλ€.
## μꡬ μ¬ν
- Apple silicon (M1/M2) νλμ¨μ΄μ Mac μ»΄ν¨ν°.
- macOS 12.6 λλ μ΄ν (13.0 λλ μ΄ν μΆμ²).
- Python arm64 λ²μ
- PyTorch 2.0(μΆμ²) λλ 1.13(`mps`λ₯Ό μ§μνλ μ΅μ λ²μ ). Yhttps://pytorch.org/get-started/locally/μ μ§μΉ¨μ λ°λΌ `pip` λλ `conda`λ‘ μ€μΉν μ μμ΅λλ€.
## μΆλ‘ νμ΄νλΌμΈ
μλ μ½λλ μ΅μν `to()` μΈν°νμ΄μ€λ₯Ό μ¬μ©νμ¬ `mps` λ°±μλλ‘ Stable Diffusion νμ΄νλΌμΈμ M1 λλ M2 μ₯μΉλ‘ μ΄λνλ λ°©λ²μ 보μ¬μ€λλ€.
<Tip warning={true}>
**PyTorch 1.13μ μ¬μ© μ€μΌ λ ** μΆκ° μΌνμ± μ λ¬μ μ¬μ©νμ¬ νμ΄νλΌμΈμ "νλΌμ΄λ°"νλ κ²μ μΆμ²ν©λλ€. μ΄κ²μ λ°κ²¬ν μ΄μν λ¬Έμ μ λν μμ ν΄κ²° λ°©λ²μ
λλ€. 첫 λ²μ§Έ μΆλ‘ μ λ¬μ νμ μ λ¬μ μ½κ° λ€λ₯Έ κ²°κ³Όλ₯Ό μμ±ν©λλ€. μ΄ μ λ¬μ ν λ²λ§ μννλ©΄ λλ©° μΆλ‘ λ¨κ³λ₯Ό ν λ²λ§ μ¬μ©νκ³ κ²°κ³Όλ₯Ό νκΈ°ν΄λ λ©λλ€.
</Tip>
μ΄μ νμμ μ€λͺ
ν κ²λ€μ ν¬ν¨ν μ¬λ¬ λ¬Έμ λ₯Ό ν΄κ²°νλ―λ‘ PyTorch 2 μ΄μμ μ¬μ©νλ κ²μ΄ μ’μ΅λλ€.
```python
# `huggingface-cli login`μ λ‘κ·ΈμΈλμ΄ μμμ νμΈ
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5")
pipe = pipe.to("mps")
# μ»΄ν¨ν°κ° 64GB μ΄νμ RAM λ¨μΌ λ μΆμ²
pipe.enable_attention_slicing()
prompt = "a photo of an astronaut riding a horse on mars"
# μ²μ "μλ°μ
" μ λ¬ (μ μ€λͺ
μ 보μΈμ)
_ = pipe(prompt, num_inference_steps=1)
# κ²°κ³Όλ μλ°μ
μ λ¬ νμ CPU μ₯μΉμ κ²°κ³Όμ μΌμΉν©λλ€.
image = pipe(prompt).images[0]
```
## μ±λ₯ μΆμ²
M1/M2 μ±λ₯μ λ©λͺ¨λ¦¬ μλ ₯μ λ§€μ° λ―Όκ°ν©λλ€. μμ€ν
μ νμν κ²½μ° μλμΌλ‘ μ€μλμ§λ§ μ€μν λ μ±λ₯μ΄ ν¬κ² μ νλ©λλ€.
νΉν μ»΄ν¨ν°μ μμ€ν
RAMμ΄ 64GB λ―Έλ§μ΄κ±°λ 512 Γ 512ν½μ
λ³΄λ€ ν° λΉνμ€ ν΄μλμμ μ΄λ―Έμ§λ₯Ό μμ±νλ κ²½μ°, μΆλ‘ μ€μ λ©λͺ¨λ¦¬ μλ ₯μ μ€μ΄κ³ μ€μνμ λ°©μ§νκΈ° μν΄ *μ΄ν
μ
μ¬λΌμ΄μ±*μ μ¬μ©νλ κ²μ΄ μ’μ΅λλ€. μ΄ν
μ
μ¬λΌμ΄μ±μ λΉμ©μ΄ λ§μ΄ λλ μ΄ν
μ
μμ
μ ν λ²μ λͺ¨λ μννλ λμ μ¬λ¬ λ¨κ³λ‘ μνν©λλ€. μΌλ°μ μΌλ‘ λ²μ© λ©λͺ¨λ¦¬κ° μλ μ»΄ν¨ν°μμ ~20%μ μ±λ₯ μν₯μ λ―ΈμΉμ§λ§ 64GB μ΄μμ΄ μλ κ²½μ° λλΆλΆμ Apple Silicon μ»΄ν¨ν°μμ *λ λμ μ±λ₯*μ΄ κ΄μ°°λμμ΅λλ€.
```python
pipeline.enable_attention_slicing()
```
## Known Issues
- μ¬λ¬ ν둬ννΈλ₯Ό λ°°μΉλ‘ μμ±νλ κ²μ [μΆ©λμ΄ λ°μνκ±°λ μμ μ μΌλ‘ μλνμ§ μμ΅λλ€](https://github.com/huggingface/diffusers/issues/363). μ°λ¦¬λ μ΄κ²μ΄ [PyTorchμ `mps` λ°±μλ](https://github.com/pytorch/pytorch/issues/84039)μ κ΄λ ¨μ΄ μλ€κ³ μκ°ν©λλ€. μ΄ λ¬Έμ λ ν΄κ²°λκ³ μμ§λ§ μ§κΈμ λ°°μΉ λμ λ°λ³΅ λ°©λ²μ μ¬μ©νλ κ²μ΄ μ’μ΅λλ€. |