I’m trying to define a Dataset
/Dataloader
for an image style transfer network. I have a dataset of images grouped by styles, and I want each sample from this dataset to consist of two images, one for style, the other for content. My first idea was to implement a Dataset
with something like this in __init__
:
n = len(images)
itr_style = random.shuffle([i for i in range(n)]))
itr_content = random.shuffle([i for i in range(n)]))
and this in __getitem__
:
return (images[itr_style[index]], images[itr_content[index]])
Which is probably not the most efficient implementation, and I also need to make sure that:
- The two images don’t come from the same style
- The dataset re-shuffles every epoch
What is the best way to implement this Dataset
?