MCPcopy Create free account
hub / github.com/devinxzhang/MFuser / forward_train

Method forward_train

mmseg/models/segmentors/encoder_decoder.py:139–176  ·  view source on GitHub ↗

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,
                      seg_weight=None,
                      return_feat=False)

Source from the content-addressed store, hash-verified

137 return seg_logit
138
139 def forward_train(self,
140 img,
141 img_metas,
142 gt_semantic_seg,
143 seg_weight=None,
144 return_feat=False):
145 """Forward function for training.
146
147 Args:
148 img (Tensor): Input images.
149 img_metas (list[dict]): List of image info dict where each dict
150 has: 'img_shape', 'scale_factor', 'flip', and may also contain
151 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
152 For details on the values of these keys see
153 `mmseg/datasets/pipelines/formatting.py:Collect`.
154 gt_semantic_seg (Tensor): Semantic segmentation masks
155 used if the architecture supports semantic segmentation task.
156
157 Returns:
158 dict[str, Tensor]: a dictionary of loss components
159 """
160 x = self.extract_feat(img)
161
162 losses = dict()
163 if return_feat:
164 losses['features'] = x
165
166 loss_decode = self._decode_head_forward_train(x, img_metas,
167 gt_semantic_seg,
168 seg_weight)
169 losses.update(loss_decode)
170
171 if self.with_auxiliary_head:
172 loss_aux = self._auxiliary_head_forward_train(
173 x, img_metas, gt_semantic_seg, seg_weight)
174 losses.update(loss_aux)
175
176 return losses
177
178 # TODO refactor
179 def slide_inference(self, img, img_meta, rescale):

Callers 2

Calls 4

extract_featMethod · 0.95
updateMethod · 0.80

Tested by

no test coverage detected