논문 노트: ASLFeat: 정확한 형태와 위치를 갖는 지역 특징 학습
본 논문은 D2-Net을 한 단계 더 개선한 것으로, 주요 개선점은 다음과 같다.
1) Deformable Convolution을 사용해 밀집 변환을 추정하고 특징을 추출한다.
2) 특징 피라미드를 사용해 공간 해상도에 대응하고, low-level 세부 정보를 활용해 특징점의 위치를 정밀하게 찾는다.
1 방법
1.1 배경 지식
본 논문의 네트워크 설계는 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를 얻고, y에 다음 연산을 적용해 detector 점수를 구한다.
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는 두 점수를 곱한 뒤 최댓값을 취해 얻는다.
이를 바탕으로 본 논문은 다음과 같은 개선을 제안한다.
1.2 DCN with Geometric Constraints
저자들은 기존 DCN의 자유도가 너무 높아 임의의 변형을 예측할 수 있다고 본다. 그러나 시각적 위치 추정에서는 변형이 전체에 걸쳐 일어나고 자유도도 제한적이다. 일반적으로 1) similarity, 2) affine, 3) homography로 한정된다.

따라서 기존 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을 다음과 같이 정의한다.
Homography-constrained DCN
Homography는 일반적으로 네 쌍의 대응점으로 구할 수 있다. 본 논문에서는 《Unsupervised deep homography》의 방식을 따라 미분 가능한 선형 방정식 풀이기로 H 행렬을 구한다. 일반적으로 선형 방정식은 \mathbf{M h}=\mathbf{0}, \mathbf{M} \in \mathbb{R}^{8 \times 9}로 정의된다. 여기서 \mathbf{h}는 \mathbf{H} 행렬의 9개 파라미터를 나타내는 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에서는 spatial 및 channel-wise responses를 함께 사용해 detector 점수를 구한다. channel-wise-score 계산에 ratio-to-max를 사용하면 점수와 채널 내 실제 분포의 연관성이 약해질 수 있다(?). 이를 바탕으로 저자들은 두 점수의 계산 방식을 다음과 같이 개선했다. 주된 목적은 피크를 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를 두 개씩 배치하고, 마지막에는 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 실험
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








