henry000 commited on
Commit
96a806a
Β·
1 Parent(s): d252042

πŸš€ [Update] dataloader with pre-proccess

Browse files
Files changed (1) hide show
  1. 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
- images = torch.stack([item[0] for item in batch])
182
- targets = [item[1] for item in batch]
183
- return images, targets
 
 
 
 
 
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):