Some of us might have worked on KITTI vision benchmarks.
Dataset Description:
22 Sequences, Of which 11 are provided with ground truth labeling
number of frames in 11 sequences = [4541, 1101, 4661, 801, 271, 2761, 1101, 1101, 4071, 1591, 1201]
Let my dataloader be:
class KITTIData(Dataset):
    def __init__(self, basedir, sequences):
        self.basedir    = basedir
        self.sequences  = sequences
        self.seq_lens   = []
        self.cumulative = []
      
        for i in self.sequences:
            curdirlen = os.listdir(os.path.join(self.basedir, "sequences", i, "image_2"))
            self.seq_lens.append(len(curdirlen)-1)
        
        temp = 0
        for i in self.seq_lens:
            temp = temp + i
            self.cumulative.append(temp)
        
    def __len__(self):
        return np.sum(self.seq_lens)

    def __getitem__(self, index):
        seq_key   = liefunctions.BinarySearch(self.cumulative, index)
        seq_index = self.sequences[seq_key]

        if seq_key == 0:
            offset = index
        else:
            offset = index - self.cumulative[seq_key-1]
        
        t1   = offset
        t2   = offset + 1
        img1 = Image.open(os.path.join(self.basedir, "sequences", seq_index, "image_2", "%06d" % t1 + ".png")).convert('RGB')
        #img1 = ImageOps.grayscale(img1)
        img2 = Image.open(os.path.join(self.basedir, "sequences", seq_index, "image_2", "%06d" % t2 + ".png")).convert('RGB')
        #img2 = ImageOps.grayscale(img2)

        img1 = self.transform(img1)
        img2 = self.transform(img2)

        img = torch.cat((img1, img2), 0)  

        return img


How can i modify this to generate randomly cropped sequences for example, (10 to 20), (45 to 60) …(1053 to 1080) frames from each sequence ?

Any similar example for this where small chunks of randomly cropped sequences are added in the dataloader would help me a lot.
Thank you for your effort in advance!!