{"action":"opened","issue":{"url":"https://api.github.com/repos/fizyr/keras-retinanet/issues/171","repository_url":"https://api.github.com/repos/fizyr/keras-retinanet","labels_url":"https://api.github.com/repos/fizyr/keras-retinanet/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/fizyr/keras-retinanet/issues/171/comments","events_url":"https://api.github.com/repos/fizyr/keras-retinanet/issues/171/events","html_url":"https://github.com/fizyr/keras-retinanet/issues/171","id":280263714,"number":171,"title":"bbox_transform formula","user":{"login":"Cre1th","id":13314142,"avatar_url":"https://avatars2.githubusercontent.com/u/13314142?v=4","gravatar_id":"","url":"https://api.github.com/users/Cre1th","html_url":"https://github.com/Cre1th","followers_url":"https://api.github.com/users/Cre1th/followers","following_url":"https://api.github.com/users/Cre1th/following{/other_user}","gists_url":"https://api.github.com/users/Cre1th/gists{/gist_id}","starred_url":"https://api.github.com/users/Cre1th/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cre1th/subscriptions","organizations_url":"https://api.github.com/users/Cre1th/orgs","repos_url":"https://api.github.com/users/Cre1th/repos","events_url":"https://api.github.com/users/Cre1th/events{/privacy}","received_events_url":"https://api.github.com/users/Cre1th/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-07T20:14:31Z","updated_at":"2017-12-07T20:14:31Z","closed_at":null,"author_association":"NONE","body":"Hey, I was wondering why 1.0 is added to the widths and heights in [bbox_transform](https://github.com/fizyr/keras-retinanet/blob/master/keras_retinanet/utils/anchors.py).\r\n\r\n```\r\nanchor_widths  = anchors[:, 2] - anchors[:, 0] + 1.0\r\nanchor_heights = anchors[:, 3] - anchors[:, 1] + 1.0\r\nanchor_ctr_x   = anchors[:, 0] + 0.5 * anchor_widths\r\nanchor_ctr_y   = anchors[:, 1] + 0.5 * anchor_heights\r\n```\r\n...\r\n```\r\ntargets_dx = (gt_ctr_x - anchor_ctr_x) / anchor_widths\r\ntargets_dy = (gt_ctr_y - anchor_ctr_y) / anchor_heights\r\ntargets_dw = np.log(gt_widths / anchor_widths)\r\ntargets_dh = np.log(gt_heights / anchor_heights)\r\n```\r\n\r\nIt seems to me the purpose is to avoid division by zero. But I think, taking the maximum(1, anchor_widths/anchor_heights) is better suited for this task.\r\nEspecially because I think this introduces a slight error. Let's say the center offset in `x` is `10` then `target_dx = 10 / (anchors[:, 2] - anchors[:, 0] + 1.0)`. This is the value we want our regressor to have.\r\nUsing now [inv_bbox_transform](https://github.com/fizyr/keras-retinanet/blob/master/keras_retinanet/backend/common.py) even with this target regression result\r\n`pred_ctr_x = ctr_x + target_dx * widths` does not yield the result we want of `ctr_x + 10`. This is because `target_dw * widths` is slightly less then 10 as in [inv_bbox_transform](https://github.com/fizyr/keras-retinanet/blob/master/keras_retinanet/backend/common.py) the + 1.0 is not taken into account see `widths  = boxes[:, :, 2] - boxes[:, :, 0]`.\r\n\r\nSo my question is: Does this +1.0 serve any other purpose?\r\n"}}
{"actor":{"display_login":"Cre1th"}}