Commit
·
958ea27
1
Parent(s):
787a5ea
updating with resize
Browse files
app.py
CHANGED
|
@@ -90,18 +90,18 @@ def image_resize(img, resize=224):
|
|
| 90 |
img = img.astype(np.uint8)
|
| 91 |
return img
|
| 92 |
|
| 93 |
-
def cellpose_segment(
|
| 94 |
-
|
| 95 |
-
masks, flows, _ = model.eval(
|
| 96 |
flows = flows[0]
|
| 97 |
# masks = np.zeros(img.shape[:2])
|
| 98 |
# flows = np.zeros_like(img)
|
| 99 |
target_size = (img_input.shape[1], img_input.shape[0])
|
| 100 |
-
if (target_size[0]!=img.shape[1]
|
| 101 |
# scale it back to keep the orignal size
|
| 102 |
masks = cv2.resize(masks.astype('uint16'), target_size, interpolation=cv2.INTER_NEAREST).astype('uint16')
|
| 103 |
flows = cv2.resize(flows.astype('float32'), target_size).astype('uint8')
|
| 104 |
-
|
| 105 |
outpix = plot_outlines(img, masks)
|
| 106 |
overlay = plot_overlay(img, masks)
|
| 107 |
return outpix, overlay, flows, masks
|
|
|
|
| 90 |
img = img.astype(np.uint8)
|
| 91 |
return img
|
| 92 |
|
| 93 |
+
def cellpose_segment(img_input):
|
| 94 |
+
img = image_resize(img_input)
|
| 95 |
+
masks, flows, _ = model.eval(img, channels=[0,0])
|
| 96 |
flows = flows[0]
|
| 97 |
# masks = np.zeros(img.shape[:2])
|
| 98 |
# flows = np.zeros_like(img)
|
| 99 |
target_size = (img_input.shape[1], img_input.shape[0])
|
| 100 |
+
if (target_size[0]!=img.shape[1] or target_size[1]!=img.shape[0]):
|
| 101 |
# scale it back to keep the orignal size
|
| 102 |
masks = cv2.resize(masks.astype('uint16'), target_size, interpolation=cv2.INTER_NEAREST).astype('uint16')
|
| 103 |
flows = cv2.resize(flows.astype('float32'), target_size).astype('uint8')
|
| 104 |
+
|
| 105 |
outpix = plot_outlines(img, masks)
|
| 106 |
overlay = plot_overlay(img, masks)
|
| 107 |
return outpix, overlay, flows, masks
|