drkareemkamal commited on
Commit
afeeaa2
·
verified ·
1 Parent(s): 4e6ec3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -58,7 +58,7 @@ from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
58
  ##########################
59
 
60
  sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h_4b8939.pth")
61
- sam.to(device="cuda")
62
 
63
  import streamlit as st
64
  import torch
@@ -77,7 +77,7 @@ import copy
77
  def load_sam():
78
  sam_checkpoint = "sam_vit_h_4b8939.pth"
79
  model_type = "vit_h"
80
- device = "cuda"
81
 
82
  sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
83
  sam.to(device=device)
@@ -104,7 +104,7 @@ def load_pipeline():
104
  torch_dtype=torch.float16,
105
  revision="fp16"
106
  )
107
- pipe = pipe.to('cuda')
108
  pipe.enable_xformers_memory_efficient_attention()
109
  return pipe
110
 
@@ -179,7 +179,7 @@ if uploaded_file:
179
  stable_diffusion_mask = Image.fromarray(selected_mask * 255).convert("RGB")
180
 
181
  pipe = load_pipeline()
182
- generator = torch.Generator(device="cuda").manual_seed(77)
183
 
184
  num_images = 4
185
  images = []
 
58
  ##########################
59
 
60
  sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h_4b8939.pth")
61
+ #sam.to(device="cpu")
62
 
63
  import streamlit as st
64
  import torch
 
77
  def load_sam():
78
  sam_checkpoint = "sam_vit_h_4b8939.pth"
79
  model_type = "vit_h"
80
+ device = "cpu"
81
 
82
  sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
83
  sam.to(device=device)
 
104
  torch_dtype=torch.float16,
105
  revision="fp16"
106
  )
107
+ #pipe = pipe.to('cuda')
108
  pipe.enable_xformers_memory_efficient_attention()
109
  return pipe
110
 
 
179
  stable_diffusion_mask = Image.fromarray(selected_mask * 255).convert("RGB")
180
 
181
  pipe = load_pipeline()
182
+ generator = torch.Generator(device="cpu").manual_seed(77)
183
 
184
  num_images = 4
185
  images = []