sovit-123 / fasterrcnn-pytorch-training-pipeline

PyTorch Faster R-CNN Object Detection on Custom Dataset
MIT License
223 stars 77 forks source link

ValueError: x_max is less than or equal to x_min for bbox #44

Closed samahwaleed closed 1 year ago

samahwaleed commented 1 year ago

My bounding box is in "Pascal VOC" format. While training a model, I got this error:

ValueError: x_max is less than or equal to x_min for bbox (tensor(0.3252), tensor(0.9222), tensor(0.3252), tensor(0.9308),tensor(2)).

sovit-123 commented 1 year ago

@samahwaleed Your xmin and xmax have the same coordinates in one of the files. xmax should be at least 1 pixel larger than xmin. You may need to correct the annotations.

samahwaleed commented 1 year ago

is there any way to know the name of the file that has error because I have 3000 training images?

sovit-123 commented 1 year ago

You can print the name by adding a print statement in the datasets.py file. You will need to make --workers 0 so that the files are accessed serially and get the actual file name that has the issue.

samahwaleed commented 1 year ago

I write print(annot_filename) in load_image_and_labels function but it prints all xml file not the file that has error.

sovit-123 commented 1 year ago

The last file name before the error happens is the one that has error.

samahwaleed commented 1 year ago

Got another error: AssertionError: All bounding boxes should have positive height and width. Found invalid box [433.2250061035156, 516.2073974609375, 433.2250061035156, 522.4518432617188] for target at index 1.

sovit-123 commented 1 year ago

This is also an annotation issue. Looks like your dataset has a few object objects where xmin = xmax, and ymin = ymax. This can cause issues with albumentations or the Faster RCNN RPN network. Every xmax and ymax should be at least 1 pixel greater than xmin and ymin.

sovit-123 commented 1 year ago

@samahwaleed Also, please pull the latest code. I made some changes to the mosaic augmentation which improves performance to a great extent.

samahwaleed commented 1 year ago

@sovit-123 it works, Thank you so much

How I can know these informations:

Number of regions to sample,
Number of strongest regions,
Negative overlap range,
Positive overlap range
sovit-123 commented 1 year ago

I think what you are asking for is assigning anchors according to the custom dataset. Right now, the codebase does not support that. I will have to think how to add that to the codebase.

samahwaleed commented 1 year ago

@sovit-123 Thank you Sir,