Inference with slide/whole style. Args: img (Tensor): The input image of shape (N, 3, H, W). img_meta (dict): Image info dict where each dict has: 'img_shape', 'scale_factor', 'flip', and may also contain 'filename', 'ori_shape', 'pad_
(self, img, img_meta, rescale)
| 83 | return seg_logit |
| 84 | |
| 85 | def inference(self, img, img_meta, rescale): |
| 86 | """Inference with slide/whole style. |
| 87 | |
| 88 | Args: |
| 89 | img (Tensor): The input image of shape (N, 3, H, W). |
| 90 | img_meta (dict): Image info dict where each dict has: 'img_shape', |
| 91 | 'scale_factor', 'flip', and may also contain |
| 92 | 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. |
| 93 | For details on the values of these keys see |
| 94 | `mmseg/datasets/pipelines/formatting.py:Collect`. |
| 95 | rescale (bool): Whether rescale back to original shape. |
| 96 | |
| 97 | Returns: |
| 98 | Tensor: The output segmentation map. |
| 99 | """ |
| 100 | |
| 101 | assert self.test_cfg.mode in ['slide', 'whole'] |
| 102 | ori_shape = img_meta[0]['ori_shape'] |
| 103 | assert all(_['ori_shape'] == ori_shape for _ in img_meta) |
| 104 | if self.test_cfg.mode == 'slide': |
| 105 | seg_logit = self.slide_inference(img, img_meta, rescale) |
| 106 | else: |
| 107 | seg_logit = self.whole_inference(img, img_meta, rescale) |
| 108 | output = F.softmax(seg_logit, dim=1) |
| 109 | flip = img_meta[0]['flip'] |
| 110 | if flip: |
| 111 | flip_direction = img_meta[0]['flip_direction'] |
| 112 | assert flip_direction in ['horizontal', 'vertical'] |
| 113 | if flip_direction == 'horizontal': |
| 114 | output = output.flip(dims=(3, )) |
| 115 | elif flip_direction == 'vertical': |
| 116 | output = output.flip(dims=(2, )) |
| 117 | |
| 118 | return output |
| 119 | |
| 120 | def inference_(self, imgs): |
| 121 | imgs_meta = dict( |
nothing calls this directly
no test coverage detected