論文筆記:UnsuperPoint: End-to-end Unsupervised Interest Point Detector and Descriptor

SuperPoint 取得了很大的成功,但有一個很明顯的問題:訓練和取得真值都非常困難(需借助模擬)。在實際場景中,要先手動標註再進行 finetune 並不容易。因此,本文提出一種非監督式學習方法,可同時取得關鍵點與描述子。雖然不需監督,這個方法在資料集上仍取得了良好的效果,而且速度也很快。

1 網路設計

本文的網路設計大致與 SuperPoint 一致,但 head 的設計有許多細節不同。SuperPoint 主要透過分類來定位離散的關鍵點座標,並判斷各位置是否為關鍵點。在 UnsuperPoint 中,作者以 score map 作為關鍵點的信賴度指標,並透過迴歸 offset 來定位關鍵點。其網路設計如下:

1.1 Backbone Module

本文的 Backbone module 與 SuperPoint 類似,採用 FCN 網路架構。每一層都由兩個 conv 加上 maxpooling 組成,總共進行 3 次下採樣,通道數依序為:32-32-64-64-128-128-256-256。

因此,最終的 feature map 上每個點都對應到原始影像中一個 8×8 的區域。

1.2 Score Module S_{map}

Score module S_{map} 透過迴歸為每個點算出一個分數,表示該點是關鍵點的信賴度(介於 [0-1] 之間)。它由 conv-256 + conv-1 組成,啟用函數為 sigmoid。和傳統方法一樣,這個分數用來選出得分最高的 N 個關鍵點。

1.3 Position Module P_{map}

Position module 用來預測關鍵點的位置。SuperPoint 採用分類方式(64 個 channel 各自預測一個位置是否為關鍵點),本文則透過迴歸預測一個 8×8 區塊內關鍵點的座標偏移量 offset(正規化至 [0-1] 範圍)。其結構為 conv-256 + conv-2,啟用函數為 sigmoid。下圖以一張 24×24 的影像為例:對於進行 8 倍下採樣的 FCN,position module 實際上會預測 3×3 = 9 個 keypoint 的位置:

其中,計算偏移量的公式如下:

\begin{array}{l}\mathbf{P}_{\operatorname{map}, \mathbf{x}}(r, c)=\left(c+\mathbf{P}_{\text {relative }, \mathbf{x}}(r, c)\right) \cdot f_{\text {downsample }} \\\mathbf{P}_{\text {map }, \mathbf{y}}(r, c)=\left(r+\mathbf{P}_{\text {relative,y }}(r, c)\right) \cdot f_{\text {downsample }}\tag{1}\end{array}

本文中 f_{\text {downsample}} = 8。

1.4 Descriptor Module F_{map}

Descriptor module F_{map} 提供關鍵點的描述資訊,用來衡量關鍵點配對時的相似程度。它由 conv256 – conv256 組成,每個描述子的大小為 256 floats。前一部分產生一張含有 256 個 channels 的 feature map,其中每個位置代表一個 8×8 區塊的描述。後續的 model 則使用 P_{map} 中所有關鍵點的位置,透過內插取得各位置的描述子。由於 P_{map} 透過迴歸取得關鍵點座標,再加上這裡採用的內插方式,整個取得描述子的過程是可微分的,這項特性會在訓練時用到。

2 自監督架構

這一節說明如何進行自監督訓練。整體流程如下圖所示:

3

從圖中可以看出,這個流程其實和監督式方法很像,也就是對影像進行 T 的 Transform,將原始影像變換後,分別從變換前後的影像擷取 score、point、feature 三項結果:變換前為 S^A、P^A 和 F^A,變換後為 S^B、P^B 和 F^B。接著對其中的點位置進行 T 的 transform,將其轉換到 P^B 的位置,取得 Point-pair correspondences,再利用這些配對關係取得所需的非監督訊號。

3 Loss functions

本文採用聯合訓練三個分支的方式,整體的 Loss 公式如下:

\begin{aligned}\mathcal{L}_{\text {total }}=& \alpha_{\text {usp }} \mathcal{L}^{\text {usp }} \\&+\alpha_{\text {uni\_xy }} \mathcal{L}^{\text {uni\_xy }} \\&+\alpha_{\text {desc }} \mathcal{L}^{\text {desc }}+\alpha_{\text {decorr }} \mathcal{L}^{\text {decorr }}\tag{2}\end{aligned}

每一項都有一個權重係數 \alpha。

Point-pair correspondences

以 b \in\{A, B\} 表示兩張影像各自的輸出集合,每張影像都會輸出 3 個 tensor:\mathbf{s}^b、\mathbf{P}^b 和 \mathbf{F}^b。為了計算後文中的 Loss,我們需要定義兩張影像之間的配對點。令 \mathbf{M}^A 和 \mathbf{M}^B 分別表示兩張影像的 branch 輸出,則兩者的距離矩陣定義為 \mathbf{G} = \mathbf{M}^A \times \mathbf{M}^B。公式如下:

