Please look at the following example:
import numpy as np
from torchvision import transforms

X = np.random.randint(low=0, high=255, size=(32,32,3), dtype=np.unit8)  # an image in ndarray format
your_transforms = transforms.Compose([transforms.CenterCrop(10),transforms.ToTensor(),])  # a set of transformations
if isinstance(X, np.ndarray):
    your_transforms.transforms.insert(0, transforms.ToPILImage())

Now given what you found on the other page, we can do this:
from torchvision.datasets import VisionDataset

class BasicVisionDataset(VisionDataset):
    def __init__(self, images, targets, transform=None, target_transform=None):
        if isinstance(images, np.ndarray):
            transform.transforms.insert(0, transforms.ToPILImage())
        super(BasicVisionDataset, self).__init__(root=None, transform=transform, target_transform=target_transform)
        assert len(images) == len(targets)

        self.images = images
        self.targets = targets

    def __getitem__(self, index):
        return self.transform(self.images[index]), self.targets[index]

    def __len__(self):
        return len(self.targets)

Please let me know if this works.