Skip to content

Commit

Permalink
Fix coord bug in centroid_aug.py: optimize centroid box calculatio
Browse files Browse the repository at this point in the history
  • Loading branch information
dummyindex committed May 29, 2024
1 parent 479506f commit a03937d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions notebooks/scripts/mmdetection_classify/centroid_aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,24 @@ def __call__(self, results, exact_match_rg_channel=False):
properties.sort(key=lambda x: x.area, reverse=True)
props = properties[0]
centroid = props.centroid
# centroid_box = np.array(
# [
# centroid[0] - centroid_box_width / 2,
# centroid[1] - centroid_box_width / 2,
# centroid[0] + centroid_box_width / 2,
# centroid[1] + centroid_box_width / 2,
# ]
# )

centroid_box = np.array(
[
centroid[0] - centroid_box_width / 2,
centroid[1] - centroid_box_width / 2,
centroid[0] + centroid_box_width / 2,
centroid[0] - centroid_box_width / 2,
centroid[1] + centroid_box_width / 2,
centroid[0] + centroid_box_width / 2,
]
)

# Clip to image size
centroid_box[0] = max(0, centroid_box[0])
centroid_box[1] = max(0, centroid_box[1])
Expand Down

0 comments on commit a03937d

Please sign in to comment.