introduction_cn.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. 模型简介\n",
    "[PP-YOLO](https://arxiv.org/abs/2007.12099)是PaddleDetection优化和改进的YOLOv3的模型,其精度(COCO数据集mAP)和推理速度均优于[YOLOv4](https://arxiv.org/abs/2004.10934)模型。关于PP-YOLO的更多细节可以参考[官方文档](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.5/configs/ppyolo/README_cn.md)。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 模型效果\n",
    "PP-YOLO在[COCO](http://cocodataset.org) test-dev2017数据集上精度达到45.9%,在单卡V100上FP32推理速度为72.9 FPS, V100上开启TensorRT下FP16推理速度为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. 模型如何使用\n",
    "首先克隆PaddleDetection,并将数据集存放在`dataset/coco/`目录下面"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
34
   "metadata": {},
W
wangxinxin08 已提交
35 36
   "outputs": [],
   "source": [
37 38 39 40 41 42
    "# 克隆PaddleDetection仓库\n",
    "%mkdir -p ~/work\n",
    "%cd ~/work/\n",
    "!git clone https://github.com/PaddlePaddle/PaddleDetection.git\n",
    "\n",
    "# 安装其他依赖\n",
43
    "%cd PaddleDetection\n",
44
    "%mkdir -p demo_input demo_output\n",
45
    "!pip install -r requirements.txt"
W
wangxinxin08 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1 训练\n",
    "使用8GPU通过如下命令一键式启动训练(以下命令均默认在PaddleDetection根目录运行), 通过`--eval`参数开启训练中交替评估。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
59
   "metadata": {},
W
wangxinxin08 已提交
60 61
   "outputs": [],
   "source": [
62
    "!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 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 推理部署\n",
    "PP-YOLO模型部署及推理benchmark需要通过`tools/export_model.py`导出模型后使用Paddle预测库进行部署和推理,可通过如下命令一键式启动。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
76
   "metadata": {},
W
wangxinxin08 已提交
77 78 79 80 81 82
   "outputs": [],
   "source": [
    "# 导出模型,默认存储于output/ppyolo目录\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",
    "\n",
    "# 预测库推理\n",
83 84
    "!wget -P demo_input -N https://paddledet.bj.bcebos.com/modelcenter/images/General/000000014439.jpg\n",
    "!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 已提交
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 137 138
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 模型原理\n",
    "PP-YOLO的整体结构图如下图所示:\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从如下方面优化和提升YOLOv3模型的精度和速度:\n",
    "\n",
    "- 更优的骨干网络: ResNet50vd-DCN\n",
    "- 更大的训练batch size: 8 GPUs,每GPU batch_size=24,对应调整学习率和迭代轮数\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",
    "更多细节可以参考我们的技术报告:https://arxiv.org/abs/2007.12099"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. 注意事项\n",
    "**所有的命令默认运行在AI Studio的`jupyter`上, 如果运行在终端上,去掉命令开头的符号%或!**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. 相关论文及引用信息\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": {
139 140 141 142 143
  "kernelspec": {
   "display_name": "Python 3.10.6 64-bit",
   "language": "python",
   "name": "python3"
  },
W
wangxinxin08 已提交
144
  "language_info": {
145 146 147 148 149 150 151 152 153 154
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
W
wangxinxin08 已提交
155
  },
156 157 158 159 160 161
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
   }
  }
W
wangxinxin08 已提交
162 163 164 165
 },
 "nbformat": 4,
 "nbformat_minor": 2
}