Let's say I have 3 images of shape (400, 400, 3) for each of them stored inside a list, and I want to store them in a tensor yielding a final shape of (3, 400, 400, 3), how could I achieve that ?
I've already tried doing my_imgs = [] for img in list_of_image: ..my_imgs.append(img) X = np.array(my_imgs)
which gives int() argument must be a string, a bytes-like object or a number
Store my images in a 4D numpy array
Let's say I have 3 images of shape (400, 400, 3) for each of them stored inside a list, and I want to store them in a tensor yielding a final shape of (3, 400, 400, 3), how could I achieve that ?
I've already tried doing
my_imgs = []
for img in list_of_image:
..my_imgs.append(img)
X = np.array(my_imgs)
which gives
int() argument must be a string, a bytes-like object or a number
Thank you.
you can use the numpy concatenate or stack functions: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html
np.asarray(my_imgs)
Add comment