Spaces:
Runtime error
Runtime error
Martin Tomov
commited on
with gr.Blocks() as demo: with gr.Row():
Browse files
app.py
CHANGED
|
@@ -86,7 +86,7 @@ def get_boxes(detection_results: List[DetectionResult]) -> List[List[List[float]
|
|
| 86 |
|
| 87 |
def mask_to_polygon(mask: np.ndarray) -> np.ndarray:
|
| 88 |
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 89 |
-
if len(contours)
|
| 90 |
return np.array([])
|
| 91 |
largest_contour = max(contours, key=cv2.contourArea)
|
| 92 |
return largest_contour
|
|
@@ -231,7 +231,7 @@ with gr.Blocks() as demo:
|
|
| 231 |
|
| 232 |
annotated_output = gr.Image(type="numpy")
|
| 233 |
json_output = gr.Textbox()
|
| 234 |
-
crops_output = gr.Gallery(label="Cropped Bounding Boxes")
|
| 235 |
|
| 236 |
def update_outputs(image, include_json, include_bboxes):
|
| 237 |
results = process_image(image, include_json, include_bboxes)
|
|
|
|
| 86 |
|
| 87 |
def mask_to_polygon(mask: np.ndarray) -> np.ndarray:
|
| 88 |
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 89 |
+
if len(contours) is 0:
|
| 90 |
return np.array([])
|
| 91 |
largest_contour = max(contours, key=cv2.contourArea)
|
| 92 |
return largest_contour
|
|
|
|
| 231 |
|
| 232 |
annotated_output = gr.Image(type="numpy")
|
| 233 |
json_output = gr.Textbox()
|
| 234 |
+
crops_output = gr.Gallery(label="Cropped Bounding Boxes")
|
| 235 |
|
| 236 |
def update_outputs(image, include_json, include_bboxes):
|
| 237 |
results = process_image(image, include_json, include_bboxes)
|