\mathbf{G}=\left[g_{i j}\right]_{M^{\mathrm{A}} \times M^{\mathrm{B}}}=\left[\left\|\mathbf{p}_{i}^{\mathrm{A} \rightarrow \mathrm{B}}-\mathbf{p}_{j}^{\mathrm{B}}\right\|_{2}\right]_{M^{\mathrm{A}} \times M^{\mathrm{B}}}\tag{3}

其中 \mathbf{p}_{i}^{\mathrm{A} \rightarrow \mathrm{B}}=T \mathbf{p}_{i}^{\mathrm{A}}\tag{4}。

最近鄰
如果 A 中的 point i 和 B 中的 point j 之間的距離滿足 g_{ij} < \epsilon_{correspond},則稱這兩個點互為最近鄰。

根據這個定義,對於 B 中給定的 tensor \mathbf{s}^b、\mathbf{P}^b 和 \mathbf{F}^b,我們可以找出 K 個最近鄰,並將相應的結果記為 \hat{\mathbf{s}^b}、\hat{\mathbf{P}^b} 和 \hat{\mathbf{F}^b},其中各點以下標 k 表示。第 k 個最近鄰點的 score 為 \hat{s_k^b}、position 為 \hat{\mathbf{p}_k^b},descriptor 為 \hat{\mathbf{f}_k^b}。對應點之間的距離為:

d_{k}=\left\|T \hat{\mathbf{p}}_{k}^{\mathrm{A}}-\hat{\mathbf{p}}_{k}^{\mathrm{B}}\right\|=\left\|\hat{\mathbf{p}}_{k}^{\mathrm{A} \rightarrow \mathrm{B}}-\hat{\mathbf{p}}_{k}^{\mathrm{B}}\right\|\tag{5}

3.1 Unsupervised point loss \mathcal{L}^{u s p}

這個 unsupervised point loss \mathcal{L}^{u s p} 定義如下:

\mathcal{L}^{u s p}=\alpha_{\text {position }} \sum_{k=1}^{K} l_{k}^{\text {position }}+\alpha_{\text {score }} \sum_{k=1}^{K} l_{k}^{\text {score }}+\sum_{k=1}^{K} l_{k}^{\text {usp }}\tag{6}

它分成三個部分,每個部分都對 K 個最近鄰點加總。各部分如下:

Position Loss
這部分 loss 的主要目標是讓 A 圖偵測到的關鍵點位置經變換後,與 B 圖偵測到的對應關鍵點位置一致,藉此確保關鍵點位置在不同視角下仍能保持穩定:
l_{k}^{\text {position }}=d_{k}\tag{7}

Score Loss
這部分 loss 的主要目標是讓 A 圖與 B 圖中對應點的分數相近,也就是讓同一個點在不同視角下具有一致的信賴度:
l_{k}^{\mathrm{score}}=\left(\hat{s}_{k}^{\mathrm{A}}-\hat{s}_{k}^{\mathrm{B}}\right)^{2}\tag{8}

Unsupervised Point Loss
這部分 loss 的主要目標,是確保網路預測的 score(信心度)能反映關鍵點座標可重現(repeatable)的機率。例如,在不同視角下重現率較高的點,score 也會比較高:
l_{k}^{\text {usp }}=\hat{s}_{k}\left(d_{k}-\bar{d}\right)\tag{9}

其中 \hat{s}_{k} 表示同一個點在 A 圖與 B 圖中的平均分數:
\hat{s}_{k}=\frac{\hat{s}_{k}^{\mathrm{A}}+\hat{s}_{k}^{\mathrm{B}}}{2}\tag{10}

而 \bar{d} 表示同一個點在所有最近鄰中的平均位置:
\bar{d}=\frac{1}{K} \sum_{k=1}^{K} d_{k}\tag{11}

3.2 Uniform point predictions \mathcal{L}^{uni\_xy}

如果只用上述 Loss 進行非監督式訓練,就容易產生一些有缺陷(artifact)的關鍵點,如下圖所示:

如圖(a)所示,大部分預測點的 offset 座標可能會集中在區塊邊緣(0 和 8);加入均勻 loss 後,這些座標就會比較分散,如圖(b)所示。顯然,對於同一個區塊內的點來說,offset 均勻分布才比較合理。

Uniform point predictions \mathcal{L}^{uni\_xy} 正是為了解決這個問題而設計的。其定義如下:

\begin{aligned}\mathcal{L}^{\text {uni\_xy}} &=\alpha_{\text {uni\_xy}}\left(\mathcal{L}^{\text {uni\_x}}+\mathcal{L}^{\text {uni\_y}}\right) \\\mathcal{L}^{\text {uni\_x}} &=\sum_{i=1}^{M}\left(x_{i}^{\text {sorted }}-\frac{i-1}{M-1}\right)^{2} \\\mathcal{L}^{\text {uni\_y}} &=\sum_{i=1}^{M}\left(y_{i}^{\text {sorted }}-\frac{i-1}{M-1}\right)^{2}\tag{12}\end{aligned}

