Obtaining the image name after doing random split

Hi everyone,

I was wondering if it is possible to obtain the original name or the full path of the image after using torch.utils.data.random_split(). Achieving this would allow to save train and test split images with their original names to local directories. Thanks.

random_split wraps the Dataset into Subsets as seen here. The used indices can be access via subset_dataset.indices and could be used to get the image paths.
It depends what kind of Dataset you are using, but e.g. ImageFolder should contains the paths in its dataset.samples attribute.

Thanks a lot @ptrblck for the reply.