Skip to content

Instantly share code, notes, and snippets.

@gihyunkim
Created October 11, 2019 05:27
Show Gist options
  • Save gihyunkim/4506bc89c680e01d94cc53abc053b340 to your computer and use it in GitHub Desktop.
Save gihyunkim/4506bc89c680e01d94cc53abc053b340 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# YOLOv3\n",
"- 기존의 yolo v2에 다른 사람들의 여러 아이디어를 차용한 내용이다.\n",
"\n",
"## 1. Bounding box prediction\n",
"- 기존의 방식은 tx, ty, tw, th를 예측하고 위의 식으로 bx, by, bw, bh를 구한 다음 L2 LOSS를 통해서 학습을 시켰다.\n",
"\n",
"$$b_x = \\sigma(t_x)+c_x$$\n",
"$$b_y = \\sigma(t_y)+c_y$$\n",
"$$b_w = p_we^{t_w}$$\n",
"$$b_h = p_he^{t_h}$$\n",
"\n",
"\n",
"- 이에 대한 컨셉을 변경해, 위의 기존 식을 Inverse해서 다이렉트로 tx, ty, tw, th 값들의 L1 LOSS 값을 구한다.\n",
"\n",
"$$t_x = \\sigma^{-1}(b_x-c_x)$$\n",
"$$t_y = \\sigma^{-1}(b_y-c_y)$$\n",
"$$t_w = ln\\frac{b_w}{p_w}$$\n",
"$$t_h = ln\\frac{b_h}{p_h}$$\n",
"\n",
"\n",
"- YOLO V3에서는 각각의 예측된 box마다 objectness에 대한 점수를 logistic regression을 사용해서 구한다.\n",
" - 만약 예측된 어떤 box가 다른 box들보다 IOU가 높다면 해당 값은 1이 되어야 한다.\n",
" - 만약 Box의 IOU가 Best는 아니지만 특정 threshold보다는 높은 결과가 나온다면 Faster R-CNN의 방법을 사용해 무시.\n",
" \n",
" \n",
"- YOLO V3는 Faster R-CNN과는 다르게 하나의 Box에 하나의 GT box를 할당.\n",
" - 만약 GT가 할당되지 않는다면, 좌표 및 클래스 예측에 손실을 주진 않고, Objectness에 대한 손실 값만 적용."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Class prediction\n",
"- 각각의 bbox는 class 예측을 multi-label classification을 하게 되는데, 여기서 기존의 softmax를 사용하는 것이 성능면에서 좋지않아, **logistic classifier**를 사용하였다. (loss = binary cross-enropy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predictions Across Scales\n",
"- 3개의 다른 scale의 box들을 예측한다.\n",
"\n",
"\n",
"- **feature pytamid network**의 컨셉과 유사한 방식으로 다양한 scale에서 feature들을 추출.\n",
" - 기존 feature extractor에서 몇개의 convolutional layer를 추가.\n",
" \n",
"\n",
"- 최종단으로부터 2번째 이전 layer에서 feature map을 가져와 2배로 up-scaling을 하고, 제일 앞단의 feature map을 가져와 둘을 concatenation을 이용해 합친다.\n",
" - 의미 있는 semantic information을 이전 layer의 feature map을 이용해 얻을 수 있고, finer-grained information을 제일 앞단의 feature map으로부터 얻을 수 있다."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Feature Extractor\n",
"- Darknet-19와 newfangled residual network를 하이브리드하여 새로운 네트워크 모델을 생성.\n",
" - 정확도는 높으면서 연산량은 낮고 더 빠르다."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Things We tried that didn't work\n",
"시도했지만 제대로 동작하지 않은 것들.\n",
"\n",
"1. anchor box x, y offset prediction\n",
"linear activation을 사용해 다양한 box의 width, height의 x,y offset을 일반적인 anchor box 예측 메카니즘을 사용해 해결하려 했지만, model의 안정성을 떨어트리며 잘 작동하지 않았다.\n",
"\n",
"\n",
"2. Linear x, y predictions instead of logistic\n",
"logistic activation 대신 linear activation을 사용해 다이렉트로 x, y의 offset 값을 예측하려 했지만 mAP가 감소.\n",
"\n",
"\n",
"3. Focal Loss\n",
"YOLO는 이미 objectness와 conditional class prediction이 분리되어 있어, focal loss 문제에 대해 자체적으로 해결이 된다. 따라서 대부분의 class prediction으로부터 loss가 생기지 않을 거라 생각한다.\n",
"\n",
"4. Dual IOU thresholds and thruth assignment\n",
"Faster R-CNN은 학습하는 동안 2가지 IOU threshold를 사용하는데, 만약 예측된 값이 GT와의 IOU값이 0.7이라면 이는 [0.3, ~0.7]로 셋팅된 값으로 인해 positive example이 되고, 0.3보다 작다면 이는 negative example로 무시되게 된다. YOLO v3에서 이와 유사한 방식을 적용했지만 좋은 결과를 얻지 못했다. "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment