patrickvonplaten commited on
Commit
11a3326
1 Parent(s): 21b2071

Improve usage example (#11)

Browse files

- Improve usage example (034ae2ed1832d2af18a5b901ef5955a983b45e13)

Files changed (1) hide show
  1. README.md +18 -0
README.md CHANGED
@@ -74,6 +74,12 @@ device = "cuda"
74
 
75
  pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
76
  pipe = pipe.to(device)
 
 
 
 
 
 
77
  ```
78
 
79
  **Note**:
@@ -85,6 +91,12 @@ 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`:
@@ -97,6 +109,12 @@ model_id = "CompVis/stable-diffusion-v1-4"
97
  scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
98
  pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True)
99
  pipe = pipe.to("cuda")
 
 
 
 
 
 
100
  ```
101
 
102
  # Uses
 
74
 
75
  pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
76
  pipe = pipe.to(device)
77
+
78
+ prompt = "a photo of an astronaut riding a horse on mars"
79
+ with autocast("cuda"):
80
+ image = pipe(prompt, guidance_scale=7.5)["sample"][0]
81
+
82
+ image.save("astronaut_rides_horse.png")
83
  ```
84
 
85
  **Note**:
 
91
 
92
  pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_auth_token=True)
93
  pipe = pipe.to(device)
94
+
95
+ prompt = "a photo of an astronaut riding a horse on mars"
96
+ with autocast("cuda"):
97
+ image = pipe(prompt, guidance_scale=7.5)["sample"][0]
98
+
99
+ image.save("astronaut_rides_horse.png")
100
  ```
101
 
102
  To swap out the noise scheduler, pass it to `from_pretrained`:
 
109
  scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
110
  pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True)
111
  pipe = pipe.to("cuda")
112
+
113
+ prompt = "a photo of an astronaut riding a horse on mars"
114
+ with autocast("cuda"):
115
+ image = pipe(prompt, guidance_scale=7.5)["sample"][0]
116
+
117
+ image.save("astronaut_rides_horse.png")
118
  ```
119
 
120
  # Uses