mahazainab commited on
Commit
a1cebdc
·
verified ·
1 Parent(s): e1c6875

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -7,8 +7,16 @@ from PIL import Image
7
  @st.cache_resource
8
  def load_model():
9
  model_id = "runwayml/stable-diffusion-v1-5"
10
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
11
- pipe = pipe.to("cuda")
 
 
 
 
 
 
 
 
12
  return pipe
13
 
14
  pipe = load_model()
 
7
  @st.cache_resource
8
  def load_model():
9
  model_id = "runwayml/stable-diffusion-v1-5"
10
+
11
+ # Load the model
12
+ pipe = StableDiffusionPipeline.from_pretrained(model_id)
13
+
14
+ # Check if CUDA is available and use it, otherwise fall back to CPU
15
+ if torch.cuda.is_available():
16
+ pipe = pipe.to("cuda")
17
+ else:
18
+ pipe = pipe.to("cpu")
19
+
20
  return pipe
21
 
22
  pipe = load_model()