SphereNet(2018)
이 포스트는 제가 개인적인 용도로 정리한 글 입니다.
SphereNet: Learning Spherical Representations for Detection and Classification in Omnidirectional Images (ECCV 2018) pdf
- Unofficial github: 공식 구현은 아니고 다른 사람이 직접 구현한 모델이다.
- SphereConv2D & SphereMaxPool2D
- Kernel Pattern Look-up Table
- Uniform sampling
- OmniMNIST
- Spherical Object Detection
- SphereConv2D & SphereMaxPool2D
Kernel Sampling Method
“The central idea of SphereNet is to lift local CNN operations from the regular image domain to the sphere surface where omnidirectional images can be represented without distortions.”
“This is achieved by representing the kernel as a small patch tangent to the spehre.”
- $S$: unit sphere
- $S^2$: its surface
- $\mathbf{s} = (\phi, \theta) \in S^2$
- 점 $\mathbf{s}$가 $S^2$ 위에 있어, 좌표가 위도/경도로 표현된다는 말은 곧 “equirectangular image 위에 있다”는 말이다.
- $\Pi$: tangent plane located at \(\mathbf{s}_{\Pi} = (\phi_{\Pi}, \theta_{\Pi})\)
- $\mathbf{x}$ : a point on $\Pi$ by its coordinates $\mathbf{x} \in \mathbb{R}^2$
- $\Pi_0$: tangent plane located at $\mathbf{s} = (0 ,0)$.
“A point $s$ on the sphere is related to its tangent plane coordinates $\mathbf{x}$ via a gnomonic projection.”
Sampling at the center
Equirectangular의 중심에서 샘플링 = step size $\Delta_{\theta}$, $\Delta_{\phi}$ 만큼 sampling 함.
\[\begin{aligned} \mathbf{s}_{(0, 0)} &= (0, 0) \\ \mathbf{s}_{(\pm 1, 0)} &= (\pm \Delta_{\theta}, 0) \\ \mathbf{s}_{(0, \pm 1)} &= (0, \pm \Delta_{\phi}) \\ \mathbf{s}_{(\pm 1, \pm 1)} &= (\pm \Delta_{\theta}, \pm \Delta_{\phi}) \end{aligned}\]실제 논문에서의 notation
아래의 공식들과 notation이 약간 안 맞아서, 포스트의 방식으로 $\phi$와 $\theta$ 순서를 바꿨다.
이때, 각 sampling point들이 tangent plane $\Pi_0$의 어디에 있는지 계산할 수 있다. gnomonic projection을 이용해 계산한 결과는 아래와 같다.
그래서 Sampling pattern \(\mathbf{s}_{(j, k)}\)는 곧, 아래와 같은 kernel pattern $\mathbf{x}_{(j, k)}$를 유도한다.
\[\begin{aligned} \mathbf{x}_{(0, 0)} &= (0, 0) \\ \mathbf{x}_{(\pm 1, 0)} &= (\pm \tan \Delta_{\theta}, 0) \\ \mathbf{x}_{(0, \pm 1)} &= (0, \pm \tan \Delta_{\phi}) \\ \mathbf{x}_{(\pm 1, \pm 1)} &= (\pm \tan \Delta_{\theta}, \pm \sec \Delta_{\theta} \tan \Delta_{\phi}) \end{aligned}\]공식 유도
위의 공식이 잘 와닿지 않아서 직접 유도해보려고 한다.
먼저 $\mathbf{s}_{(0, 0)} = (0, 0)$인 경우를 살펴보자.
이때 $(\theta_{\Pi_0}\, , \phi_{\Pi_0}) = (0, 0)$이다.
이제 공식에 대입해보자.
\[\begin{aligned} x(0, 0) &= \frac{\cos 0\sin (0 - 0)}{\sin 0 \sin 0+ \cos 0\cos 0\cos (0- 0)} = 0\\ \\ y(0, 0) &= \frac{\cos 0 \sin 0- \sin 0\cos 0\cos (0- 0)}{\sin 0 \sin 0+ \cos 0\cos 0\cos (0- 0)} = 0 \end{aligned}\]그럼 분자의 텀이 모두 0이 되기 때문에, 위에서 유도한 $\mathbf{x}_{(0, 0)} = (0, 0)$의 결과가 나온다.
일단 다음 과정을 진행하기 전에 $(\phi_{\Pi_0}\, , \theta_{\Pi_0}) = (0, 0)$에 맞춰서 공식을 refine 하자.
\[\begin{aligned} x(\theta, \phi) &= \frac{\cos \phi \sin (\theta - 0)}{\sin 0 \sin \phi + \cos 0\cos \phi \cos (\theta - 0)} \\ &= \frac{\cos \phi \sin \theta}{\cos \phi \cos \theta} = \frac{\sin \theta}{\cos \theta} = \tan \theta \\ \\ y(\theta, \phi) &= \frac{\cos 0 \sin \phi - \sin 0\cos \phi \cos (\theta - 0)}{\sin 0 \sin \phi + \cos 0\cos \phi \cos (\theta - 0)} \\ &= \frac{\sin \phi}{\cos \phi \cos \theta} = \frac{\tan \phi}{\cos \theta} \end{aligned}\]이번에는 \(\mathbf{s}_{(\pm 1, 0)} = (\pm \Delta_{\theta}, 0)\)의 경우를 살펴보자.
이때, $(\theta_{\Pi_0}\, , \phi_{\Pi_0}) = (0, 0)$이다.
공식에 대입하면 아래와 같다.
\[\begin{aligned} x(\pm \Delta_{\theta}, 0) &= \frac{\sin \theta}{\cos \theta} = \frac{\sin (\pm \Delta_{\theta})}{\cos (\pm \Delta_{\theta})} = \pm \tan \Delta_{\theta}\\ \\ y(\pm \Delta_{\theta}, 0) &= \frac{\tan 0}{\cos \pm \Delta_{\theta}} = 0 \end{aligned}\]그래서 위에서 유도한 \(\mathbf{x}_{(\pm 1, 0)} = (\pm \tan \Delta_{\theta}, 0)\)의 결과가 나온다.
Inverse gnomonic projection
앞에서는 kernel의 중심을 \(\mathbf{s}_{\Pi_0} = (0, 0)\)으로 잡았다면, 이번에는 \(\mathbf{s}_{\Pi} = (\theta_{\Pi}, \phi{\Pi})\)로 잡자.
이때, kernel paattern $\mathbf{x} = (x, y)$에서 sampling pattern $\mathbf{s} = (\theta, \phi)$는 아래와 같이 유도할 수 있다.
수식이 많이 복잡한데, 간단한 케이스인 $\mathbf{s}_{\Pi_0} = (0, 0)$에서 살펴보자.
사실 이 공식은 앞에서 살펴본, sampling pattern $\mathbf{s} = (\theta, \phi)$에서 kernel paattern $\mathbf{x} = (x, y)$를 유도하는 공식의 역함수다.
Implementation
Equirectangular Image에서 row에 대한 정보가 같다면 모두 동일한 kernel sampling deviation을 가진 kernel을 사용한다. 그래서 이것을 row에 따라 계산하여 look-up table에 저장한 후 꺼내 쓴다는 말이다.
Experiment
Spherical Image Classification
Conv layer와 Pool layer를 SphereConv와 SpherePool로 교체해주면 된다.
평-범
Spherical Object Detection
Spherical Single Shot MultiBox Detector(Sphere-SSD)를 제시한다.
흥미로운 점은 IoU를 비교하기 위해 두 polygonal region을 동일한 tangent plane에 매핑하여 그 상태에서 IoU를 구했다는 점이다. Equirectangular Image에서 IoU를 구하지 않은 점이 흥미롭다.
Classification: Omni-MNIST
생-략
Object Detection: FlyingCars
360 이미지에 대한 Dataset이 부족하여 논문에서 자체적으로 FlyingCars Dataset을 만들었다고 한다.
단순하게 360 이미지에 3D car model을 붙인 형식이라고 한다.
기존 360 이미지 Detection 방법보다 개선된 결과가 도출되었다.
주목할 점은 Detection된 이미지를 살펴보면, Equirectangular의 Discontinuity 문제를 완벽하게 해결하고 있다는 점이다!!
Transfer Learning: OmPaCa
기존의 perspective dataset에서 학습된 모델에 Spherial Layer를 적용한 실험이다.
논문에선 실험을 위해 Omnidirectional Parked Cars(OmPaCa) Dataset을 새롭게 제시한다.
KITTI Dataset1에서 학습시킨 perspective SSD model을 Sphere-SSD 모델로 변환하여 fine-tune 하였다.
-
UC Berkeley에서 공개한 “자율주행용 학습 데이터”이다. ↩