ValueError: Requested crop size is larger than the image size in RandomResizedCrop
See original GitHub issue🐛 Bug
ValueError: Requested crop size is larger than the image size
when including RandomResizedCrop in my transforms pipeline:
ValueError: Caught ValueError in DataLoader worker process 1.
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/ai_damages/parts/src/data_loading.py", line 64, in __getitem__
transformed = self.transforms(image=img, mask=mask)
File "/opt/conda/lib/python3.8/site-packages/albumentations/core/composition.py", line 182, in __call__
data = t(force_apply=force_apply, **data)
File "/opt/conda/lib/python3.8/site-packages/albumentations/core/transforms_interface.py", line 89, in __call__
return self.apply_with_params(params, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/albumentations/core/transforms_interface.py", line 102, in apply_with_params
res[key] = target_function(arg, **dict(params, **target_dependencies))
File "/opt/conda/lib/python3.8/site-packages/albumentations/core/transforms_interface.py", line 227, in apply_to_mask
return self.apply(img, **{k: cv2.INTER_NEAREST if k == "interpolation" else v for k, v in params.items()})
File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/transforms.py", line 857, in apply
crop = F.random_crop(img, crop_height, crop_width, h_start, w_start)
File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/functional.py", line 331, in random_crop
raise ValueError(
ValueError: Requested crop size (2131, 1636) is larger than the image size (1836, 3264)
To Reproduce
I can’t reproduce it deterministically, it just happens sometimes.
Environment
- Docker Image: pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime
- Albumentations version: 0.5.2 (by pip)
Additional Context
Instantiated as:
A.RandomResizedCrop(img_size, img_size, scale=(0.20, 1.))
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top Results From Across the Web
ValueError: Requested crop size (64, 64) is larger than the ...
ValueError : Caught ValueError in DataLoader worker process 2. ... ValueError: Requested crop size (64, 64) is larger than the image size (48 ......
Read more >Crop transforms (augmentations.crops.transforms)
Crop and pad images by pixel amounts or fractions of image sizes. Cropping removes pixels at the sides (i.e. extracts a subimage from...
Read more >Torch vision cropping behavior when crop region larger than ...
If an image is smaller than the specified crop region, ... in get_params raise ValueError( ValueError: Required crop size (50, 50) is larger...
Read more >Source code for torchvision.transforms - chsasank.com
Args: tensor (Tensor): Tensor image of size (C, H, W) to be normalized. mean ... h: raise ValueError("Requested crop size {} is bigger...
Read more >Source code for mmaction.datasets.pipelines.augmentations
Fusion order: crop -> resize -> flip Required keys are "imgs", ... supports more than " '2 image scales') scale = random.choice(scales) return...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Now we check that image and mask shapes are equal. More info in #1310
@claverru Thanks! I hit almost exactly the same problem 😃