π [Add] dynamic bbox, prevent more cuda memory bug
Browse files
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)
|