I have one dataset containing images X of type ( numpy array) and one target csv file as Y which has counts of cells (type : pandas dataframe, that I have converted to numpy array), both are now read as numpy arrays. Essentially, I am creating a training dataset to train my images with target dataset using cnn model.
For the code below i am getting an error that argument is bad.
Any help on how to solve this?
**image = cv2.imread(img_path)**
Full code:
def load_data():
import os
datasets = (X,Y)
images = []
labels = []
# iterate through training and test sets
count =0
for dataset in datasets:
# iterate through folders in each dataset
for folder in dataset:
if folder in ['plasma']: label = 'T4'
elif folder in ['lymphocyte']: label = 'T3'
elif folder in ['epithelial']: label = 'T2'
elif folder in ['neutrophil']: label = 'T1'
elif folder in ['eosinophil']: label = 'T5'
elif folder in ['connective']: label = 'T6'
img_path = np.append(dataset, folder)
**image = cv2.imread(img_path)**
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# resize the image
image = cv2.resize(image, image_size)
# Append the image and its corresponding label to the output
images.append(image)
labels.append(label)
images = np.array(images, dtype = 'float32')
labels = np.array(labels, dtype = 'int32')
return images, labels
Error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-145-a8d2a3fd920f> in <module>
----> 1 images, labels = load_data()
<ipython-input-144-1acddd84d1e7> in load_data()
24
25 img_path = np.append(dataset, folder)
---> 26 image = cv2.imread(img_path)
27 image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
28
TypeError: bad argument type for built-in operation