introduction_en.ipynb 5.5 KB
Notebook
Newer Older
W
wangxinxin08 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Introduction\n",
    "[PP-YOLO](https://arxiv.org/abs/2007.12099) is a optimized model based on YOLOv3 in PaddleDetection,whose performance(mAP on COCO) and inference spped are better than [YOLOv4](https://arxiv.org/abs/2004.10934). For more details, refer to [official documentation](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.5/configs/ppyolo/README.md)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Model Effects\n",
    "PP-YOLO reached mmAP(IoU=0.5:0.95) as 45.9% on COCO test-dev2017 dataset, and inference speed of FP32 on single V100 is 72.9 FPS, inference speed of FP16 with TensorRT on single V100 is 155.6 FPS.\n",
    "\n",
    "<div align=\"center\">\n",
19
    "  <img src=\"https://raw.githubusercontent.com/PaddlePaddle/PaddleDetection/release/2.5/docs/images/ppyolo_map_fps.png\" width=500 />\n",
W
wangxinxin08 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. How to use the model\n",
    "Clone PaddleDetection firstly and put the COCO-style dataset in `dataset/coco`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
34
   "metadata": {},
W
wangxinxin08 已提交
35 36
   "outputs": [],
   "source": [
37 38 39 40
    "%mkdir -p ~/work\n",
    "%cd ~/work/\n",
    "!git clone https://github.com/PaddlePaddle/PaddleDetection.git\n",
    "\n",
41
    "%cd PaddleDetection\n",
42
    "%mkdir -p demo_input demo_output\n",
43
    "!pip install -r requirements.txt"
W
wangxinxin08 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1 Training\n",
    "Training PP-YOLO on 8 GPUs with following command(all commands should be run under PaddleDetection dygraph directory as default)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
57
   "metadata": {},
W
wangxinxin08 已提交
58 59
   "outputs": [],
   "source": [
60
    "!python -m paddle.distributed.launch --log_dir=./ppyolo_dygraph/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml"
W
wangxinxin08 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 Inference\n",
    "For inference deployment or benchmark, model exported with `tools/export_model.py` should be used and perform inference with Paddle inference library with following commands:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
74
   "metadata": {},
W
wangxinxin08 已提交
75 76 77
   "outputs": [],
   "source": [
    "# export model, model will be save in output/ppyolo as default\n",
78 79
    "!wget -P demo_input -N https://paddledet.bj.bcebos.com/modelcenter/images/General/000000014439.jpg\n",
    "!python tools/export_model.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml -o weights=https://paddledet.bj.bcebos.com/models/ppyolo_r50vd_dcn_1x_coco.pdparams\n",
W
wangxinxin08 已提交
80 81
    "\n",
    "# inference with Paddle Inference library\n",
82
    "!CUDA_VISIBLE_DEVICES=0 python deploy/python/infer.py --model_dir=output_inference/ppyolo_r50vd_dcn_1x_coco --image_file=demo_input/000000014439.jpg --device=GPU --output_dir=demo_output"
W
wangxinxin08 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Model principle\n",
    "The overall archtecture of PP-YOLO is shown as follows:\n",
    "<div align=\"center\">\n",
    "  <img src=\"https://paddledet.bj.bcebos.com/modelcenter/images/PP-YOLO-Arch.png\" width=500 />\n",
    "</div>\n",
    "\n",
    "PP-YOLO improved performance and speed of YOLOv3 with following methods:\n",
    "\n",
    "- Better backbone: ResNet50vd-DCN\n",
    "- Larger training batch size: 8 GPUs and mini-batch size as 24 on each GPU\n",
    "- [Drop Block](https://arxiv.org/abs/1810.12890)\n",
    "- [Exponential Moving Average](https://www.investopedia.com/terms/e/ema.asp)\n",
    "- [IoU Loss](https://arxiv.org/pdf/1902.09630.pdf)\n",
    "- [Grid Sensitive](https://arxiv.org/abs/2004.10934)\n",
    "- [Matrix NMS](https://arxiv.org/pdf/2003.10152.pdf)\n",
    "- [CoordConv](https://arxiv.org/abs/1807.03247)\n",
    "- [Spatial Pyramid Pooling](https://arxiv.org/abs/1406.4729)\n",
    "\n",
    "For more details, please refer to our technical report:https://arxiv.org/abs/2007.12099"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. Attention\n",
    "**All commands run on AI Studio's `jupyter` by default. If running on a terminal, remove the % or ! at the beginning of the command.**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. Related papers and citations\n",
    "```\n",
    "@misc{long2020ppyolo,\n",
    "title={PP-YOLO: An Effective and Efficient Implementation of Object Detector},\n",
    "author={Xiang Long and Kaipeng Deng and Guanzhong Wang and Yang Zhang and Qingqing Dang and Yuan Gao and Hui Shen and Jianguo Ren and Shumin Han and Errui Ding and Shilei Wen},\n",
    "year={2020},\n",
    "eprint={2007.12099},\n",
    "archivePrefix={arXiv},\n",
    "primaryClass={cs.CV}\n",
    "}\n",
    "```"
   ]
  }
 ],
 "metadata": {
137 138 139 140 141
  "kernelspec": {
   "display_name": "Python 3.8.13 ('paddle_env')",
   "language": "python",
   "name": "python3"
  },
W
wangxinxin08 已提交
142
  "language_info": {
143 144 145 146 147 148 149 150 151 152
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
W
wangxinxin08 已提交
153
  },
154 155 156 157 158 159
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "864bc28e4d94d9c1c4bd0747e4313c0ab41718ab445ced17dbe1a405af5ecc64"
   }
  }
W
wangxinxin08 已提交
160 161 162 163
 },
 "nbformat": 4,
 "nbformat_minor": 2
}