mouseland commited on
Commit
bce0fa8
·
verified ·
1 Parent(s): 062c28f

Update app.py

Browse files

GPU should only be active for model eval

Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -91,10 +91,15 @@ def image_resize(img, resize=400):
91
  img = img.astype(np.uint8)
92
  return img
93
 
 
94
  @spaces.GPU(duration=10)
 
 
 
 
95
  def cellpose_segment(img_input):
96
  img = image_resize(img_input)
97
- masks, flows, _ = model.eval(img, channels=[0,0])
98
  flows = flows[0]
99
  # masks = np.zeros(img.shape[:2])
100
  # flows = np.zeros_like(img)
 
91
  img = img.astype(np.uint8)
92
  return img
93
 
94
+
95
  @spaces.GPU(duration=10)
96
+ def run_model_gpu(model, img):
97
+ masks, flows, _ = model.eval(img, channels=[0,0])
98
+ return masks, flows
99
+
100
  def cellpose_segment(img_input):
101
  img = image_resize(img_input)
102
+ masks, flows = run_model_gpu(model, img)
103
  flows = flows[0]
104
  # masks = np.zeros(img.shape[:2])
105
  # flows = np.zeros_like(img)