Skip to content

The implementation of interpolatation in STDCHead isn't consistent with config setting. #1230

@jiehuang165

Description

@jiehuang165

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
When calculating losses in Moudle STDCHead, seg_logit needs to be resized back to the size of seg_label. It has a attribute align_corners to control whether align_corners=True or False in "configs/base/models/stdc.py" line 71:

dict(
type='STDCHead',
in_channels=256,
channels=64,
num_convs=1,
num_classes=2,
boundary_threshold=0.1,
in_index=0,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=[

But in code implementation, the align_corners is forced to True, ignoring the setting in configuration file, in line 87.

seg_logit = F.interpolate(
seg_logit,
boundary_targets.shape[2:],
mode='bilinear',
align_corners=True)
loss = super(STDCHead, self).losses(seg_logit,
boudary_targets_pyramid.long())

Bug fix
Actually STDCHead.losses calls BaseDecodeHead.losses(line 88-89), and BaseDecodeHead.losses will resize seg_logit to the same size of seg_label using configuration's setting align_corners(line 239).

loss = super(STDCHead, self).losses(seg_logit,
boudary_targets_pyramid.long())

def losses(self, seg_logit, seg_label):
"""Compute segmentation loss."""
loss = dict()
seg_logit = resize(
input=seg_logit,
size=seg_label.shape[2:],
mode='bilinear',
align_corners=self.align_corners)

Therefore, there is no need to do interpolate in STDCHead.losses again. Just deleting the code block line 83-87 in "mmseg/models/decode_heads/stdc_head.py" fixes the bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions