Skip to content

Commit 06bdcbe

Browse files
Fix naming of get_centers_and_bounding_boxes; update corresponding test
1 parent 6c3b25c commit 06bdcbe

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

micro_sam/prompt_generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class PointAndBoxPromptGenerator:
1111
You can use this class to derive prompts from an instance segmentation, either for
1212
evaluation purposes or for training Segment Anything on custom data.
1313
In order to use this generator you need to precompute the bounding boxes and center
14-
coordiantes of the instance segmentation, using e.g. `util.get_bounding_boxes_and_centers`.
14+
coordiantes of the instance segmentation, using e.g. `util.get_centers_and_bounding_boxes`.
1515
Here's an example for how to use this class:
1616
```python
1717
# Initialize generator for 1 positive and 4 negative point prompts.
1818
prompt_generator = PointAndBoxPromptGenerator(1, 4, dilation_strength=8)
1919
# Precompute the bounding boxes for the given segmentation
20-
bounding_boxes, _ = util.get_bounding_boxes_and_centes(segmentation)
20+
bounding_boxes, _ = util.get_centers_and_bounding_boxes(segmentation)
2121
# generate point prompts for the object with id 1 in 'segmentation'
2222
seg_id = 1
2323
points, point_labels, _, _ = prompt_generator(segmentation, seg_id, bounding_boxes)

micro_sam/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def compute_iou(mask1: np.ndarray, mask2: np.ndarray) -> float:
450450
return iou
451451

452452

453-
def get_bounding_boxes_and_centers(
453+
def get_centers_and_bounding_boxes(
454454
segmentation: np.ndarray,
455455
mode: str = "v"
456456
) -> tuple[Mapping[int, np.ndarray], Mapping[int, tuple]]:

test/test_prompt_generators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def _debug(self, mask, center, box, coords, point_labels):
4141

4242
def test_point_prompt_generator(self):
4343
from micro_sam.prompt_generators import PointAndBoxPromptGenerator
44-
from micro_sam.util import get_cell_center_coordinates
44+
from micro_sam.util import get_centers_and_bounding_boxes
4545

4646
labels = self._get_test_data()
4747
label_ids = np.unique(labels)[1:]
4848

49-
centers, boxes = get_cell_center_coordinates(labels)
49+
centers, boxes = get_centers_and_bounding_boxes(labels)
5050

5151
test_point_pairs = [(1, 0), (1, 1), (4, 3), (2, 4), (3, 9), (13, 27)]
5252
for (n_pos, n_neg) in test_point_pairs:
@@ -70,12 +70,12 @@ def test_point_prompt_generator(self):
7070

7171
def test_box_prompt_generator(self):
7272
from micro_sam.prompt_generators import PointAndBoxPromptGenerator
73-
from micro_sam.util import get_cell_center_coordinates
73+
from micro_sam.util import get_centers_and_bounding_boxes
7474

7575
labels = self._get_test_data()
7676
label_ids = np.unique(labels)[1:]
7777

78-
centers, boxes = get_cell_center_coordinates(labels)
78+
centers, boxes = get_centers_and_bounding_boxes(labels)
7979
generator = PointAndBoxPromptGenerator(0, 0, dilation_strength=0, get_point_prompts=False, get_box_prompts=True)
8080

8181
for label_id in label_ids:

0 commit comments

Comments
 (0)