Skip to content

Commit

Permalink
[Fix]: fix bug related to Pixeldata (#8450)
Browse files Browse the repository at this point in the history
  • Loading branch information
chhluo authored and ZwwWayne committed Aug 17, 2022
1 parent 035b915 commit 9a7db95
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mmdet/models/data_preprocessors/data_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmengine.data import PixelData
from mmengine.dist import barrier, broadcast, get_dist_info
from mmengine.logging import MessageHub
from mmengine.model import BaseDataPreprocessor, ImgDataPreprocessor
Expand Down Expand Up @@ -163,11 +164,12 @@ def pad_gt_sem_seg(self,
gt_sem_seg = data_samples.gt_sem_seg.sem_seg
h, w = gt_sem_seg.shape[-2:]
pad_h, pad_w = data_samples.batch_input_shape
data_samples.gt_sem_seg.sem_seg = F.pad(
gt_sem_seg = F.pad(
gt_sem_seg,
pad=(0, max(pad_w - w, 0), 0, max(pad_h - h, 0)),
mode='constant',
value=self.seg_pad_value)
data_samples.gt_sem_seg = PixelData(sem_seg=gt_sem_seg)


@MODELS.register_module()
Expand Down Expand Up @@ -327,11 +329,12 @@ def forward(
for data_samples in batch_data_samples:
gt_sem_seg = data_samples.gt_sem_seg.sem_seg
h, w = gt_sem_seg.shape[-2:]
data_samples.gt_sem_seg.sem_seg = F.pad(
gt_sem_seg = F.pad(
gt_sem_seg,
pad=(0, max(0, dst_w - w), 0, max(0, dst_h - h)),
mode='constant',
value=self.seg_pad_value)
data_samples.gt_sem_seg = PixelData(sem_seg=gt_sem_seg)

return batch_inputs, batch_data_samples

Expand Down

0 comments on commit 9a7db95

Please sign in to comment.