Spaces:
Runtime error
Runtime error
Martin Tomov commited on
keycv2 fix
Browse files
app.py
CHANGED
|
@@ -91,7 +91,7 @@ def mask_to_polygon(mask: np.ndarray) -> np.ndarray:
|
|
| 91 |
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 92 |
if len(contours) == 0:
|
| 93 |
return np.array([])
|
| 94 |
-
largest_contour = max(contours,
|
| 95 |
return largest_contour
|
| 96 |
|
| 97 |
def refine_masks(masks: torch.BoolTensor, polygon_refinement: bool = False) -> List[np.ndarray]:
|
|
|
|
| 91 |
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 92 |
if len(contours) == 0:
|
| 93 |
return np.array([])
|
| 94 |
+
largest_contour = max(contours, key=cv2.contourArea)
|
| 95 |
return largest_contour
|
| 96 |
|
| 97 |
def refine_masks(masks: torch.BoolTensor, polygon_refinement: bool = False) -> List[np.ndarray]:
|