提交 33f02d99 编写于 作者: D dengkaipeng

fix comments

上级 0f148a62
...@@ -59,7 +59,7 @@ def get_isr_p_func(pos_iou_thresh=0.25, bias=0, k=2): ...@@ -59,7 +59,7 @@ def get_isr_p_func(pos_iou_thresh=0.25, bias=0, k=2):
weight_factor = np.clip(max_l_num - l_max_iou_rank, 0., weight_factor = np.clip(max_l_num - l_max_iou_rank, 0.,
None) / max_l_num None) / max_l_num
weight_factor = np.power(bias + (1 - bias) * weight_factor, k) weight_factor = np.power(bias + (1 - bias) * weight_factor, k)
pos_weights[l_inds] *= weight_factor * 1.2 pos_weights[l_inds] *= weight_factor
pos_weights = pos_weights / np.mean(pos_weights) pos_weights = pos_weights / np.mean(pos_weights)
all_pos_weights[pos_mask] = pos_weights all_pos_weights[pos_mask] = pos_weights
......
...@@ -142,21 +142,24 @@ class YOLOv3Loss(object): ...@@ -142,21 +142,24 @@ class YOLOv3Loss(object):
iou = self._calc_iou(output, target, gt_box, anchors, batch_size, iou = self._calc_iou(output, target, gt_box, anchors, batch_size,
num_classes, downsample, scale_x_y) num_classes, downsample, scale_x_y)
# sorted_iou, sorted_gt_inds = fluid.layers.argsort(iou, axis=-1, descending=True) sorted_iou, sorted_gt_inds = fluid.layers.argsort(
# max_iou = sorted_iou[:, :, 0:1] iou, axis=-1, descending=True)
# gt_inds = fluid.layers.cast(sorted_gt_inds[:, :, 0:1], dtype='float32') max_iou = sorted_iou[:, :, 0:1]
# pred_cls = fluid.layers.argmax(cls, axis=-1) gt_inds = fluid.layers.cast(
# pred_cls = fluid.layers.reshape(pred_cls, [batch_size, -1, 1]) sorted_gt_inds[:, :, 0:1], dtype='float32')
# pred_cls = fluid.layers.cast(pred_cls, dtype='float32') pred_cls = fluid.layers.argmax(cls, axis=-1)
# isr_p_input = fluid.layers.concat([max_iou, gt_inds, pred_cls], axis=-1) pred_cls = fluid.layers.reshape(pred_cls, [batch_size, -1, 1])
# isr_p = get_isr_p_func() pred_cls = fluid.layers.cast(pred_cls, dtype='float32')
# pos_weights = fluid.layers.zeros_like(max_iou) isr_p_input = fluid.layers.concat(
# fluid.layers.py_func(isr_p, isr_p_input, pos_weights) [max_iou, gt_inds, pred_cls], axis=-1)
# isr_p = get_isr_p_func()
# tobj_shape = fluid.layers.shape(tobj) pos_weights = fluid.layers.zeros_like(max_iou)
# pos_weights = fluid.layers.reshape(pos_weights, (-1, an_num, tobj_shape[2], fluid.layers.py_func(isr_p, isr_p_input, pos_weights)
# tobj_shape[3]))
# tobj = tobj * pos_weights tobj_shape = fluid.layers.shape(tobj)
pos_weights = fluid.layers.reshape(pos_weights, (
-1, an_num, tobj_shape[2], tobj_shape[3]))
tobj = tobj * pos_weights
# isr_tobj = tobj * pos_weights # isr_tobj = tobj * pos_weights
# loss_cls = fluid.layers.sigmoid_cross_entropy_with_logits(cls, tcls) # loss_cls = fluid.layers.sigmoid_cross_entropy_with_logits(cls, tcls)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册