gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\imgproc\src\color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' code example
Example: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
This error happened because the image didn't load properly.
So you have problem with the previous line cv2.imread my suggestion is :
check if the images exist in the path you give
check the count variable if he have valid number