rbgirshick / py-faster-rcnn

Faster R-CNN (Python implementation) -- see https://github.com/ShaoqingRen/faster_rcnn for the official MATLAB version
Other
8.11k stars 4.11k forks source link

Is some BUG in bbox_transform.py?? #403

Open tanghy2016 opened 7 years ago

tanghy2016 commented 7 years ago

I added another class to the old 20 ones, but after that, when the training iterated about 20,000 times, overflow occurred and the program ended. So I wrote a print sentence in right that function which overflowed before for checking, and below are the results. Do u know anything about my problem?

code as follow:

def bbox_transform_inv(boxes, deltas): if boxes.shape[0] == 0: return np.zeros((0, deltas.shape[1]), dtype=deltas.dtype)

boxes = boxes.astype(deltas.dtype, copy=False)

widths = boxes[:, 2] - boxes[:, 0] + 1.0
heights = boxes[:, 3] - boxes[:, 1] + 1.0
ctr_x = boxes[:, 0] + 0.5 * widths
ctr_y = boxes[:, 1] + 0.5 * heights

dx = deltas[:, 0::4]
dy = deltas[:, 1::4]
dw = deltas[:, 2::4]
dh = deltas[:, 3::4]

print 'dx=\n', dx, 'dy=\n', dy, 'dw=\n', dw, 'dh=\n', dh, 'shape', dx.shape
pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis]
pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis]
pred_w = np.exp(dw) * widths[:, np.newaxis]
pred_h = np.exp(dh) * heights[:, np.newaxis]

pred_boxes = np.zeros(deltas.shape, dtype=deltas.dtype)
# x1
pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * pred_w
# y1
pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * pred_h
# x2
pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * pred_w
# y2
pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * pred_h

return pred_boxes

result as follow:

wangsky2001 commented 7 years ago

I have a similar problem too. Any one find a solution?

fernandorovai commented 7 years ago

I have the same problem as well. Did you guys find any clue?

HTLife commented 7 years ago

I got similar problem. Didn't find any solution yet.

Every time when program goes to iter=55

gt_heights in bbox_transform will become negative.

def bbox_transform(ex_rois, gt_rois):
...
print(gt_rois[1, 3])
print(gt_rois[1, 1])
#normal
187.5
22.5
166.0

#error
188.75
81918.8
-81729.0

And it is caused by gt_rois[:, 1] is greater than gt_rois[:, 3]

gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0

HaiyongJiang commented 7 years ago

I think it is because of the bug in the bbox_inv_transform. When we need to inversely calculate the x_right, y_top, we need to minus 1 for consistency, namely pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * pred_w -1.

wubaorong commented 6 years ago

@tanghy2016 I met the same error,but I don't know how to solve it,can you help me? /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:51: RuntimeWarning: overflow encountered in exp pred_w = np.exp(dw) widths[:, np.newaxis] /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:51: RuntimeWarning: overflow encountered in multiply pred_w = np.exp(dw) widths[:, np.newaxis] /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:52: RuntimeWarning: overflow encountered in exp pred_h = np.exp(dh) heights[:, np.newaxis] /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:52: RuntimeWarning: overflow encountered in multiply pred_h = np.exp(dh) heights[:, np.newaxis] dw [[ -43.27822113] [ -25.07061386] [ 2.01593685] ..., [-656.98260498] [ -1.75763202] [ 8.05360603]] dh [[ -15.3271513 ] [ -91.23004913] [ 10.69660854] ..., [-882.39678955] [ 5.89947605] [ -46.34132004]] dw [[ 3.35388470e+00] [ 1.31920695e+00] [ 6.19263506e+00] ..., [ 5.52571016e+04] [ 6.56975031e-01] [ 1.32541170e+01]] dh [[ -1.61431007e+01] [ 1.11354284e+01] [ -5.96233797e+00] ..., [ 5.50620898e+04] [ -1.52027397e+01] [ 2.52831030e+00]] dw [[ 3.35388470e+00] [ 1.31920695e+00] [ 6.19263506e+00] ..., [ 5.52571016e+04] [ 6.56975031e-01] [ 1.32541170e+01]] dh [[ -1.61431007e+01] [ 1.11354284e+01] [ -5.96233797e+00] ..., [ 5.50620898e+04] [ -1.52027397e+01] [ 2.52831030e+00]] dw [[ -7.99755469e+11] [ -1.12661050e+12] [ -4.95364628e+10] ..., [ -1.36656558e+15] [ 9.77799021e+11] [ 6.54851768e+11]] dh [[ 7.60489574e+11] [ 5.36720736e+11] [ -8.07536067e+10] ..., [ -1.39083013e+15] [ -9.40745359e+11] [ 1.08815345e+12]] dw [[ -7.99755469e+11] [ -1.12661050e+12] [ -4.95364628e+10] ..., [ -1.36656558e+15] [ 9.77799021e+11] [ 6.54851768e+11]] dh [[ 7.60489574e+11] [ 5.36720736e+11] [ -8.07536067e+10] ..., [ -1.39083013e+15] [ -9.40745359e+11] [ 1.08815345e+12]] dw [[ 1.79596433e+29] [ -6.17638350e+29] [ -1.23744272e+30] ..., [ inf] [ 1.12123926e+30] [ 4.85978886e+29]] dh [[ -9.36732242e+29] [ -5.96307005e+29] [ 7.51251514e+29] ..., [ inf] [ 1.17530431e+30] [ -9.80356859e+29]] /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:56: RuntimeWarning: invalid value encountered in subtract pred_boxes[:, 0::4] = pred_ctr_x - 0.5 pred_w /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/fast_rcnn/bbox_transform.py:58: RuntimeWarning: invalid value encountered in subtract pred_boxes[:, 1::4] = pred_ctr_y - 0.5 pred_h /home/wu/faster_rcnn/py-faster-rcnn/tools/../lib/rpn/proposal_layer.py:175: RuntimeWarning: invalid value encountered in greater_equal keep = np.where((ws >= min_size) & (hs >= min_size))[0] dw [[ 1.79596433e+29] [ -6.17638350e+29] [ -1.23744272e+30] ..., [ inf] [ 1.12123926e+30] [ 4.85978886e+29]] dh [[ -9.36732242e+29] [ -5.96307005e+29] [ 7.51251514e+29] ..., [ inf] [ 1.17530431e+30] [ -9.80356859e+29]] dw [[ nan] [ nan] [ nan] ..., [ nan] [ nan] [ nan]] dh [[ nan] [ nan] [ nan] ..., [ nan] [ nan] [ nan]]

meetps commented 6 years ago

Check my comment here