π [Update] dataloader with pre-proccess
Browse files- yolo/utils/dataloader.py +8 -3
yolo/utils/dataloader.py
CHANGED
|
@@ -178,9 +178,14 @@ 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 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
|
| 186 |
def get_dataloader(config):
|
|
|
|
| 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, target_size = len(batch), [item[1].size(0) for item in batch]
|
| 182 |
+
batch_targets = torch.zeros(batch_size, max(target_size), 5)
|
| 183 |
+
images = []
|
| 184 |
+
for idx, (image, target) in enumerate(batch):
|
| 185 |
+
images.append(image)
|
| 186 |
+
batch_targets[idx, : target_size[idx]] = target
|
| 187 |
+
batch_images = torch.stack(images)
|
| 188 |
+
return batch_images, batch_targets
|
| 189 |
|
| 190 |
|
| 191 |
def get_dataloader(config):
|