harmionestark commited on
Commit
dcc1c7f
Β·
verified Β·
1 Parent(s): a31088e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -19,6 +19,18 @@ pipe.to(device)
19
  pipe.text_encoder.to(device, dtype=torch.float32)
20
  pipe.vae.to(device, dtype=torch.float32)
21
  pipe.unet.to(device, dtype=torch.float32)
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  MAX_SEED = np.iinfo(np.int32).max
24
  MAX_IMAGE_SIZE = 1024
@@ -47,7 +59,7 @@ def infer(
47
  image = pipe(
48
  prompt=prompt,
49
  negative_prompt=negative_prompt,
50
- guidance_scale=guidance_scale,
51
  num_inference_steps=num_inference_steps,
52
  width=width,
53
  height=height,
 
19
  pipe.text_encoder.to(device, dtype=torch.float32)
20
  pipe.vae.to(device, dtype=torch.float32)
21
  pipe.unet.to(device, dtype=torch.float32)
22
+ pipe.scheduler.to(device, dtype=torch.float32)
23
+
24
+ def force_float32(model):
25
+ for param in model.parameters():
26
+ param.data = param.data.to(torch.float32)
27
+ for buffer in model.buffers():
28
+ buffer.data = buffer.data.to(torch.float32)
29
+
30
+ force_float32(pipe.text_encoder)
31
+ force_float32(pipe.vae)
32
+ force_float32(pipe.unet)
33
+ force_float32(pipe.scheduler)
34
 
35
  MAX_SEED = np.iinfo(np.int32).max
36
  MAX_IMAGE_SIZE = 1024
 
59
  image = pipe(
60
  prompt=prompt,
61
  negative_prompt=negative_prompt,
62
+ guidance_scale=torch.tensor(guidance_scale, dtype=torch.float32, device=device),
63
  num_inference_steps=num_inference_steps,
64
  width=width,
65
  height=height,