First, you can set the __len__(self) to be the number of sequences you have, so in this case, 11. So instead of



 nivesh_gadipudi:

np.sum(self.seq_lens)


you can specify it as len(self.seq_lens). Sure, an epoch will be smaller, but you can train for more epochs.
Then, I assumed that you wanted to have a variable number of frames (but in serialized order) on each __getitem__(self, idx) call, so that’s what I specified as t1 and t2. At each call, you would get a sequence index and then randomly pick  t1 and t2 in that sequence. Then take all the frames between t1 and t1+t2.
If you want to fix the number of frames then you can simply take frames between t1 and t1+k. Then, t1 can be specified as:
t1 = random.sample(range(0, self.seq_lens[idx]-k), 1)
If you don’t want to take sequential (t1, t1+1,... t1+k) frames just replace 1 to k in t1 and remove t2.
Hope this clears it up.