Esempio n. 1
0
 def forward(self, x):
     if self.nhwc:
         x = nchw_to_nhwc_transform(x)
     x = F.relu(self.conv5_mask(x))
     if self.nhwc:
         x = nhwc_to_nchw_transform(x)
     return self.mask_fcn_logits(x)
    def forward(self, x, proposals):
##        if self.nhwc:
##            x = nchw_to_nhwc_transform(x)
        x = self.pooler(x, proposals)
        x = self.head(x)
        if self.nhwc:
            x = nhwc_to_nchw_transform(x)
        return x
 def forward(self, x, proposals):
     x = self.pooler(x, proposals)
     ## TODO: we can get rid of this transpose by changing box head loss computation accordingly
     if self.nhwc:
         x = nhwc_to_nchw_transform(x)
     x = x.view(x.size(0), -1)
     x = F.relu(self.fc6(x))
     x = F.relu(self.fc7(x))
     return x
 def forward(self, x, proposals):
     x = self.pooler(x, proposals)
     if self.nhwc:
         x = nchw_to_nhwc_transform(x)
     for layer_name in self.blocks:
         x = F.relu(getattr(self, layer_name)(x))
     if self.nhwc:
         x = nhwc_to_nchw_transform(x)
     return x
 def forward(self, x):
     #TODO: this transpose may be needed for modularity of Detectron repo
     #        if self.nhwc:
     #            x = nchw_to_nhwc_transform(x)
     x = F.relu(self.conv5_mask(x))
     logits = self.mask_fcn_logits(x)
     if self.nhwc:
         logits = nhwc_to_nchw_transform(logits)
     return logits
 def forward(self, x):
     outputs = []
     if self.nhwc:
         x = nchw_to_nhwc_transform(x)
     x = self.stem(x)
     for stage_name in self.stages:
         x = getattr(self, stage_name)(x)
         if self.return_features[stage_name]:
             outputs.append(x)
     if self.nhwc and not self.has_fpn:
         for i, t in enumerate(outputs):
             outputs[i] = nhwc_to_nchw_transform(t)
     return outputs
 def forward(self, x):
     """
     Arguments:
         x (list[Tensor]): feature maps for each feature level.
     Returns:
         results (tuple[Tensor]): feature maps after FPN layers.
             They are ordered from highest resolution first.
     """
     last_inner = getattr(self, self.inner_blocks[-1])(x[-1])
     results = []
     results.append(getattr(self, self.layer_blocks[-1])(last_inner))
     for feature, inner_block, layer_block in zip(
             x[:-1][::-1], self.inner_blocks[:-1][::-1],
             self.layer_blocks[:-1][::-1]):
         if not inner_block:
             continue
         if self.nhwc:
             last_inner = nhwc_to_nchw_transform(last_inner)
         inner_top_down = F.interpolate(last_inner,
                                        scale_factor=2,
                                        mode="nearest")
         if self.nhwc:
             inner_top_down = nchw_to_nhwc_transform(inner_top_down)
         inner_lateral = getattr(self, inner_block)(feature)
         # TODO use size instead of scale to make it robust to different sizes
         # inner_top_down = F.upsample(last_inner, size=inner_lateral.shape[-2:],
         # mode='bilinear', align_corners=False)
         last_inner = inner_lateral + inner_top_down
         results.insert(0, getattr(self, layer_block)(last_inner))
     if isinstance(self.top_blocks, LastLevelP6P7):
         last_results = self.top_blocks(x[-1], results[-1])
         results.extend(last_results)
     elif isinstance(self.top_blocks, LastLevelMaxPool):
         last_results = self.top_blocks(results[-1], self.nhwc)
         results.extend(last_results)
     if self.nhwc:
         for i, f in enumerate(results):
             results[i] = nhwc_to_nchw_transform(f)
     return tuple(results)