論文筆記:ASLFeat: Learning Local Features of Accurate Shape and Localization

本文在 D2-Net 的基礎上進一步改進,主要創新如下:

1)使用 Deformable Convolution 進行密集的變換估計與特徵擷取
2)使用特徵金字塔適應不同的空間解析度,並利用 low-level 細節精確定位特徵點

1 Methods

1.1 Prerequisites

本文的網路設計以 DCN 和 D2-Net 這兩項研究為基礎。首先回顧它們的核心概念:

Deformable convolutional networks (DCN)

可變形卷積 (Deformable Convolutional Networks, DCN) 的主要目的是學習動態感受野。傳統卷積的公式如下:

\begin{equation}\mathbf{y}(\mathbf{p})=\sum_{\mathbf{p}_{n} \in \mathcal{R}} \mathbf{w}\left(\mathbf{p}_{n}\right) \cdot \mathbf{x}\left(\mathbf{p}+\mathbf{p}_{n}\right)\end{equation}
其中 \mathbf{p} 代表卷積的中心點座標,\mathbf{p}_{n} 代表卷積範圍 \mathcal{R} 內的偏移量,\mathbf{x}(\cdot) 表示取該點的像素值。DCN 則在此基礎上加入預測的 offset \Delta p 以及 feature 權重 \Delta m:

\begin{equation}\mathbf{y}(\mathbf{p})=\sum_{\mathbf{p}_{n} \in \mathcal{R}} \mathbf{w}\left(\mathbf{p}_{n}\right) \cdot \mathbf{x}\left(\mathbf{p}+\mathbf{p}_{n}+\Delta \mathbf{p}_{n}\right) \cdot \Delta \mathbf{m}_{n}\end{equation}
由於 \Delta p 通常是小數,因此實作時會採用非線性插值。

D2-Net

D2-Net 的核心概念是將 descriptor 和 detector 合而為一,也就是 describe-and-detect。它先學習一張 feature map,再透過 L2-Norm 取得 local descriptors;至於 detector,則是在 y 上進行以下計算:

計算 local score:

\begin{equation}\alpha_{i j}^{c}=\frac{\exp \left(\mathbf{y}_{i j}^{c}\right)}{\sum_{\left(i^{\prime}, j^{\prime}\right) \in \mathcal{N}(i, j)} \exp \mathbf{y}_{i^{\prime} j^{\prime}}^{c}}\end{equation}
其中 \mathcal{N}(i, j) 代表鄰近像素的範圍,例如 3 \times 3 卷積的鄰域大小為 3 × 3,共 9 個像素。

計算 channel-wise-score:

\begin{equation}\beta_{i j}^{c}=\mathbf{y}_{i j}^{c} / \max _{t} \mathbf{y}_{i j}^{t}\end{equation}
最後,將兩者相乘後取最大值,即可得到 detector score:

\begin{equation}s_{i j}=\max _{t}\left(\alpha_{i j}^{c} \beta_{i j}^{c}\right)\end{equation}

在此基礎上,本文提出了以下改進。

1.2  DCN with Geometric Constraints

作者認為,原版 DCN 的自由度過高,可能預測出任意形變。但在視覺定位任務中,形變作用於整體,自由度有限,通常僅涉及以下三類變換:1) similarity, 2) affine and 3) homography:

因此,傳統 DCN 不僅會學到不必要的參數,也無法保證符合幾何約束。為此,作者加入幾何約束來改進 DCN。

Affine-constrained DCN

包含旋轉與縮放的 Affine Transform 通常如下所示:

\begin{equation}\mathbf{S}=\lambda R(\theta)=\lambda\left(\begin{array}{cc}\cos (\theta) & \sin (\theta) \\-\sin (\theta) & \cos (\theta)\end{array}\right)\end{equation}
有些論文(例如 AffNet)還會引入彎曲係數,因此本文也採用類似做法,將 Affine Transform 定義如下:

\begin{equation}\begin{aligned}\mathbf{A} &=\mathbf{S} A^{\prime}=\lambda R(\theta) A^{\prime} \\&=\lambda\left(\begin{array}{cc}\cos (\theta) & \sin (\theta) \\-\sin (\theta) & \cos (\theta)\end{array}\right)\left(\begin{array}{ll}a_{11}^{\prime} & 0 \\a_{21}^{\prime} & a_{22}^{\prime}\end{array}\right)\end{aligned}\end{equation}

Homography-constrained DCN

Homography 通常可用 4 組對應點求解。本文參考《Unsupervised deep homography》的做法,使用可微分的線性求解器求出 H 矩陣。線性方程式通常定義為:\mathbf{M h}=\mathbf{0},\mathbf{M} \in \mathbb{R}^{8 \times 9}。其中 \mathbf{h} 是一個 9 維向量,表示 \mathbf{H} 矩陣的 9 個參數。由於必須滿足 \mathbf{H}_{33}=1、\mathbf{H}_{31}=\mathbf{H}_{32}=- 這三項約束,實際上只剩 6 個參數。將線性方程式改寫為 \hat{\mathbf{M}}_{(i)} \hat{\mathbf{h}}=\hat{\mathbf{b}}_{(i)},其中 \hat{\mathbf{M}}_{(i)} \in \mathbb{R}^{2 \times 6},而對於每組對應點 (u_i, v_i) 與 (u_i', v_i'),可得:

\begin{equation}\hat{\mathbf{M}}_{(i)}=\left[\begin{array}{cccccc}0 & 0 & -u_{i} & -v_{i} & v_{i}^{\prime} u_{i} & v_{i}^{\prime} v_{i} \\u_{i} & v_{i} & 0 & 0 & -u_{i}^{\prime} u_{i} & -u_{i}^{\prime} v_{i}\end{array}\right]\end{equation}

以及:

