I was working on Sequential model for plant disease detection problem.
Initially I used an image_list=[]
and converted images to array using img_to_array(image)
My next step was to use test_train_split
but before that I need to convert this list to array hence I used this:
im_list=np.array(image_list,dtype=np.float16)/255.0
But this line throws "ValueError: could not broadcast input array from shape (64,64,3) into shape (64,64)."
I understand it's an image list but generally it should convert a 3-D list to array as I tried with a sample list which it converted successfully. I don't get why this wouldn't work!!
::[UPDATE]::
PS: If the answers posted on the similar post doesn't help your issue. ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
and if you cannot modify the dimensions or implement .astype() as stated in that post!!. Try using the below function:
if len(img.shape)>2 and img.shape[2]==4:
img=cv2.cvtColor(img,cv2.COLOR_BGRA2BGR)
This generally happens when there's a 'PNG' image in the dataset.
Sample Trial:
li=np.random.rand(10,10,2)
lii=np.array(li,dtype=np.float16)
Variable Explorer: