import numpy as np
import matplotlib.pyplot as plt
import os
import cv2
DATADIR = "C:\\Users\\Timmi K. Rysgaard\\OneDrive\\Desktop\\Sculptures\\"
CATEGORIES = ["Beetle", "Nerd"]
for category in CATEGORIES:
path = os.path.join(DATADIR,category) # path to nerd or beetle
for img in os.listdir(path):
img_array = cv2.imread(os.path.join(path,img) , 0)
plt.imshow(img_array, cmap="gray")
plt.show()
break
break
I am receiving:
- TypeError: Image data of dtype object cannot be converted to float
Could I be trying to imread the folder, and if so, how do I fix it?
You probably have other files or directories in the same folder. You could try limiting the file types to be accepted using something like this: