karimbenharrak commited on
Commit
157feb0
·
verified ·
1 Parent(s): 2d5c2d9

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -5
handler.py CHANGED
@@ -20,6 +20,10 @@ class EndpointHandler():
20
  "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16
21
  )
22
  self.smooth_pipe.to("cuda")
 
 
 
 
23
 
24
 
25
 
@@ -39,12 +43,8 @@ class EndpointHandler():
39
  latents = image_processor.preprocess(image)
40
  latents = latents.to(device="cuda")
41
 
42
- vae = AutoencoderKL.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
43
- subfolder="vae", use_safetensors=True,
44
- ).to("cuda")
45
-
46
  with torch.no_grad():
47
- latents_dist = vae.encode(latents).latent_dist.sample() * vae.config.scaling_factor
48
 
49
  self.smooth_pipe.enable_xformers_memory_efficient_attention()
50
  out = self.smooth_pipe(prompt, image=latents_dist).images
 
20
  "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16
21
  )
22
  self.smooth_pipe.to("cuda")
23
+
24
+ self.vae = AutoencoderKL.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
25
+ subfolder="vae", use_safetensors=True,
26
+ ).to("cuda")
27
 
28
 
29
 
 
43
  latents = image_processor.preprocess(image)
44
  latents = latents.to(device="cuda")
45
 
 
 
 
 
46
  with torch.no_grad():
47
+ latents_dist = self.vae.encode(latents).latent_dist.sample() * vae.config.scaling_factor
48
 
49
  self.smooth_pipe.enable_xformers_memory_efficient_attention()
50
  out = self.smooth_pipe(prompt, image=latents_dist).images