jbohnslav / opencv_transforms

OpenCV implementation of Torchvision's image augmentations
MIT License
377 stars 46 forks source link

ColorJitter can't handle float32 images? #11

Closed marisancans closed 4 years ago

marisancans commented 4 years ago

Hi there, using cvtransforms.ColorJitter(brightness=(0, 0.1), contrast=(0, 0.1)) gives me error: File "/home/ma/anaconda3/envs/ml/lib/python3.6/site-packages/opencv_transforms/transforms.py", line 710, in <lambda> transforms.append(Lambda(lambda img: F.adjust_brightness(img, brightness_factor)))' File "/home/ma/anaconda3/envs/ml/lib/python3.6/site-packages/opencv_transforms/functional.py", line 334, in adjust_brightness return cv2.LUT(img, table)[:,:,np.newaxis] cv2.error: OpenCV(4.2.0) /io/opencv/modules/core/src/lut.cpp:368: error: (-215:Assertion failed) (lutcn == cn || lutcn == 1) && _lut.total() == 256 && _lut.isContinuous() && (depth == CV_8U || depth == CV_8S) in function 'LUT'

Looking at these god awful opencv error messages, it might crash because the image is float32?

marisancans commented 4 years ago

This is related: pytorch forums Looks like it's because of float or because i'm using grayscale image