keras-yolo3 icon indicating copy to clipboard operation
keras-yolo3 copied to clipboard

IndexError: index 160 is out of bounds for axis 0 with size 160

Open ShimaShamli opened this issue 4 years ago • 4 comments

I get this error when I train on bottleneck.

IndexError: index 160 is out of bounds for axis 0 with size 160

This is the code that the error says it has the problem

def bottleneck_generator(annotation_lines, batch_size, input_shape, anchors, num_classes, bottlenecks): n = len(annotation_lines) i = 0 while True: box_data = [] b0=np.zeros((batch_size,bottlenecks[0].shape[1],bottlenecks[0].shape[2],bottlenecks[0].shape[3])) b1=np.zeros((batch_size,bottlenecks[1].shape[1],bottlenecks[1].shape[2],bottlenecks[1].shape[3])) b2=np.zeros((batch_size,bottlenecks[2].shape[1],bottlenecks[2].shape[2],bottlenecks[2].shape[3])) for b in range(batch_size): _, box = get_random_data(annotation_lines[i], input_shape, random=False, proc_img=False) box_data.append(box) b0[b]=bottlenecks[0][i] b1[b]=bottlenecks[1][i] b2[b]=bottlenecks[2][i] i = (i+1) % n box_data = np.array(box_data) y_true = preprocess_true_boxes(box_data, input_shape, anchors, num_classes) yield [b0, b1, b2, *y_true], np.zeros(batch_size)

Is there something wrong with the code? or is there any other solution?

ShimaShamli avatar Jan 25 '21 00:01 ShimaShamli

The code works. I got similar errors because of incompatible versions of tensorflow, cuda, cudnn, keras. It works for me with Cuda 10, cudnn 7.6, tensorflow-gpu==1.15.3 and Keras==2.2.4.

Anyman552 avatar Feb 02 '21 09:02 Anyman552

@Anyman552 I used train.py and I got no error with the code, but when I used train_bottleneck I faced the same problem, train_bottleneck worked with little amount of data but with a high loss then nan, when I try on the whole dataset I got similar error. any idea?

Eman-Ehab avatar Feb 23 '21 11:02 Eman-Ehab

Unfortunately no. I only use train.py. Sorry!

Anyman552 avatar Feb 25 '21 10:02 Anyman552

I noticed this issue when bboxes data has values > 416 (image width and height)

SidhaantAnand avatar Oct 26 '21 18:10 SidhaantAnand