Update README.md
Browse files
README.md
CHANGED
|
@@ -68,11 +68,17 @@ segmentation = img_proc.post_process_semantic_segmentation(
|
|
| 68 |
output,
|
| 69 |
target_sizes=[img.size[::-1]]
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
def detect_bboxes(masks: np.ndarray):
|
| 73 |
r"""
|
| 74 |
-
A simple bounding box detection function
|
| 75 |
-
the performance metrics in the "Performance" section.
|
| 76 |
"""
|
| 77 |
detected_blocks = []
|
| 78 |
contours, _ = cv2.findContours(
|
|
@@ -88,7 +94,7 @@ def detect_bboxes(masks: np.ndarray):
|
|
| 88 |
detected_blocks.append(bounding_box)
|
| 89 |
return detected_blocks
|
| 90 |
|
| 91 |
-
|
| 92 |
for segment in segmentation:
|
| 93 |
bboxes, labels = [], []
|
| 94 |
for ii in range(1, len(model.config.label2id)):
|
|
@@ -97,7 +103,7 @@ for segment in segmentation:
|
|
| 97 |
bbx, lab = detect_bboxes(mm.numpy())
|
| 98 |
bboxes.extend(bbx)
|
| 99 |
labels.extend([ii]*len(bbx))
|
| 100 |
-
|
| 101 |
```
|
| 102 |
|
| 103 |
### Citation
|
|
|
|
| 68 |
output,
|
| 69 |
target_sizes=[img.size[::-1]]
|
| 70 |
)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Here is a simple method for detecting bounding boxes from semantic segmentation. This is the method used to calculate the model's performance in object
|
| 74 |
+
detection, as described in the "Performance" section. The method is provided without any additional post-processing.
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
import cv2
|
| 78 |
|
| 79 |
def detect_bboxes(masks: np.ndarray):
|
| 80 |
r"""
|
| 81 |
+
A simple bounding box detection function
|
|
|
|
| 82 |
"""
|
| 83 |
detected_blocks = []
|
| 84 |
contours, _ = cv2.findContours(
|
|
|
|
| 94 |
detected_blocks.append(bounding_box)
|
| 95 |
return detected_blocks
|
| 96 |
|
| 97 |
+
bbox_pred = []
|
| 98 |
for segment in segmentation:
|
| 99 |
bboxes, labels = [], []
|
| 100 |
for ii in range(1, len(model.config.label2id)):
|
|
|
|
| 103 |
bbx, lab = detect_bboxes(mm.numpy())
|
| 104 |
bboxes.extend(bbx)
|
| 105 |
labels.extend([ii]*len(bbx))
|
| 106 |
+
bbox_pred.append(dict(bboxes=bboxes, labels=lables))
|
| 107 |
```
|
| 108 |
|
| 109 |
### Citation
|