I am trying to use albumentations for data augmentation following this notebook. When I try to fit the model, I get a UnknownError: Graph execution error:
. Below is the full error code.
Epoch 1/10
---------------------------------------------------------------------------
UnknownError Traceback (most recent call last)
<ipython-input-42-f02a657ecadb> in <module>()
47 )
48 model.compile(loss=loss_func,optimizer=optimizer)
---> 49 history = model.fit(train_ds,validation_data=val_ds,class_weight=class_weights,epochs=EPOCHS,callbacks=[mc,es],verbose=1)
50
51 perf[fold+1] = history
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
53 ctx.ensure_initialized()
54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:
UnknownError: Graph execution error:
2 root error(s) found.
(0) UNKNOWN: error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3>; VDepth = cv::impl::{anonymous}::Set<0, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::<unnamed>::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py", line 271, in __call__
ret = func(*args)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py", line 642, in wrapper
return func(*args, **kwargs)
File "<ipython-input-26-1b9ce6086764>", line 3, in aug_fn
aug_data = transforms(**data)
File "/usr/local/lib/python3.7/dist-packages/albumentations/core/composition.py", line 171, in __call__
data = t(**data)
File "/usr/local/lib/python3.7/dist-packages/albumentations/core/transforms_interface.py", line 38, in __call__
res[key] = target_function(arg, **dict(params, **target_dependencies))
File "/usr/local/lib/python3.7/dist-packages/albumentations/augmentations/transforms.py", line 898, in apply
return F.shift_hsv(image, hue_shift, sat_shift, val_shift)
File "/usr/local/lib/python3.7/dist-packages/albumentations/augmentations/functional.py", line 244, in shift_hsv
img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3>; VDepth = cv::impl::{anonymous}::Set<0, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::<unnamed>::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
[[{{node PyFunc}}]]
[[IteratorGetNext]]
[[IteratorGetNext/_2]]
(1) UNKNOWN: error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3>; VDepth = cv::impl::{anonymous}::Set<0, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::<unnamed>::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py", line 271, in __call__
ret = func(*args)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py", line 642, in wrapper
return func(*args, **kwargs)
File "<ipython-input-26-1b9ce6086764>", line 3, in aug_fn
aug_data = transforms(**data)
File "/usr/local/lib/python3.7/dist-packages/albumentations/core/composition.py", line 171, in __call__
data = t(**data)
File "/usr/local/lib/python3.7/dist-packages/albumentations/core/transforms_interface.py", line 38, in __call__
res[key] = target_function(arg, **dict(params, **target_dependencies))
File "/usr/local/lib/python3.7/dist-packages/albumentations/augmentations/transforms.py", line 898, in apply
return F.shift_hsv(image, hue_shift, sat_shift, val_shift)
File "/usr/local/lib/python3.7/dist-packages/albumentations/augmentations/functional.py", line 244, in shift_hsv
img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3>; VDepth = cv::impl::{anonymous}::Set<0, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::<unnamed>::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
[[{{node PyFunc}}]]
[[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_43969]
From what I can tell from ther error, it seems my images have a channel of one which is strange because they actually have 3 channels which is what I am passing to the model.