Skip to content

Commit

Permalink
Merge pull request #1294 from AldusLorde/doc
Browse files Browse the repository at this point in the history
added additional documentation aboout bbox regression targets
  • Loading branch information
hgaiser authored Feb 27, 2020
2 parents bd102f3 + bcaa165 commit 460461a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions keras_retinanet/utils/anchors.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def generate_anchors(base_size=16, ratios=None, scales=None):
def bbox_transform(anchors, gt_boxes, mean=None, std=None):
"""Compute bounding-box regression targets for an image."""

# The Mean and std are calculated from COCO dataset.
# Bounding box normalization was firstly introduced in the Fast R-CNN paper.
# See https://github.com/fizyr/keras-retinanet/issues/1273#issuecomment-585828825 for more details
if mean is None:
mean = np.array([0, 0, 0, 0])
if std is None:
Expand All @@ -327,6 +330,9 @@ def bbox_transform(anchors, gt_boxes, mean=None, std=None):
anchor_widths = anchors[:, 2] - anchors[:, 0]
anchor_heights = anchors[:, 3] - anchors[:, 1]

# According to the information provided by a keras-retinanet author, they got marginally better results using
# the following way of bounding box parametrization.
# See https://github.com/fizyr/keras-retinanet/issues/1273#issuecomment-585828825 for more details
targets_dx1 = (gt_boxes[:, 0] - anchors[:, 0]) / anchor_widths
targets_dy1 = (gt_boxes[:, 1] - anchors[:, 1]) / anchor_heights
targets_dx2 = (gt_boxes[:, 2] - anchors[:, 2]) / anchor_widths
Expand Down

0 comments on commit 460461a

Please sign in to comment.