question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Expected y_min for bbox (0.27531645569620256, 68.33333333333333, 0.7927215189873418, 199.33333333333334, 10) to be in the range [0.0, 1.0], got 68.33333333333333.

See original GitHub issue

🐛 Bug

When trying to perform data augmentation with bounding boxes and mask in coco format, this is the output the is produced. The same problem was also reported in #947 but the problem still persists.

To Reproduce

Traceback (most recent call last):
  File "/workspace/deepfashion_train/train.py", line 216, in <module>
    main()
  File "/workspace/deepfashion_train/train.py", line 213, in main
    trainer.fit(model, data_module)
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 460, in fit
    self._run(model)
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 758, in _run
    self.dispatch()
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 799, in dispatch
    self.accelerator.start_training(self)
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 96, in start_training
    self.training_type_plugin.start_training(trainer)
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 144, in start_training
    self._results = trainer.run_stage()
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 809, in run_stage
    return self.run_train()
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 844, in run_train
    self.run_sanity_check(self.lightning_module)
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1112, in run_sanity_check
    self.run_evaluation()
  File "/opt/conda/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 954, in run_evaluation
    for batch_idx, batch in enumerate(dataloader):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 517, in __next__
    data = self._next_data()
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data
    return self._process_data(data)
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data
    data.reraise()
  File "/opt/conda/lib/python3.8/site-packages/torch/_utils.py", line 429, in reraise
    raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop
    data = fetcher.fetch(index)
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/workspace/deepfashion_train/dataset.py", line 199, in __getitem__
    transformed = self.trans(image=np.asarray(img), masks=mask_list, bboxes = boxes.detach().tolist(), class_labels = labels.detach().tolist())  #bboxes = bbox_labels)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/composition.py", line 180, in __call__
    p.preprocess(data)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/utils.py", line 62, in preprocess
    data[data_name] = self.check_and_convert(data[data_name], rows, cols, direction="to")
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/utils.py", line 70, in check_and_convert
    return self.convert_to_albumentations(data, rows, cols)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 51, in convert_to_albumentations
    return convert_bboxes_to_albumentations(data, self.params.format, rows, cols, check_validity=True)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 302, in convert_bboxes_to_albumentations
    return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 302, in <listcomp>
    return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 251, in convert_bbox_to_albumentations
    check_bbox(bbox)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 327, in check_bbox
    raise ValueError(
ValueError: Expected y_min for bbox (0.27531645569620256, 68.33333333333333, 0.7927215189873418, 199.33333333333334, 10) to be in the range [0.0, 1.0], got 68.33333333333333.

The code that generates this error is:

self.trans = A.Compose([
                A.Resize(224, 224),
                        #A.Resize(256, 128),
                        #A.RandomRotate90(),
                A.Flip(),
                A.ColorJitter(brightness= 0.3, contrast= 0.3,saturation=0.1, hue=0.1, p=0.3),
                #A.Transpose(),
                A.GaussNoise(),
                #A.RandomCrop(width=224, height=224),
                A.OneOf([
                    A.MotionBlur(p=.5),
                    A.MedianBlur(blur_limit=3, p=0.5),
                    A.Blur(blur_limit=3, p=0.5),
                ], p=0.5),
                A.ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=0.5),
                A.OneOf([
                    A.OpticalDistortion(p=0.5),
                    A.GridDistortion(p=.3),
                    A.PiecewiseAffine(p=0.5),
                ], p=0.5),
                A.OneOf([
                    A.CLAHE(clip_limit=2),
                    A.Emboss(),
                    A.RandomBrightnessContrast(),            
                ], p=0.5),
                A.HueSaturationValue(p=0.5),
                    #A.Normalize(mean=(0.486, 0.459, 0.408), std=(0.229, 0.224, 0.225)),
                    ToTensorV2()
                ], bbox_params=A.BboxParams(format='coco', label_fields=['class_labels']))
        else:
            self.trans = A.Compose([
                A.Resize(224, 224),
                ToTensorV2()
            ], bbox_params = A.BboxParams(format='coco', label_fields=['class_labels']))

Expected behavior

Perform some image augmentations technique over the dataset with bounding boxes and masks.

Environment

  • Albumentations version (e.g., 0.1.8): 1.0.1
  • Python version (e.g., 3.7): 3.7
    
  • OS (e.g., Linux): Linux
    
  • How you installed albumentations (conda, pip, source): pip
    

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

1reaction
narain1commented, Jul 12, 2021

that PR has’nt been merged

1reaction
aliceinlandcommented, Jul 12, 2021

Already updated the package, before publishing the issue, and the error is still present.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value Error: Expected x_max for bbox (0.73, 0.26, 1.02, 0.39 ...
When I train my own dataset with Faster RCNN by pytorch, I got this error - 'ValueError: Expected x_max for bbox (0.7343220683333334, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found