I think the transformation to L mode will destroy your data.
If you don’t really need to transform your numpy array to a PIL.Image, you could directly use:
x = torch.from_numpy(img_as_np)

Otherwise, use the F mode for your transformation:
img_as_img = Image.fromarray(img_as_np, 'F')

and remove the transformation to L.