Instructions to use CompVis/stable-diffusion-v1-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use CompVis/stable-diffusion-v1-2 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-2", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
- DiffusionBee
Commit ·
d6b863c
1
Parent(s): 2baddba
Update README.md
Browse files
README.md
CHANGED
|
@@ -61,24 +61,30 @@ Run this command to log in with your HF Hub token if you haven't before:
|
|
| 61 |
huggingface-cli login
|
| 62 |
```
|
| 63 |
|
| 64 |
-
Running the pipeline with the default
|
|
|
|
| 65 |
```python
|
| 66 |
import torch
|
| 67 |
from torch import autocast
|
| 68 |
from diffusers import StableDiffusionPipeline
|
| 69 |
|
| 70 |
-
model_id = "CompVis/stable-diffusion-v1-
|
| 71 |
device = "cuda"
|
| 72 |
|
| 73 |
-
|
| 74 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
|
| 75 |
pipe = pipe.to(device)
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
```
|
| 83 |
|
| 84 |
To swap out the noise scheduler, pass it to `from_pretrained`:
|
|
|
|
| 61 |
huggingface-cli login
|
| 62 |
```
|
| 63 |
|
| 64 |
+
Running the pipeline with the default PNDM scheduler:
|
| 65 |
+
|
| 66 |
```python
|
| 67 |
import torch
|
| 68 |
from torch import autocast
|
| 69 |
from diffusers import StableDiffusionPipeline
|
| 70 |
|
| 71 |
+
model_id = "CompVis/stable-diffusion-v1-1"
|
| 72 |
device = "cuda"
|
| 73 |
|
| 74 |
+
|
| 75 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
|
| 76 |
pipe = pipe.to(device)
|
| 77 |
+
```
|
| 78 |
|
| 79 |
+
**Note**:
|
| 80 |
+
If you are limited by GPU memory and have less than 10GB of GPU RAM available, please make sure to load the StableDiffusionPipeline in float16 precision instead of the default float32 precision as done above. You can do so by telling diffusers to expect the weights to be in float16 precision:
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
```py
|
| 84 |
+
import torch
|
| 85 |
+
|
| 86 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_auth_token=True)
|
| 87 |
+
pipe = pipe.to(device)
|
| 88 |
```
|
| 89 |
|
| 90 |
To swap out the noise scheduler, pass it to `from_pretrained`:
|