【EmbedMask】《EmbedMask:Embedding Coupling for One-stage Instance Segmentation》

在这里插入图片描述
在这里插入图片描述
arXiv-2019
code:https://github.com/yinghdb/EmbedMask
在 FCOS 基础上的改进



1 Background and Motivation

随着深度学习的蓬勃发展,CNN 在计算机视觉中的应用已经从 image-level 扩展到 pixel-level。eg,实例分割就是对目标检测的一种扩展,detected objects from instance-level to pixel-level.

当前基于 CNN 做实例分割的方法可以分为两类

  • Proposal-based methods:先用目标检测方法检测目标框,再在框内区域进行 pix-level 的分类。代表性的方法有 Mask R-CNN (参考【Mask RCNN】《Mask R-CNN》) , one-stage 普遍没有 two-stage 的目标检测方法的方法猛,two-stage 中 RoI pooling 操作又会存在如下两个缺点
    • results in the loss of features and the distortion to the aspect ratios
    • complex to adjust too many parameters
  • segmentation based methods: segment first then do clustering,这类方法都没有 re-pooling 操作(RoI pooling),难点在 cluster 的过程中,很难去 determine the number of clusters or the positions of the cluster centers

作者融合两类分割方法的优点(It preserves strong detection capabilities as the proposal-based methods, and meanwhile keeps the details of images as the segmentation-based methods),提出了 EmbedMask 实例分割方法,用 embedding 的方式来 simplifies the clustering procedure in the segmentation-based methods and avoid the repooling procedure in Mask R-CNN

2 Related Work

  • Proposal-based methods:detection and segmentation
    • Two-stage Methods,eg Mask RCNN
    • One-stage Methods,eg YOLACT、TensorMask
  • Segmentation-based Methods(bottom-up methods):first segmenting and then clustering(eg 让属于同一实例的像素在 embedding 空间中尽量靠在一起)

3 Advantages / Contributions

  • propose a framework that unites the proposal-based and segmentation-based methods,通过 pixel-embedding 和 proposal embedding
  • one-stage 实例分割方法,但是 higher quality(挑了些图) and higher speed than two-stage 的 Mask RCNN(但 AP 没别人高哟)

4 Method

pixel embeddings, proposal embeddings, and proposal margins to extract the instance masks

在这里插入图片描述
d = 32 d=32 d=32

location x j x_j xj p r o p o s a l j proposal_j proposalj 的所有参数为 { c l a s s j , b o x j , c e n t e r j , q j , σ j } \{class_j, box_j,center_j, q_j,\sigma_j\} {classj,boxj,centerj,qj,σj}

其中 q j q_j qj 是 proposal embedding,which is regarded as the cluster center

σ j \sigma_j σj 是 proposal margin

pixel embedding 和 proposal embedding 的相似度来生成每个候选区域中的 mask,proposal margin δ \delta δ 相当于一个相似度的阈值,来决定最终的 mask

4.1 Embedding Definition

在这里插入图片描述
作者提出了下面两种新的 embedding 方式

  • proposal embedding, which is a good representation of entire instance

  • pixel embedding, which learns the relation between each pixel with corresponding instance

在 embedding 空间中,proposal embedding 相当于聚类中心,然后同一个 instance 的 pixel embedding 会在这个聚类中心附近

相比于其他方法,作者的这种 embedding 方式就避免了找 cluster center 的位置和数量的问题了


常规的思路是

在这里插入图片描述

  • p i p_i pi 是 pixel embeddings
  • q i q_i qi 是 proposal embedding
  • δ \delta δ 是 proposal margin
  • Q k Q_k Qk 是 instance proposal S k S_k Sk(GT mask) 内,正样本区域 q i q_i qi 的平均值,也即聚类中心

训练的时候 S k S_k Sk 是 GT mask, Q k Q_k Qk 是所有 positive proposal embedding 的平均值,优化目标是让同一 instance 的 pixel embedding 与 proposal embedding 尽可能的近(pull),与背景像素尽可能的远(push)

在公式(1)的基础上,采用 hinge loss,就可以训练了

