| 204 | 'valid_mask': valid_mask} |
| 205 | |
| 206 | def symmetricImagePad(self, image_batch, padding_factor): |
| 207 | b, c, h, w = image_batch.size() |
| 208 | pad_h, pad_w = int(h * padding_factor), int(w * padding_factor) |
| 209 | idx_pad_left = torch.LongTensor(range(pad_w - 1, -1, -1)) |
| 210 | idx_pad_right = torch.LongTensor(range(w - 1, w - pad_w - 1, -1)) |
| 211 | idx_pad_top = torch.LongTensor(range(pad_h - 1, -1, -1)) |
| 212 | idx_pad_bottom = torch.LongTensor(range(h - 1, h - pad_h - 1, -1)) |
| 213 | if self.use_cuda: |
| 214 | idx_pad_left = idx_pad_left.cuda() |
| 215 | idx_pad_right = idx_pad_right.cuda() |
| 216 | idx_pad_top = idx_pad_top.cuda() |
| 217 | idx_pad_bottom = idx_pad_bottom.cuda() |
| 218 | image_batch = torch.cat((image_batch.index_select(3, idx_pad_left), image_batch, |
| 219 | image_batch.index_select(3, idx_pad_right)), 3) |
| 220 | image_batch = torch.cat((image_batch.index_select(2, idx_pad_top), image_batch, |
| 221 | image_batch.index_select(2, idx_pad_bottom)), 2) |
| 222 | return image_batch |
| 223 | |
| 224 | def expandImagePad(self, image_batch, padding_factor): |
| 225 | b, c, h, w = image_batch.size() |