lucasjinreal/keras_frcnn

Bounding boxes dictionary empty

drprajapati opened this issue · 3 comments

bbox_threshold = 0.8
#apply the spatial pyramid pooling to the proposed regions
boxes = dict()
for jk in range(result.shape[0] // cfg.num_rois + 1):
rois = np.expand_dims(result[cfg.num_rois * jk:cfg.num_rois * (jk + 1), :], axis=0)
if rois.shape[1] == 0:
break
if jk == result.shape[0] // cfg.num_rois:
# pad R
curr_shape = rois.shape
target_shape = (curr_shape[0], cfg.num_rois, curr_shape[2])
rois_padded = np.zeros(target_shape).astype(rois.dtype)
rois_padded[:, :curr_shape[1], :] = rois
rois_padded[0, curr_shape[1]:, :] = rois[0, 0, :]
rois = rois_padded
[p_cls, p_regr] = model_classifier_only.predict([F, rois])

    for ii in range(p_cls.shape[1]):
        if np.max(p_cls[0, ii, :]) < bbox_threshold or np.argmax(p_cls[0, ii, :]) == (p_cls.shape[2] - 1):
            continue

        cls_num = np.argmax(p_cls[0, ii, :])
        if cls_num not in boxes.keys():
            boxes[cls_num] = []
        (x, y, w, h) = rois[0, ii, :]
        try:
            (tx, ty, tw, th) = p_regr[0, ii, 4 * cls_num:4 * (cls_num + 1)]
            tx /= cfg.classifier_regr_std[0]
            ty /= cfg.classifier_regr_std[1]
            tw /= cfg.classifier_regr_std[2]
            th /= cfg.classifier_regr_std[3]
            x, y, w, h = roi_helpers.apply_regr(x, y, w, h, tx, ty, tw, th)
        except Exception as e:
            print(e)
            pass
        boxes[cls_num].append(
            [cfg.rpn_stride * x, cfg.rpn_stride * y, cfg.rpn_stride * (x + w), cfg.rpn_stride * (y + h),
             np.max(p_cls[0, ii, :])])

print(boxes.items())

The boxes.items() has no elements in it.

Please help

Did you try to reduce the value of bbox_threshold? e.g. bbox_threshold = 0.1.

I run test_frcnn_kitti with "bbox_threshold = 0.10". That is ok but the bounding box is very crowded. Other arguments from 0.8 to 0.11 can not work.