deeplab自定义数据集的权重标准是什么?

What are the criteria for the weight of deeplab my custom dataset?

我正在训练 Deeplab v3 通过在三个 class 中制作自定义数据集,包括背景

然后,我的class是背景,熊猫,瓶子还有1949张图片

我正在使用 moblienetv2 模型

segmentation_dataset.py修改如下。

_MYDATA_INFORMATION = DatasetDescriptor(
        splits_to_sizes={
            'train': 975,  # num of samples in images/training
            'trainval': 1949,
            'val': 974,  # num of samples in images/validation
        },


        num_classes=3,
        ignore_label=0,
)

train.py修改如下

flags.DEFINE_boolean('initialize_last_layer', False,
                 'Initialize the last layer.')

flags.DEFINE_boolean('last_layers_contain_logits_only', True,
                 'Only consider logits as last layers or not.')

train_utils.py未修改

not_ignore_mask = tf.to_float(tf.not_equal(scaled_labels, ignore_label)) * loss_weight

我得到了一些结果,但不是最完美的。

例如熊猫和瓶子的面具颜色相同或不同

我要的结果是红熊猫绿瓶

所以,我判断是权重有问题

根据其他人的问题,train_utils.py配置如下

irgore_weight = 0
label0_weight =1
label1_weight = 10
label2_weight = 15
not_ignore_mask = 
    tf.to_float(tf.equal(scaled_labels, 0)) * label0_weight +
    tf.to_float(tf.equal(scaled_labels, 1)) * label1_weight +
    tf.to_float(tf.equal(scaled_labels, 2)) * label2_weight +
    tf.to_float(tf.equal(scaled_labels, ignore_label)) * irgore_weight 

tf.losses.softmax_cross_entropy(
    one_hot_labels,
    tf.reshape(logits, shape=[-1, num_classes]),
    weights=not_ignore_mask,
    scope=loss_scope)

我有一个问题。

体重的标准是什么?

我的数据集包含以下内容。

enter image description here

是自动生成的,所以不知道具体哪个多,但是差不多。

还有一件事,我正在使用 Pascal 的颜色映射类型。

这是第一黑底第二红第三绿

我想准确地将 pandas 指定为红色,将瓶子指定为绿色。我该怎么办?

我认为您可能混淆了标签定义。也许我可以帮你。请再次检查您的 segmentation_dataset.py。在这里,您将“0”定义为忽略的标签。这意味着所有标记为“0”的像素都被排除在训练过程之外(更具体地说,在损失函数的计算中被排除,因此对权重的更新没有影响)。鉴于这种情况,不要 "ignore" 背景 class 是至关重要的,因为它也是您想要正确预测的 class。在 train_utils.py 中,您为忽略的 class 分配了一个权重因子,这不会产生任何影响- --> 确保您没有混淆三个训练class带有 "ignored" 标签的 [背景、面饼、瓶子]。

在您的情况下,num_classes=3 应该是正确的,因为它指定了要预测的标签数量(模型自动假定这些标签为 0、1 和 2 . 如果你想忽略某些标签,你必须用第四个标签 class 注释它们(只需为此选择一个数字 >2),然后将此标签分配给 ignored_label。如果你没有要忽略的像素仍然设置 ignored_label=255 并且不会影响您的训练;)