|
@@ -33,7 +33,6 @@ class UNet(DeepLabv3p):
|
|
|
自行计算相应的权重,每一类的权重为:每类的比例 * num_classes。class_weight取默认值None是,各类的权重1,
|
|
自行计算相应的权重,每一类的权重为:每类的比例 * num_classes。class_weight取默认值None是,各类的权重1,
|
|
|
即平时使用的交叉熵损失函数。
|
|
即平时使用的交叉熵损失函数。
|
|
|
ignore_index (int): label上忽略的值,label为ignore_index的像素不参与损失函数的计算。默认255。
|
|
ignore_index (int): label上忽略的值,label为ignore_index的像素不参与损失函数的计算。默认255。
|
|
|
- fixed_input_shape (list): 长度为2,维度为1的list,如:[640,720],用来固定模型输入:'image'的shape,默认为None。
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
Raises:
|
|
|
ValueError: use_bce_loss或use_dice_loss为真且num_calsses > 2。
|
|
ValueError: use_bce_loss或use_dice_loss为真且num_calsses > 2。
|
|
@@ -48,8 +47,7 @@ class UNet(DeepLabv3p):
|
|
|
use_bce_loss=False,
|
|
use_bce_loss=False,
|
|
|
use_dice_loss=False,
|
|
use_dice_loss=False,
|
|
|
class_weight=None,
|
|
class_weight=None,
|
|
|
- ignore_index=255,
|
|
|
|
|
- fixed_input_shape=None):
|
|
|
|
|
|
|
+ ignore_index=255):
|
|
|
self.init_params = locals()
|
|
self.init_params = locals()
|
|
|
super(DeepLabv3p, self).__init__('segmenter')
|
|
super(DeepLabv3p, self).__init__('segmenter')
|
|
|
# dice_loss或bce_loss只适用两类分割中
|
|
# dice_loss或bce_loss只适用两类分割中
|
|
@@ -79,7 +77,7 @@ class UNet(DeepLabv3p):
|
|
|
self.class_weight = class_weight
|
|
self.class_weight = class_weight
|
|
|
self.ignore_index = ignore_index
|
|
self.ignore_index = ignore_index
|
|
|
self.labels = None
|
|
self.labels = None
|
|
|
- self.fixed_input_shape = fixed_input_shape
|
|
|
|
|
|
|
+ self.fixed_input_shape = None
|
|
|
|
|
|
|
|
def build_net(self, mode='train'):
|
|
def build_net(self, mode='train'):
|
|
|
model = paddlex.cv.nets.segmentation.UNet(
|
|
model = paddlex.cv.nets.segmentation.UNet(
|
|
@@ -90,7 +88,7 @@ class UNet(DeepLabv3p):
|
|
|
use_dice_loss=self.use_dice_loss,
|
|
use_dice_loss=self.use_dice_loss,
|
|
|
class_weight=self.class_weight,
|
|
class_weight=self.class_weight,
|
|
|
ignore_index=self.ignore_index,
|
|
ignore_index=self.ignore_index,
|
|
|
- fixed_input_shape = self.fixed_input_shape)
|
|
|
|
|
|
|
+ fixed_input_shape=self.fixed_input_shape)
|
|
|
inputs = model.generate_inputs()
|
|
inputs = model.generate_inputs()
|
|
|
model_out = model.build_net(inputs)
|
|
model_out = model.build_net(inputs)
|
|
|
outputs = OrderedDict()
|
|
outputs = OrderedDict()
|