Update app.py
Browse filesGPU should only be active for model eval
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
|
| 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)
|