Spaces:
Runtime error
Runtime error
Martin Tomov commited on
outline update
Browse files
app.py
CHANGED
|
@@ -62,11 +62,6 @@ def annotate(image: Union[Image.Image, np.ndarray], detection_results: List[Dete
|
|
| 62 |
cv2.putText(image_cv2, f'{label}: {score:.2f}', (box.xmin, box.ymin - 10),
|
| 63 |
cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|
| 64 |
|
| 65 |
-
if mask is not None:
|
| 66 |
-
mask_uint8 = (mask * 255).astype(np.uint8)
|
| 67 |
-
contours, _ = cv2.findContours(mask_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 68 |
-
cv2.drawContours(image_cv2, contours, -1, (0, 255, 0), 2)
|
| 69 |
-
|
| 70 |
return cv2.cvtColor(image_cv2, cv2.COLOR_BGR2RGB)
|
| 71 |
|
| 72 |
def plot_detections(image: Union[Image.Image, np.ndarray], detections: List[DetectionResult], include_bboxes: bool = True) -> np.ndarray:
|
|
@@ -215,7 +210,7 @@ examples = [
|
|
| 215 |
|
| 216 |
gr.Interface(
|
| 217 |
fn=process_image,
|
| 218 |
-
inputs=[gr.Image(type="pil"), gr.Checkbox(label="Include JSON", value=False), gr.Checkbox(label="Include Bounding Boxes", value=
|
| 219 |
outputs=[gr.Image(type="numpy"), gr.Textbox()],
|
| 220 |
title="InsectSAM 🐞",
|
| 221 |
examples=examples
|
|
|
|
| 62 |
cv2.putText(image_cv2, f'{label}: {score:.2f}', (box.xmin, box.ymin - 10),
|
| 63 |
cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
return cv2.cvtColor(image_cv2, cv2.COLOR_BGR2RGB)
|
| 66 |
|
| 67 |
def plot_detections(image: Union[Image.Image, np.ndarray], detections: List[DetectionResult], include_bboxes: bool = True) -> np.ndarray:
|
|
|
|
| 210 |
|
| 211 |
gr.Interface(
|
| 212 |
fn=process_image,
|
| 213 |
+
inputs=[gr.Image(type="pil"), gr.Checkbox(label="Include JSON", value=False), gr.Checkbox(label="Include Bounding Boxes", value=True)],
|
| 214 |
outputs=[gr.Image(type="numpy"), gr.Textbox()],
|
| 215 |
title="InsectSAM 🐞",
|
| 216 |
examples=examples
|