在这里插入图片描述

  • K K K: GT instance 的数量
  • B k B_k Bk:represents the set of pixel embeddings that need to be supervised for the instance S k S_k Sk,GT mask 对应的 bbox 的区域
  • N k N_k Nk:the number of pixel embeddings in B k B_k Bk
  • I ( i ∈ S k ) \mathbb{I}(i \in S_k) I(iSk) indicator function
  • S k S_k Sk:GT instance 的 mask
  • Q k Q _k Qk 是所有 positive proposal embedding 的平均值,positive 区域是预测的 bbox 与 S k S_k Sk 对应的 bbox IoU 大于 0.5 的区域内
  • [ x ] + [x]_+ [x]+:表示 max(0,x)
  • δ a \delta_a δa δ b \delta_b δb 是 two margins designed for push and pull strategy

第一项是 pull 到 margin δ a \delta_a δa 内,第二项是 push 到 margin δ b \delta_b δb

画个图这个关系就很明了,横坐标是 p-q,纵坐标分别是两项 loss

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-2,5,100)
y1 = np.array([max(0,(i-1))**2 for i in x])
y2 = np.array([max(0,(1-j))**2 for j in x])

plt.plot(x,y1)
plt.plot(x,y2)
plt.legend(['y1','y2'],loc="upper center")

# gca = get current axis
ax = plt.gca() # x,y

# spines = 上下左右四条黑线
ax.spines['right'].set_color('none') # 让右边的黑线消失
ax.spines['top'].set_color('none')  # 让上边的黑线消失

ax.xaxis.set_ticks_position('bottom') # 把下面的黑线设置为x轴
ax.yaxis.set_ticks_position('left')   #  把左边的黑线设置为y轴

ax.spines['bottom'].set_position(('data',0)) # 移动x轴到指定位置,本例子为0
ax.spines['left'].set_position(('data',0))   # 移动y轴到指定位置,本例子为0

plt.show()

在这里插入图片描述
第一项 x 超过了设定的阈值,损失就会越来越大,第二项 x 小于阈值,损失就会越来越大

作者发现设定固定的 margin (difficult to find the optimal values),

在这里插入图片描述

因此采用 learning 的方式,来学习一个 margin

3.2 Learnable Margin

采用高斯公式来判断像素是否属于实例,取代 3.1 小节的公式 (1)

在这里插入图片描述

map the distance between the pixel embedding p i p_i pi of the pixel x i x_i xi and the proposal embedding Q k Q_k Qk of the instance S k S_k Sk into a value ranged in [0, 1)

  • Σ k \Sigma_k Σk 就是 positive 区域的 σ j \sigma_j σj 的均值,类比 q j q_j qj Q k Q_k Qk 的关系,positive 是预测的 bbox 与 S k S_k Sk 对应的 bbox IoU 大于 0.5 的区域内
  • ϕ ( x i , S k ) \phi(x_i,S_k) ϕ(xi,Sk) 表示像素 x i x_i xi 属于 GT mask S k S_k Sk 的概率

整体的 loss 就没有用公式(3)中的 hinge loss 了, 而采用了如下形式

在这里插入图片描述

  • L ( ⋅ ) L(·) L() 是 binary classification loss function
  • ϕ ( x i , S k ) \phi(x_i,S_k) ϕ(xi,Sk) 表示像素 x i x_i xi 属于 GT mask S k S_k Sk 的概率
  • G ( x i , S k ) \mathbb{G}(x_i,S_k) G(xi,Sk) represents the ground truth label for pixel x i x_i xi to judge whether it is in the mask of the proposal S k S_k Sk, which is a binary value

相当于需要网络学 Σ \Sigma Σ,而不是用固定的 σ \sigma σ,实际中学习的是 1 2 σ 2 \frac{1}{2\sigma^2} 2σ21(会用指数函数保证预测出来的都是正值)

3.3 Smooth Loss

Q k Q_k Qk Σ k \Sigma_k Σk 的计算方式如下

在这里插入图片描述
在这里插入图片描述

  • M k M_k Mk 是正样本像素的集合——当前像素预测出的 bbox 与 GT bbox 的 IoU > 0.5

