From b2a9d38228925148efbeec656bf1a27e22466117 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Wed, 11 Dec 2019 22:09:44 +0800 Subject: [PATCH] update model_builder.py --- pdseg/models/model_builder.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pdseg/models/model_builder.py b/pdseg/models/model_builder.py index 81886cc3..9e209b0e 100644 --- a/pdseg/models/model_builder.py +++ b/pdseg/models/model_builder.py @@ -166,7 +166,7 @@ def build_model(main_prog, start_prog, phase=ModelPhase.TRAIN): if cfg.AUG.AUG_METHOD == 'rangescaling': size = cfg.AUG.INF_RESIZE_VALUE value = fluid.layers.reduce_max(origin_shape) - scale = size / value + scale = float(size) / value.astype('float32') image = fluid.layers.resize_bilinear( image, scale=scale, align_corners=False, align_mode=0) @@ -191,6 +191,9 @@ def build_model(main_prog, start_prog, phase=ModelPhase.TRAIN): std = np.array(cfg.STD).reshape(1, len(cfg.STD), 1, 1) std = fluid.layers.assign(std.astype('float32')) image = (image / 255 - mean) / std + # 很有必要,使后面的网络能通过image.shape获取特征图的shape + image = fluid.layers.reshape( + image, shape=[-1, cfg.DATASET.DATA_DIM, height, width]) else: image = fluid.layers.data( @@ -229,7 +232,6 @@ def build_model(main_prog, start_prog, phase=ModelPhase.TRAIN): raise Exception( "softmax loss can not combine with dice loss or bce loss" ) - logits = model_func(image, class_num) # 根据选择的loss函数计算相应的损失函数 -- GitLab