This should be working as i have seen it work on anothers however this is not working for me. I am doing a test/train model and trying to train the image
This is all that i have tried. Data saved on google drive
train_image = []
for i in tqdm(range(train.shape[0])):
img = image.load_img('/content/drive/My Drive/Colab Notebooks/data/train/'+train['file_id'][i], target_size=(128,173,1), color_mode='grayscale')
img = image.img_to_array(img)
img = img/255
train_image.append(img)
x_train = np.array(train_image)
0%| | 0/5377 [00:00<?, ?it/s]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-ef9f3fb90a16> in <module>()
1 train_image = []
2 for i in tqdm(range(train.shape[0])):
----> 3 img = image.load_img('/content/drive/My Drive/Colab Notebooks/data/train/'+train['file_id'][i], target_size=(128,173,1), color_mode='grayscale')
4 img = image.img_to_array(img)
5 img = img/255
TypeError: must be str, not numpy.int64
Check whether the parameters passed in load_img and img_to_array is correct or not. I had the same error with my code. It was because I was calling a method to get a particular parameter for creating the path which returned a character (typing error) and affected it.