Ahmad Basyouni commited on
Commit
89c448c
1 Parent(s): 10fd453

Add application file

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -4,11 +4,14 @@ import torch
4
  from PIL import ImageEnhance, Image
5
  import numpy as np
6
 
7
- # Load Stable Diffusion pipeline with torch.float16 for GPU, fallback to float32 for CPU
8
  model_id = "CompVis/stable-diffusion-v1-4"
9
  default_scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
 
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
  torch_dtype = torch.float16 if device == "cuda" else torch.float32
 
 
12
  pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=default_scheduler, torch_dtype=torch_dtype).to(device)
13
 
14
  # Scheduler options
 
4
  from PIL import ImageEnhance, Image
5
  import numpy as np
6
 
 
7
  model_id = "CompVis/stable-diffusion-v1-4"
8
  default_scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
9
+
10
+ # Set device based on availability
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
  torch_dtype = torch.float16 if device == "cuda" else torch.float32
13
+
14
+ # Load pipeline with appropriate torch dtype
15
  pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=default_scheduler, torch_dtype=torch_dtype).to(device)
16
 
17
  # Scheduler options