Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #955

Open
aliceinland opened this issue Jul 9, 2021 · 8 comments

Comments

@aliceinland
Copy link

🐛 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
    
@narain1
Copy link

narain1 commented Jul 12, 2021

#958

yet to be merged

I think this PR should be solving the issue but I am not sure of it Kindly check

@aliceinland
Copy link
Author

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

@narain1
Copy link

narain1 commented Jul 12, 2021

that PR has'nt been merged

@narain1
Copy link

narain1 commented Jul 24, 2021

!pip install git+https://github.com/albumentations-team/albumentations.git

its working fine now try installing with this

@srrobo92
Copy link

That command to install doesn't work.

ERROR: Could not find a version that satisfies the requirement albumentations-beta (from versions: none)
ERROR: No matching distribution found for albumentations-beta

@narain1
Copy link

narain1 commented Jul 29, 2021

1.0.3 worked fine for me would you mind sharing your bbox inputs

@aengusng8
Copy link

@srrobo92 Did you solve the problem?

@narain1
Copy link

narain1 commented Dec 18, 2021

pascal version was working fine for me i haven't checked upon yolo format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants