pythonlessons/mltu

cv2 error

Opened this issue · 1 comments

this is the error i am getting while running the train.py script can you help me where exactly i am going wrong
Traceback (most recent call last):
File "E:\ML\ml_projects\project_folder\icpr\img_to_word\train.py", line 129, in
model.fit(
File "E:\ML\envs\python3\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "E:\ML\envs\python3\lib\site-packages\mltu\dataProvider.py", line 142, in getitem
data, annotation = preprocessor(data, annotation)
File "E:\ML\envs\python3\lib\site-packages\mltu\preprocessors.py", line 9, in call
return cv2.imread(image_path, self._method), label
cv2.error: OpenCV(4.10.0) 👎 error: (-5:Bad argument) in function 'imread'

Overload resolution failed:

  • Argument 'flags' is required to be an integer
  • dst is not a numpy array, neither a scalar
  • Expected Ptrcv::UMat for argument 'dst'

The error speaks for it self:

Specific Error Message

  • OpenCV Error: cv2.error: OpenCV(4.10.0) error: (-5:Bad argument) in function 'imread'
    • Bad Argument: This indicates that the argument passed to cv2.imread is not valid.

Common Causes

  • Invalid File Path: The image_path passed to cv2.imread might be incorrect or the file does not exist. cv2.imread returns None if the image path is invalid.
  • Incorrect Data Type: The image_path should be a string representing the path to the image file.
  • File Access Issues: There might be permission issues preventing the file from being read.
  • Unsupported File Format: The image format might not be supported by OpenCV.

So, check if what file you try to read with openCV and try to investigate this specific file