注意,训练的时候 S k S_k Sk 是 GT,会被用到如下两个地方

  • 来算 Q k Q_k Qk Σ k \Sigma_k Σk 的正样本区域时候(在 GT mask 区域内选 IoU > 0.5 的位置)
  • 算二值损失公式(4)时

测试的时候,我们是不知道 S k S_k Sk 的,无法计算 Q k Q_k Qk Σ k \Sigma_k Σk,所以作者在测试的时候把公式(3)中的 Q k Q_k Qk Σ k \Sigma_k Σk 替换为了当前位置的 q j q_j qj σ j \sigma_j σj

这样,训练和测试的 Q k Q_k Qk Σ k \Sigma_k Σk 就不一样(训练的时候是区域 embedding 的平均值,测试的时候是当前位置的 embedding),作者用如下损失来缓解这种情况

在这里插入图片描述

让每个位置的 embedding 尽量和他们的聚类中心差距较小

3.4 Training

计算 loss 的时候,feature map 和 embedding 都 resize 到原图长宽的 1/4
在这里插入图片描述

其中

在这里插入图片描述
在这里插入图片描述

λ 1 = 0.5 \lambda_1 = 0.5 λ1=0.5 λ 1 = 0.1 \lambda_1 = 0.1 λ1=0.1

1)Training Samples for Box and Classification

FCOS

{ b o x j , c l a s s j , c e n t e r j } \{box_j, class_j, center_j\} {boxj,classj,centerj},正样本被定义为,locate on the center region of the ground-truth bounding box,且在 GT mask 区域内

2)Training Samples for Proposal Embedding and Margin

正样本被定义为,当前像素预测出的 bbox 与 GT bbox 的 IoU > 0.5(且在 GT mask 内)

3)Training Samples for Pixel Embedding

正样本被定义为,落在 GT bbox 中的 pixel,实验中发现, expand bbox,增加 training sample(负样本)效果会更好

3.5 Inference

根据 NMS 后的 bbox(默认都是正样本了),用当前位置的 q j q_j qj σ j \sigma_j σj 代替 Q Q Q Σ \Sigma Σ,然后代入下面公式 计算 x i x_i xi 属于 S k S_k Sk 的概率

在这里插入图片描述

5 Experiments

5.1 Datasets

  • MS COCO
    • trainval35k split (115K images) for training,
    • minival split (5K images) for ablation study
    • test-dev (20K images) for reporting the main results

5.2 Main Results

1)Quantitative Results

在这里插入图片描述
一阶段中最好

2)Qualitative Results
在这里插入图片描述 在这里插入图片描述
左图 mask rcnn,右图 embedmask,can provide more detailed masks than Mask R-CNN with sharper edges(没有 re-pooling 带来的 detail missing)

5.3 Ablation Study

1)Fixed vs. Learnable Margin

在这里插入图片描述

δ a = 0.5 \delta_a = 0.5 δa=0.5 δ b = 0.8 \delta_b = 0.8 δb=0.8 δ = 1.5 \delta = 1.5 δ=1.5

学出来的更好

2)The Choice of Cluster Centers

p j p_j pj 作为聚类中心,不用 Q k Q_k Qk 作为聚类中心,结果如下

在这里插入图片描述

3)Sampling Strategy

也即正样本采样策略

{ b o x j , c l a s s j , c e n t e r j } \{box_j, class_j, center_j\} {boxj,classj,centerj} 是否落在中心区域

{ p j , σ j } \{p_j,\sigma_j\} {pj,σj} IoU>0.5
在这里插入图片描述
在 mask 内,且 IoU >0.5 合起来,效果会更好

4)Training Samples for Pixel Embedding
在这里插入图片描述
正样本为 GT mask 内的像素,bbox 扩大 1.2 倍,增加 training sample(负样本)效果会更好

5)Embedding Dimension
在这里插入图片描述

6 Conclusion(own)

  • proposal margin,实际中学习的是 1 2 σ 2 \frac{1}{2\sigma^2} 2σ21,会用指数函数保证预测出来的都是正值
  • 小写 q q q 和 大写 Q Q Q,小写 σ \sigma σ 和 大写 Σ \Sigma Σ 的区别是,小写代表每个位置的 embedding,大写表示正样本区域(bbox IoU>0.5)的 embedding 均值
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值