⚡️ [Update] Dataloader, run faster!
Browse files- yolo/utils/dataloader.py +9 -7
yolo/utils/dataloader.py
CHANGED
|
@@ -178,13 +178,15 @@ class YoloDataLoader(DataLoader):
|
|
| 178 |
- A tensor of batched images.
|
| 179 |
- A list of tensors, each corresponding to bboxes for each image in the batch.
|
| 180 |
"""
|
| 181 |
-
batch_size
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
batch_targets[idx, :
|
| 187 |
-
|
|
|
|
|
|
|
| 188 |
return batch_images, batch_targets
|
| 189 |
|
| 190 |
|
|
|
|
| 178 |
- A tensor of batched images.
|
| 179 |
- A list of tensors, each corresponding to bboxes for each image in the batch.
|
| 180 |
"""
|
| 181 |
+
batch_size = len(batch)
|
| 182 |
+
target_sizes = [item[1].size(0) for item in batch]
|
| 183 |
+
# TODO: Improve readability of these proccess
|
| 184 |
+
batch_targets = torch.zeros(batch_size, max(target_sizes), 5)
|
| 185 |
+
for idx, target_size in enumerate(target_sizes):
|
| 186 |
+
batch_targets[idx, :target_size] = batch[idx][1]
|
| 187 |
+
|
| 188 |
+
batch_images = torch.stack([item[0] for item in batch])
|
| 189 |
+
|
| 190 |
return batch_images, batch_targets
|
| 191 |
|
| 192 |
|