Error: (-215:Assertion failed) src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function 'cv::adaptiveThreshold'

img_array = cv2.imread('/metal/data/Columnar/Al1_1.jpg')
img = cv2.resize(img_array,(IMG_SIZE,IMG_SIZE))
img = np.asarray(img_array, dtype='float32')
bw = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
th3 = cv2.adaptiveThreshold(bw,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)

The said error is raised on the last line of code. Can someone please help me out? I am using opencv version 4.5.2.52

The whole error is:
error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\imgproc\src\thresh.cpp:1524: error: (-215:Assertion failed) src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function 'cv::adaptiveThreshold’

that’s an unfortunate expansion of the assertion.

it basically says it wants a single-channel CV_8U type matrix, and you gave it something else (float32, which is CV_32F)