\begin{equation}\hat{\mathbf{b}}_{(i)}=\left[-v_{i}^{\prime}, u_{i}^{\prime}\right]^{T} \in \mathbb{R}^{2 \times 1}\end{equation}

最後建立的線性方程式如下:

\begin{equation}\hat{\mathbf{M}} \hat{\mathbf{h}}=\hat{\mathbf{b}}\end{equation}

使用可微分的線性求解器(tf.matrix solve)即可求出 \mathbf{h}。

實作時,我們使用 {(−1, −1),(1, −1),(1, 1),(−1, 1)} 這四個偏移量,再乘以 \mathbf{H},得到新的偏移量。

定義完上述幾何變換後,即可用以下公式求得符合幾何約束的偏移量:

\begin{equation}\triangle \mathbf{p}_{n}=\mathbf{T} \mathbf{p}_{n}-\mathbf{p}_{n}, \text { where } \mathbf{p}_{n} \in \mathcal{R}\end{equation}

1.3 Selective and Accurate Keypoint Detection

Keypoint peakiness measurement

在 D2-Net 中,detector 的分數由 spatial 和 channel-wise responses 共同決定。計算 channel-wise-score 時使用了 ratio-to-max,這可能會使分數與其在 channel 上的實際分布關聯變弱(?)。因此,作者對這兩個 score 做了以下改進,主要是希望以峰值作為 detector d 的評分標準:

\begin{equation}\beta_{i j}^{c}=\operatorname{softplus}\left(\mathbf{y}_{i j}^{c}-\frac{1}{C} \sum_{t} \mathbf{y}_{i j}^{t}\right)\end{equation}

相應地:

\begin{equation}\alpha_{i j}^{c}=\operatorname{softplus}\left(\mathbf{y}_{i j}^{c}-\frac{1}{|\mathcal{N}(i, j)|} \sum_{\left(i^{\prime}, j^{\prime}\right) \in \mathcal{N}(i, j)} \mathbf{y}_{i^{\prime} j^{\prime}}^{c}\right)\end{equation}

其中 softplus 啟用函數如下:

\begin{equation}f(x)=\ln \left(1+e^{x}\right)\end{equation}

Multi-level keypoint detection (MulDet)

D2-Net 的關鍵點定位不夠精確,原因是它在低解析度的特徵圖上進行偵測。恢復空間解析度的方法有很多種(如下圖所示),例如訓練額外的特徵解碼器或採用膨脹卷積,但這些方法不是增加了要學習的參數數量,就是需要大量的 GPU 記憶體或運算資源。

作者提出了一種簡單有效的方法,不需要額外學習權重,而是利用卷積網路原有的金字塔特徵層級,結合多個層級的偵測結果。這是一種分層的尺度融合方法。

\begin{equation}\hat{\mathbf{s}}=\frac{1}{\sum_{l} w_{l}} \sum_{l} w_{l} \mathbf{s}^{(l)}\end{equation}

最終的 score 是將各層相同位置的 score 加權求和而得。

1.4 Learning Framework

Network architecture

最終的網路設計如下圖所示:

和 VGG 的設計一樣,每個尺度都有兩個 conv。最後一層使用了 3 層 deformable conv(conv6, conv7 和 conv8),MulDet 則使用 conv1、conv3 和 conv8 這三層的特徵。

公式 14 中的 w_{i}=1,2,3,公式 3 中的 \mathcal{N}(i, j)=3,2,1。

Loss design

令 \mathcal{C} 代表影像對 (I, I^{\prime}) 中的特徵點配對。與 D2-Net 類似,Loss 定義如下:

\begin{equation}\mathcal{L}\left(I, I^{\prime}\right)=\frac{1}{|\mathcal{C}|} \sum_{c \in \mathcal{C}} \frac{\hat{s}_{c} \hat{s}_{c}^{\prime}}{\sum_{q \in \mathcal{C}} \hat{s}_{q} \hat{s}_{q}^{\prime}} \mathcal{M}\left(\mathbf{f}_{c}, \mathbf{f}_{c}^{\prime}\right)\end{equation}

其中 \hat{S}_{k} 和 \hat{S}_{k}^{\prime} 分別代表 (I 和 I^{\prime}) 對應的 detector score,\mathbf{f}_{k} 和 \mathbf{f}_{k}^{\prime} 代表 descriptors,\mathcal{M}(\cdot, \cdot) 代表 ranking loss,用來取代 D2-Net 中的 hardest-triplet loss。這裡將 \mathcal{M} 定義如下:

\begin{equation}\begin{array}{l}\mathcal{M}\left(\mathbf{f}_{c}, \mathbf{f}_{c}^{\prime}\right)=\left[D\left(\mathbf{f}_{c}, \mathbf{f}_{c}^{\prime}\right)-m_{p}\right]_{+}+ \\\quad\left[m_{n}-\min \left(\min _{k \neq c} D\left(\mathbf{f}_{c}, \mathbf{f}_{k}^{\prime}\right), \min _{k \neq c} D\left(\mathbf{f}_{k}, \mathbf{f}_{c}^{\prime}\right)\right)\right]_{+}\end{array}\end{equation}

其中 D(\cdot, \cdot) 代表歐氏距離。m_p 和 m_n 分別為 0.2 和 1.0。

2 Experiments

2.1 Image Matching

實驗結果如下:

2.2 Comparisons with other methods

實驗結果如下

2.3 3D Reconstruction

實驗結果如下:

2.4 Visual Localization

實驗結果如下:

論文 & 原始碼

論文
https://arxiv.org/abs/2003.10071

原始碼
https://github.com/lzx551402/ASLFeat

參考資料

[1] https://blog.csdn.net/phy12321/article/details/106040545
[2] https://www.jianshu.com/p/c184c2efbecc

Add a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *