Commit
·
412dbda
1
Parent(s):
9c24957
Update README.md
Browse files
README.md
CHANGED
|
@@ -27,7 +27,7 @@ This model card focuses on the model associated with the Stable Diffusion model,
|
|
| 27 |
pages = {10684-10695}
|
| 28 |
}
|
| 29 |
|
| 30 |
-
##
|
| 31 |
|
| 32 |
```bash
|
| 33 |
pip install --upgrade diffusers transformers scipy
|
|
@@ -40,15 +40,20 @@ huggingface-cli login
|
|
| 40 |
|
| 41 |
Running the pipeline with the default PLMS scheduler:
|
| 42 |
```python
|
|
|
|
| 43 |
from torch import autocast
|
| 44 |
from diffusers import StableDiffusionPipeline
|
| 45 |
|
| 46 |
-
model_id = "CompVis/stable-diffusion-v1-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
prompt = "a photograph of an astronaut riding a horse"
|
| 50 |
with autocast("cuda"):
|
| 51 |
-
image = pipe(prompt
|
| 52 |
|
| 53 |
image.save(f"astronaut_rides_horse.png")
|
| 54 |
```
|
|
@@ -171,43 +176,6 @@ This model card focuses on the model associated with the Stable Diffusion model,
|
|
| 171 |
pages = {10684-10695}
|
| 172 |
}
|
| 173 |
|
| 174 |
-
## Usage examples
|
| 175 |
-
|
| 176 |
-
```bash
|
| 177 |
-
pip install --upgrade diffusers transformers scipy
|
| 178 |
-
```
|
| 179 |
-
|
| 180 |
-
Run this command to log in with your HF Hub token if you haven't before:
|
| 181 |
-
```bash
|
| 182 |
-
huggingface-cli login
|
| 183 |
-
```
|
| 184 |
-
|
| 185 |
-
Running the pipeline with the default PLMS scheduler:
|
| 186 |
-
```python
|
| 187 |
-
from torch import autocast
|
| 188 |
-
from diffusers import StableDiffusionPipeline
|
| 189 |
-
|
| 190 |
-
model_id = "CompVis/stable-diffusion-v1-3-diffusers"
|
| 191 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True).to("cuda")
|
| 192 |
-
|
| 193 |
-
prompt = "a photograph of an astronaut riding a horse"
|
| 194 |
-
with autocast("cuda"):
|
| 195 |
-
image = pipe(prompt, guidance_scale=7)["sample"][0] # image here is in PIL format
|
| 196 |
-
|
| 197 |
-
image.save(f"astronaut_rides_horse.png")
|
| 198 |
-
```
|
| 199 |
-
|
| 200 |
-
To swap out the noise scheduler, pass it to `from_pretrained`:
|
| 201 |
-
|
| 202 |
-
```python
|
| 203 |
-
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
|
| 204 |
-
|
| 205 |
-
model_id = "CompVis/stable-diffusion-v1-3-diffusers"
|
| 206 |
-
# Use the K-LMS scheduler here instead
|
| 207 |
-
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
| 208 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True).to("cuda")
|
| 209 |
-
```
|
| 210 |
-
|
| 211 |
# Uses
|
| 212 |
|
| 213 |
## Direct Use
|
|
|
|
| 27 |
pages = {10684-10695}
|
| 28 |
}
|
| 29 |
|
| 30 |
+
## Examples
|
| 31 |
|
| 32 |
```bash
|
| 33 |
pip install --upgrade diffusers transformers scipy
|
|
|
|
| 40 |
|
| 41 |
Running the pipeline with the default PLMS scheduler:
|
| 42 |
```python
|
| 43 |
+
import torch
|
| 44 |
from torch import autocast
|
| 45 |
from diffusers import StableDiffusionPipeline
|
| 46 |
|
| 47 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
| 48 |
+
device = "cuda"
|
| 49 |
+
|
| 50 |
+
generator = torch.Generator(device=device).manual_seed(0)
|
| 51 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
|
| 52 |
+
pipe = pipe.to(device)
|
| 53 |
|
| 54 |
prompt = "a photograph of an astronaut riding a horse"
|
| 55 |
with autocast("cuda"):
|
| 56 |
+
image = pipe(prompt)["sample"][0] # image here is in PIL format
|
| 57 |
|
| 58 |
image.save(f"astronaut_rides_horse.png")
|
| 59 |
```
|
|
|
|
| 176 |
pages = {10684-10695}
|
| 177 |
}
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
# Uses
|
| 180 |
|
| 181 |
## Direct Use
|