This would enlarge the accepted set of inputs of torch.as_tensor and would support PIL images / h5py arrays. I think this feature request goes well in the theme of standardizing support for methods like __array_interface__, __cuda_array_interface__ and such. It would be good for torch.as_tensor to support accepting __array_interface__ dicts directly. It may sometimes be conventient to store / manipulate these dictionaries directly, and then pass them to torch.as_tensor. Currently it produces Could not infer dtype of dict - which is also an unclear error message by the way.
Currently, torch.as_tensor(pil_image) fails with RuntimeError: Could not infer dtype of Image, while it can be converted with np.asarray.
As side-effect, this would also eliminate the need for torchvision's F.to_tensor(pil_image)
Related: #54138
cc @mruberry @rgommers @heitorschueroff