Use img.shape
It provides you the shape of img in all directions. ie number of rows, number of columns for a 2D array (grayscale image). For 3D array, it gives you number of channels also.
So if len(img.shape)
gives you two, it has a single channel.
If len(img.shape)
gives you three, third element gives you number of channels.
For more details, visit here