I have incorporated both the changes you suggest. I have changed the label to 0,1,2 and I am currently running it on cpu, but now I am getting another error which I am not able to understand.
/opt/conda/lib/python3.7/site-packages/PIL/Image.py:961: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images
  "Palette images with Transparency expressed in bytes should be "

Could you please help.