sivaprakash-rajendran commited on
Commit
788dc63
·
1 Parent(s): 4cc7b30

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -5,8 +5,11 @@ from diffusers import StableDiffusionPipeline
5
  model_name = "runwayml/stable-diffusion-v1-5"
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
7
 
8
- pipe = StableDiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16)
9
- pipe = pipe.to(device)
 
 
 
10
 
11
  def generate_image(prompt):
12
  with torch.no_grad():
 
5
  model_name = "runwayml/stable-diffusion-v1-5"
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
7
 
8
+ if device == "cuda":
9
+ pipe = StableDiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16)
10
+ pipe = pipe.to(device)
11
+ else:
12
+ pipe = StableDiffusionPipeline.from_pretrained(model_name).to(device)
13
 
14
  def generate_image(prompt):
15
  with torch.no_grad():