taipingeric / yolo-v4-tf.keras

A simple tf.keras implementation of YOLO v4
MIT License
140 stars 79 forks source link

Index out of bound error in custom training #6

Open einareinarsson opened 3 years ago

einareinarsson commented 3 years ago

Hello!

I tried to train a custom model with another data set but failed with the following:

  File "/home/.../yolo-v4-tf.keras-master/utils.py", line 290, in preprocess_true_boxes
    y_true[stage][batch_idx, grid_row, grid_col, anchor_idx, :2] = true_boxes_xy[batch_idx, box_idx, :]  # abs xy

IndexError: index 52 is out of bounds for axis 1 with size 52

The differences with the data:

gajdosech2 commented 3 years ago

Did you change anything in the config.py file? Other than that I am thinking maybe there is some problem with your annotations file... Are you using the VOC .xml file format, or directly or directly the .txt with img_path BOX0 BOX1 BOX2 ... per each line? Can you maybe post your annotations file here? Or ideally a sample from your dataset? I can try it, as I am already using this implementation on my own data without problems.

nrgrady commented 3 years ago

I had a similar problem, and was able to resolve it by switching my x and y coordinates in the annotation file around. Worth a shot.

arseniivanov commented 2 years ago

Had the same issue, it means that the coordinates for the bounding-boxes are not passed in the expected format.

The expected format is image_file_name xmin, ymin, xmax, ymax, classnum 1 - If you are using LabelImg to make your boxes for YOLO, you will get coordinates on the format normxcenter, normycenter, normwidth, normheight, so you need to scale them with your image size, followed by a subtraction/addition of half the widths/heights in order to get the expected format values. 2 - Check for arithmetic errors, you will probably copy code, and might use xmax used in place of ymax at some place for example.

kalikhademi commented 1 year ago

I have the same problem for custom training with my own data. I have attached my train_annotation.txt to this message.

I also attached the screenshot of my log error.

I appreciate it your help! train_annotation.txt

kalikhademi commented 1 year ago

Did you change anything in the config.py file? Other than that I am thinking maybe there is some problem with your annotations file... Are you using the VOC .xml file format, or directly or directly the .txt with img_path BOX0 BOX1 BOX2 ... per each line? Can you maybe post your annotations file here? Or ideally a sample from your dataset? I can try it, as I am already using this implementation on my own data without problems.

Can you let me know what changes I need to make in config.py?