vilarin commited on
Commit
b54258a
·
verified ·
1 Parent(s): d18136b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -28,6 +28,8 @@ JS = """function () {
28
  }
29
  }"""
30
 
 
 
31
  # Load VAE component
32
  vae = AutoencoderKL.from_pretrained(
33
  vae_model,
@@ -36,7 +38,7 @@ vae = AutoencoderKL.from_pretrained(
36
 
37
  # Ensure model and scheduler are initialized in GPU-enabled function
38
  if torch.cuda.is_available():
39
- pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to(0)
40
 
41
  pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
42
 
 
28
  }
29
  }"""
30
 
31
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
32
+
33
  # Load VAE component
34
  vae = AutoencoderKL.from_pretrained(
35
  vae_model,
 
38
 
39
  # Ensure model and scheduler are initialized in GPU-enabled function
40
  if torch.cuda.is_available():
41
+ pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to(device)
42
 
43
  pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
44