in dataset/scene_batch_sampler.py [0:0]
def _sample_batch(self, batch_idx):
n_per_seq = np.random.choice(self.images_per_seq_options)
n_seqs = -(-self.batch_size // n_per_seq) # round up
chosen_seq = _capped_random_choice(self.seq_names, n_seqs, replace=False)
# extend the number of samples to batch size for single-seq data
# DN: turning this off as we should not assume users want to do this automatically
# n_per_seq = max(n_per_seq, self.batch_size // len(chosen_seq))
frame_idx = np.concatenate(
[
_capped_random_choice(
self.dataset.seq_to_idx[seq], n_per_seq, replace=False
)
for seq in chosen_seq
]
)[: self.batch_size].tolist()
if len(frame_idx) < self.batch_size:
warnings.warn(
"Batch size smaller than self.batch_size!"
+ " (This is fine for experiments with a single scene and viewpooling)"
)
return frame_idx