I have a dataset class that gets images and ground truth rectangles that draws random images (indexes) in each batch. The thing is, in my case I need to draw the images by the same order in input lists. The following code is using  np.random.permutation in self.index for random draws. I’m not sure how should I change self.index (It appears in init and _next)?
It’s a numpy/data.Dataset question.
p.s - you can ignore all the ops.

self.index = np.random.permutation(len(self.img_list))

class RegionDataset(data.Dataset):
def __init__(self, img_list, gt, opts): # seq['image'], seq['gt']
    self.img_list = np.asarray(img_list)
    self.gt = gt

    self.batch_frames = opts['batch_frames'] # 8
    self.batch_pos = opts['batch_pos']
    self.batch_neg = opts['batch_neg']
    self.overlap_pos = opts['overlap_pos']
    self.overlap_neg = opts['overlap_neg']
    self.crop_size = opts['img_size']
    self.padding = opts['padding']
    self.flip = opts.get('flip', False)
    self.rotate = opts.get('rotate', 0)
    self.blur = opts.get('blur', 0)

    self.index = np.random.permutation(len(self.img_list))
    self.pointer = 0

    image = Image.open(self.img_list[0]).convert('RGB')
    self.pos_generator = SampleGenerator('uniform', image.size,
            opts['trans_pos'], opts['scale_pos'])
    self.neg_generator = SampleGenerator('uniform', image.size,
            opts['trans_neg'], opts['scale_neg'])
    
def __iter__(self):
    return self

def __next__(self):
    next_pointer = min(self.pointer + self.batch_frames, len(self.img_list))
    idx = self.index[self.pointer:next_pointer]
    
    if len(idx) < self.batch_frames:
        self.index = np.random.permutation(len(self.img_list))
        next_pointer = self.batch_frames - len(idx)
        idx = np.concatenate((idx, self.index[:next_pointer]))
    self.pointer = next_pointer
    (.....)