albumentations
albumentations copied to clipboard
A.Perspective(fit_output=True), will cause cv2 outofmemory and also caused unstable excute time
🐛 Bug
Hi, when i use Albumentations.Perspective() class to enhance my image, i tryed to set fit_output=True, will get an erro with below: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 5291741479792 bytes in function 'cv::OutOfMemoryError'
the images in the list select_obj are not same shape but all of them are very small in range(200, 200, 1).It should take very little time to process one image, but sometimes, it takes a long time for one image
when i set fit_output=False, the erro is gone
I tyed in two compute with different os: windows and linux, have the same issue please anyone can help me to fit it, thanks!
please see the screenshor with my code and erro:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Environment
- Albumentations version (e.g., 1.3.1):
- Python version (e.g., 3.10):
- OS (e.g., Linux&Windows):
- How you installed albumentations (
conda
,pip
,): - Any other relevant information:
Additional context
I got same problem, and the imgaug library has the same problem when I use perspective transform.
🐛 Bug
Hi, when i use Albumentations.Perspective() class to enhance my image, i tryed to set fit_output=True, will get an erro with below: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 5291741479792 bytes in function 'cv::OutOfMemoryError'
the images in the list select_obj are not same shape but all of them are very small in range(200, 200, 1).It should take very little time to process one image, but sometimes, it takes a long time for one image
when i set fit_output=False, the erro is gone
I tyed in two compute with different os: windows and linux, have the same issue please anyone can help me to fit it, thanks!
please see the screenshor with my code and erro:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Environment
- Albumentations version (e.g., 1.3.1):
- Python version (e.g., 3.10):
- OS (e.g., Linux&Windows):
- How you installed albumentations (
conda
,pip
,):- Any other relevant information:
Additional context
I found the reason, in perspective transform, the max_height and max_width is too large. I print the matrix,image shape, max_height and max_width. You can see how large them are.
My solution is to add this code in call function in BasicTransform class
if ('max_height' in params and params['max_height'] > self.max_side) or \ ('max_width' in params and params['max_width'] > self.max_side): # error params['matrix'] = np.eye(3) params['max_height'] = kwargs['image'].shape[0] params['max_width'] = kwargs['image'].shape[1]
I set max_side to 10000, if the params are too large, this code will keep the image unchanged
Could you please share a piece of code that will allow us to reproduce the issue?