Forward function for training. Args: img (Tensor): Input images. img_metas (list[dict]): List of image info dict where each dict has: 'img_shape', 'scale_factor', 'flip', and may also contain 'filename', 'ori_shape', 'pad_shape', and '
(self, img, img_metas, gt_semantic_seg)
| 113 | return seg_logit |
| 114 | |
| 115 | def forward_train(self, img, img_metas, gt_semantic_seg): |
| 116 | """Forward function for training. |
| 117 | |
| 118 | Args: |
| 119 | img (Tensor): Input images. |
| 120 | img_metas (list[dict]): List of image info dict where each dict |
| 121 | has: 'img_shape', 'scale_factor', 'flip', and may also contain |
| 122 | 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. |
| 123 | For details on the values of these keys see |
| 124 | `mmseg/datasets/pipelines/formatting.py:Collect`. |
| 125 | gt_semantic_seg (Tensor): Semantic segmentation masks |
| 126 | used if the architecture supports semantic segmentation task. |
| 127 | |
| 128 | Returns: |
| 129 | dict[str, Tensor]: a dictionary of loss components |
| 130 | """ |
| 131 | |
| 132 | x = self.extract_feat(img) |
| 133 | |
| 134 | losses = dict() |
| 135 | |
| 136 | loss_decode = self._decode_head_forward_train(x, img_metas, gt_semantic_seg) |
| 137 | losses.update(loss_decode) |
| 138 | |
| 139 | if self.with_auxiliary_head: |
| 140 | loss_aux = self._auxiliary_head_forward_train(x, img_metas, gt_semantic_seg) |
| 141 | losses.update(loss_aux) |
| 142 | |
| 143 | return losses |
| 144 | |
| 145 | # TODO refactor |
| 146 | def slide_inference(self, img, img_meta, rescale): |
no test coverage detected