Yihong Luo commited on
Commit
6487dd2
1 Parent(s): ee34371

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -0
README.md CHANGED
@@ -4,6 +4,26 @@
4
 
5
  ### 1-step inference
6
  1-step inference is only allowed based on SD v1.5 for now. And you should prepare the informative initialization according to the paper for better results.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  ### 2-step inference
9
  We note that a small CFG can be used to enhance the image quality.
 
4
 
5
  ### 1-step inference
6
  1-step inference is only allowed based on SD v1.5 for now. And you should prepare the informative initialization according to the paper for better results.
7
+ ```python
8
+ pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype = torch.float16)
9
+ pipeline = pipeline.to('cuda')
10
+ pipeline.scheduler = LCMScheduler.from_config(pipeline.scheduler.config)
11
+ generator = torch.manual_seed(318)
12
+ steps = 1
13
+ bs = 1
14
+ latents = ... # maybe some latent codes of real images or SD generation
15
+ latent_mean = latent.mean(dim=0)
16
+ noise = torch.randn([1,bs,64,64])
17
+ input_latent = pipeline.scheduler.add_noise(latent_mean.repeat(bs,1,1,1),noise,1000)
18
+ imgs= pipeline(prompt="A photo of a dog",
19
+ num_inference_steps=steps,
20
+ num_images_per_prompt = 1,
21
+ generator = generator,
22
+ guidance_scale=1.5,
23
+ latents = input_latent,
24
+ )[0]
25
+ imgs
26
+ ```
27
 
28
  ### 2-step inference
29
  We note that a small CFG can be used to enhance the image quality.