When you do
[np.asarray(Image.open(os.path.join(dirname, fn))) for fn in os.listdir(dirname)]
It would return an array, which is stored in local variable X
You are trying to extract variables from a list, and hence the error.
The individual elements within X
have the shape attributes. Hence, you need to do something like this (modify it according to the datastructure shape
is defined as )
dim0 = X[0].shape
and so on