Based on the error message it seems you might be passing the path or image name as image, while an already loaded PIL.Image is expected.
If that’s the case, try to load the image before passing it to the transformation via im = PIL.Image.open(image_path).