qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)
MIT License
7.14k stars 3.44k forks source link

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

Open ShimaShamli opened 3 years ago

ShimaShamli commented 3 years ago

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(batchsize): , 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?

Anyman552 commented 3 years ago

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.

Eman-Ehab commented 3 years ago

@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?

Anyman552 commented 3 years ago

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

SidhaantAnand commented 2 years ago

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