Creating a custom Image dataloader

I am trying to create an image dataloader compatible with fastai. Here is what I am trying to do:
class CustomDataset(FilesDataset):
def init(self, fnames, y, transform, path):
self.y=y
assert(len(fnames)==len(y))
super().init(fnames, transform, path)
def get_y(self, i): return open_image(os.path.join(self.path, self.y[i]))
def get_c(self): return 0

I noticed that this in turn first calls FilesDataset in which it has function get_x.
The thing is my train_x has two values, first an image and then a single dim tensor. How can I modify this dataloader which returns both image and that tensor, as well as I can apply tfms to images.

2 Likes