I have multiple transformed images saved as .pt files. I would like to upload these files, and create a Dataset that stores these images as Tensors. How can I do this?
Where would you like to upload these files?
If you just would like to lazily load each transformed image stored as a .pt
file, you could write a custom Dataset
, pass the file paths in the __init__
method and load each file in __getitem__
.
Here is a small code sample:
class MyDataset(Dataset):
def __init__(self, file_paths):
self.file_paths = file_paths
def __getitem__(self, index):
x = torch.load(self.file_paths[index])
return x
def __len__(self):
return len(self.file_paths)