3.3 Descriptor \mathcal{L}^{desc}

描述子 Loss 採用 hinge loss,定義如下:
\begin{aligned}\mathcal{L}^{\mathrm{desc}} &=\sum_{i=1}^{M^A} \sum_{j=1}^{M^B} l_{i j}^{\mathrm{desc}} \\l_{i j}^{\mathrm{desc}} &=\lambda_{d} \cdot c_{i j} \cdot \max \left(0, m_{p}-\mathbf{f}_{i}^{\mathrm{A}^{T}} \mathbf{f}_{j}^{\mathrm{B}}\right) \\&+\left(1-c_{i j}\right) \cdot \max \left(0, \mathbf{f}_{i}^{\mathrm{A}^{T}} \mathbf{f}_{j}^{\mathrm{B}}-m_{n}\right) \\\tag{13}\end{aligned}

3.4 Decorrelate descriptor \mathcal{L}^{decorr}

Decorrelate(去相關) descriptor loss \mathcal{L}^{decorr} 用來減少過度擬合,並讓描述子部分更緊緻。假設有一個描述子相關性矩陣 \mathbf{R}^{b}=\left[r_{i j}^{b}\right]_{F \times F},則 \mathcal{L}^{decorr} 的定義如下:

\mathcal{L}^{\mathrm{decorr}}=\sum_{i \neq j}^{F}\left(r_{i j}^{\mathrm{A}}\right)+\sum_{i \neq j}^{F}\left(r_{i j}^{\mathrm{B}}\right) \\\tag{14}

其中:
r_{i j}^{b}=\frac{\left(\mathbf{v}_{j}^{b}-\bar{v}_{j}^{b}\right)^{T}\left(\mathbf{v}_{i}^{b}-\bar{v}_{i}^{b}\right)}{\sqrt{\left(\mathbf{v}_{j}^{b}-\bar{v}_{j}^{b}\right)^{T}\left(\mathbf{v}_{i}^{b}-\bar{v}_{i}^{b}\right)} \sqrt{\left(\mathbf{v}_{j}^{b}-\bar{v}_{j}^{b}\right)^{T}\left(\mathbf{v}_{i}^{b}-\bar{v}_{i}^{b}\right)}}\tag{15}

上式中,\mathbf{v}_{i}^{b} 是一個 \mathbf{M}_b \times 1 維行向量,代表 \mathbf{F}_b 的第 i 行。\bar{v}_{i}^{b} 代表 \mathbf{v}_{i}^{b} 的平均值。

4 實驗

實驗結果當然很亮眼(不亮眼還發什麼論文呢?)。在速度與 SuperPoint 相差無幾的情況下,這個方法在各個測試資料集上的表現幾乎都優於 SuperPoint 和其他幾個網路。論文對實驗細節交代得相當完整,建議仔細閱讀原文,這裡只摘錄幾個主要結論:

4.1 參數設定

作者使用 MSCOCO 資料集中的 118,287 張圖片進行訓練。實驗使用的參數如下:

參數名稱參數值
輸入320x240x3
normalize-0.5再x0.225
batch size5
optimizerAdam
\epsilon_{correspond}4
m_p1
m_n0.2
\delta_d250
\alpha_{usp}1
\alpha_{position}1
\alpha_{score}2
\alpha_{uni\_xy}100
\alpha_{desc}0.001
\alpha_{decorr}0.03

4.2 比較實驗

作者針對論文中提到的幾種策略進行了比較實驗:
C1 表示在 descriptor 部分加入差值,這項做法提升了 matching score(對應 1.4);
C2 表示在 detector 部分加入 Uniform point predictions,這項做法提升了 repeatability 和 homography 的精度,並降低了 localization error(對應 3.2);
C3 表示在 descriptor 部分加入 Decorrelate,這項做法不僅提升了 repeatability,也改善了整體效能。
C4 表示同時使用 C1、C2 和 C3 策略。
實驗結果如下表所示:

4.3 速度

SuperPoint、UnsuperPoint 和 LF-Net 的速度測試是在 GPU(GeForce Titan X)上進行,其餘則是在 CPU(Intel i7-7700HQ)上進行。

4.4 Repeatability and localization error

4.5 Homography estimation and matching score

個人小結

本文最主要的貢獻在於採用無監督的方式,在實際環境中確實很實用。不過,我對於如何透過學習得到 detector 還是有些疑惑。由於作者沒有提供原始碼,預計要重現結果並不容易。

相關資料

論文


原始碼(第三方範例)
https://github.com/791136190/UnsuperPoint_PyTorch
https://github.com/RPFey/UnsuperPoint

Add a Comment

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