I tried using different modes given in the docs but cannot able to resolve the problem. The mode for the image is ‘P’. And after using transform my image has shape  ([1,128,128]), so basically the problem occurs  in transform as transform converted it from RGB to Binary