未验证 提交 609db8ba 编写于 作者: G Guanghua Yu 提交者: GitHub

fix solov2 with_background & from_config (#2205)

上级 ed6b5e99
......@@ -9,7 +9,6 @@ SOLOv2:
mask_head: SOLOv2MaskHead
ResNet:
# index 0 stands for res2
depth: 50
norm_type: bn
freeze_at: 0
......@@ -17,11 +16,7 @@ ResNet:
num_stages: 4
FPN:
in_channels: [256, 512, 1024, 2048]
out_channel: 256
min_level: 0
max_level: 4
spatial_scale: [0.25, 0.125, 0.0625, 0.03125]
SOLOv2Head:
seg_feat_channels: 512
......@@ -32,7 +27,6 @@ SOLOv2Head:
mask_nms: MaskMatrixNMS
SOLOv2MaskHead:
in_channels: 256
mid_channels: 128
out_channels: 256
start_level: 0
......
......@@ -644,7 +644,7 @@ class Gt2Solov2TargetOp(BaseOperator):
max_ins_num = [0] * len(self.num_grids)
for sample in samples:
gt_bboxes_raw = sample['gt_bbox']
gt_labels_raw = sample['gt_class']
gt_labels_raw = sample['gt_class'] + 1
im_c, im_h, im_w = sample['image'].shape[:]
gt_masks_raw = sample['gt_segm'].astype(np.uint8)
mask_feat_size = [
......
......@@ -18,7 +18,7 @@ from __future__ import print_function
import paddle
from ppdet.core.workspace import register
from ppdet.core.workspace import register, create
from .meta_arch import BaseArch
__all__ = ['SOLOv2']
......@@ -37,7 +37,6 @@ class SOLOv2(BaseArch):
"""
__category__ = 'architecture'
__inject__ = ['backbone', 'neck', 'solov2_head', 'mask_head']
def __init__(self, backbone, solov2_head, mask_head, neck=None):
super(SOLOv2, self).__init__()
......@@ -46,11 +45,28 @@ class SOLOv2(BaseArch):
self.solov2_head = solov2_head
self.mask_head = mask_head
@classmethod
def from_config(cls, cfg, *args, **kwargs):
backbone = create(cfg['backbone'])
kwargs = {'input_shape': backbone.out_shape}
neck = create(cfg['neck'], **kwargs)
kwargs = {'input_shape': neck.out_shape}
solov2_head = create(cfg['solov2_head'], **kwargs)
mask_head = create(cfg['mask_head'], **kwargs)
return {
'backbone': backbone,
'neck': neck,
'solov2_head': solov2_head,
'mask_head': mask_head,
}
def model_arch(self):
body_feats = self.backbone(self.inputs)
if self.neck is not None:
body_feats, spatial_scale = self.neck(body_feats)
body_feats = self.neck(body_feats)
self.seg_pred = self.mask_head(body_feats)
......
......@@ -190,7 +190,7 @@ class SOLOv2Head(nn.Layer):
self.num_classes = num_classes
self.in_channels = in_channels
self.seg_num_grids = num_grids
self.cate_out_channels = self.num_classes - 1
self.cate_out_channels = self.num_classes
self.seg_feat_channels = seg_feat_channels
self.stacked_convs = stacked_convs
self.kernel_out_channels = kernel_out_channels
......
......@@ -87,7 +87,7 @@ def get_solov2_segm_res(results, image_id, num_id_to_cat_id_map):
return None
# for each sample
for i in range(lengths - 1):
clsid = int(clsid_labels[i]) + 1
clsid = int(clsid_labels[i])
catid = num_id_to_cat_id_map[clsid]
score = float(clsid_scores[i])
mask = segms[i]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册