TypeError: __array__() takes 1 positional argument but 2 were given (Image classification Keras)

Solution 1:

This error sometimes is due to a bug in Pillow 8.3.0 as it is here. (You may not use import PIL directly in your code, however some libraries such as tf.keras.preprocessing.image.load_img use PIL internally)

So, downgrading from PIL 8.3.0 to 8.2.0 may work.

Check PIL version:

import PIL
print(PIL.__version__)

If it is 8.3.0, then you may downgrade to 8.2.0:

!pip install pillow==8.2.0