henry000 commited on
Commit
1528a4f
Β·
1 Parent(s): 88e45b9

πŸ› [Add] dynamic bbox, prevent more cuda memory bug

Browse files
Files changed (1) hide show
  1. yolo/tools/data_loader.py +2 -2
yolo/tools/data_loader.py CHANGED
@@ -189,10 +189,10 @@ class YoloDataLoader(DataLoader):
189
  batch_size = len(batch)
190
  target_sizes = [item[1].size(0) for item in batch]
191
  # TODO: Improve readability of these proccess
192
- batch_targets = torch.zeros(batch_size, max(target_sizes), 5)
193
  batch_targets[:, :, 0] = -1
194
  for idx, target_size in enumerate(target_sizes):
195
- batch_targets[idx, :target_size] = batch[idx][1]
196
  batch_targets[:, :, 1:] *= self.image_size
197
 
198
  batch_images, _, batch_reverse, batch_path = zip(*batch)
 
189
  batch_size = len(batch)
190
  target_sizes = [item[1].size(0) for item in batch]
191
  # TODO: Improve readability of these proccess
192
+ batch_targets = torch.zeros(batch_size, min(max(target_sizes), 100), 5)
193
  batch_targets[:, :, 0] = -1
194
  for idx, target_size in enumerate(target_sizes):
195
+ batch_targets[idx, : min(target_size, 100)] = batch[idx][1][:100]
196
  batch_targets[:, :, 1:] *= self.image_size
197
 
198
  batch_images, _, batch_reverse, batch_path = zip(*batch)