sovit-123 / fasterrcnn-pytorch-training-pipeline

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

Albumentations bouning box error #96

Closed unrue closed 3 months ago

unrue commented 1 year ago

I'm using such tools with a pascal voc dataset format, containint about 25000 images (20000 training, 5000 validation more or less). I'm launching the toos as:

python3.10 fasterrcnn-pytorch-training-pipeline/train.py --data my_dataset/data_configs/beni_culturali.yaml --epochs 100 --model fasterrcnn_resnet50_fpn --name my_dataset--batch 16 --disable-wandb

After some iterations, I get:

Epoch: [0]  [ 300/1217]  eta: 0:07:53  lr: 0.000302  loss: 1.5418 (2.1702)  loss_classifier: 0.8286 (1.3794)  loss_box_reg: 0.6446 (0.6246)  loss_objectness: 0.0279 (0.1101)  loss_rpn_box_reg: 0.0424 (0.0561)  time: 0.5274  data: 0.0108  max mem: 23807
Corrupt JPEG data: 2 extraneous bytes before marker 0xd6
.....
 File ****/lib/python3.10/site-packages/albumentations/core/bbox_utils.py", line 435, in check_bbox
    raise ValueError(f"Expected {name} for bbox {bbox} to be in the range [0.0, 1.0], got {value}.")
ValueError: Expected x_min for bbox (tensor(1.1671), tensor(0.3307), tensor(1.), tensor(0.8002), tensor(34)) to be in the range [0.0, 1.0], got 1.1670734882354736.

Why it detect corrupted JPEG? I used such dataset with other object detection tools and worked well. How can I understand which is the JPEG involved or how can I simply skip the corrupted JPEG? Thanks.

sovit-123 commented 1 year ago

Hello @unrue Actually, the image is not corrupted. The xmin which should be smaller than the image width is larger than that. Or maybe it is larger than xmax. This looks like an annotation issue in the dataset itself.

unrue commented 1 year ago

Hi, thanks for the reply. So, are you saying such error is irrelevant?

Corrupt JPEG data: 2 extraneous bytes before marker 0xd6

I'm pretty sure my dataset has right coordinates, I checked before start the training. Is it possible to understand which is the image involved?

sovit-123 commented 1 year ago

It may need some work. I think you will need to run with --workers 0 so that it runs in the main thread. Further, you will need to add a print statement in the datasets.py to know exactly which image has the issue.

sovit-123 commented 3 months ago

Hello, I have just pushed an update to datasets.py. It removes all files with invalid bounding boxes before training. I am closing the issue for now. Please re-open if needed.