提交 59f2bddb 编写于 作者: T tink2123 提交者: dengkaipeng

update reademe

上级 c19a0f30
......@@ -30,6 +30,14 @@ The bone network of YOLOv3 is darknet53, the structure of YOLOv3 is as follow:
YOLOv3 structure
</p>
YOLOv3 networks are composed of base feature extraction network, multi-scale feature fusion layers, and output layers.
1. Feature extraction network: YOLOv3 ues [DarkNet53](https://arxiv.org/abs/1612.08242) for feature extracion,Darknet53 uses a full convolution structure, replacing the pooling layer with a convolution operation of step size 2, and adding Residual-block to avoid gradient dispersion when the number of network layers is too deep.
2. Feature fusion layer. In order to solve the problem that the previous YOLO version is not sensitive to small objects, YOLOv3 uses three different scale feature maps for target detection, which are 13*13, 26*26, 52*52, respectively, for detecting large, medium and small objects. The feature fusion layer selects the three scale feature maps produced by DarkNet as input, and draws on the idea of FPN (feature pyramid networks) to fuse the feature maps of each scale through a series of convolutional layers and upsampling.
3. Output layer: The output layer also uses a full convolution structure. The number of convolution kernels in the last convolutional layer is 255:3*(80+4+1)=255, and 3 indicates that a grid cell contains 3 bounding boxes. 4 represents the four coordinate information of the box, 1 represents the Confidence Score, and 80 represents the probability of 80 categories in the COCO dataset.
## Data preparation
Train the model on [MS-COCO dataset](http://cocodataset.org/#download), download dataset as below:
......@@ -74,10 +82,20 @@ To train the model, [cocoapi](https://github.com/cocodataset/cocoapi) is needed.
# not to install the COCO API into global site-packages
python2 setup.py install --user
**data reader introduction:**
* Data reader is defined in `reader.py` .
**model configuration:**
* The model uses 9 anchors generated based on the COCO dataset, which are (10x13), (16x30), (33x23), (30x61), (62x45), (59x119), (116x90), (156x198), (373x326).
* NMS threshold=0.7, NMS valid=0.1 nms_topk=400, nms_posk=100
**training strategy:**
* Use momentum optimizer with momentum=0.9.
* In first 4000 iteration, the learning rate increases linearly from 0.0 to 0.01. Then lr is decayed at 450000, 500000 iteration with multiplier 0.1, 0.01. The maximum iteration is 500000.
* In first 1000 iteration, the learning rate increases linearly from 0.0 to 0.01. Then lr is decayed at 450000, 500000 iteration with multiplier 0.1, 0.1. The maximum iteration is 500000.
Training result is shown as below:
<p align="center">
......@@ -122,3 +140,4 @@ Visualization of infer result is shown as below:
<img src="image/000000515077.jpg" height=300 width=400 hspace='10'/> <br />
YOLOv3 Visualization Examples
</p>
......@@ -24,13 +24,21 @@ YOLOv3检测原理
</p>
YOLOv3将输入图像分成S\*S个格子,每个格子预测B个bounding box,每个bounding box预测内容包括: Location(x, y, w, h)、Confidence Score和C个类别的概率,因此YOLOv3输出层的channel数为S\*S\*B\*(5 + C)。YOLOv3的loss函数也有三部分组成:坐标误差,IOU误差和分类误差。
YOLOv3的主干网络为darknet53,其网络结构如下图所示:
YOLOv3的网络结构如下图所示:
<p align="center">
<img src"image/YOLOv3_structure.jpg" height=400 width=400 hspace='10'/> <br />
YOLOv3网络结构
</p>
在darknet53的基础上通过三个尺度完成目标检测
YOLOv3 的网络结构由基础特征提取网络、multi-scale特征融合层和输出层组成。
1. 特征提取网络。YOLOv3使用 [DarkNet53](https://arxiv.org/abs/1612.08242)作为特征提取网络,DarkNet53 基本采用了全卷积网络,用步长为2的卷积操作替代了池化层,同时添加了 Residual 单元,避免在网络层数过深时发生梯度弥散。
2. 特征融合层。为了解决之前YOLO版本对小目标不敏感的问题,YOLOv3采用了3个不同尺度的特征图来进行目标检测,分别为13*13,26*26,52*52,用来检测大、中、小三种目标。特征融合层选取 DarkNet 产出的三种尺度特征图作为输入,借鉴了FPN(feature pyramid networks)的思想,通过一系列的卷积层和上采样对各尺度的特征图进行融合。
3. 输出层。同样使用了全卷积结构,其中最后一个卷积层的卷积核个数是255:3*(80+4+1)=255,3表示一个grid cell包含3个bounding box,4表示框的4个坐标信息,1表示Confidence Score,80表示COCO数据集中80个类别的概率。
## 数据准备
......@@ -39,6 +47,7 @@ YOLOv3网络结构
cd dataset/coco
./download.sh
## 模型训练
数据准备完毕后,可以通过如下的方式启动训练:
......@@ -53,7 +62,7 @@ YOLOv3网络结构
python train.py --help
**下载预训练模型:** 本示例提供darknet53预训练模型,该模转换自作者提供的darknet53在ImageNet上预训练的权重,采用如下命令下载预训练模型:
**下载预训练模型:** 本示例提供darknet53预训练模型,该模转换自作者提供的darknet53在ImageNet上预训练的权重,采用如下命令下载预训练模型:
sh ./weights/download_pretrained_weight.sh
......@@ -75,10 +84,19 @@ YOLOv3网络结构
# not to install the COCO API into global site-packages
python2 setup.py install --user
**数据读取器说明:**
* 数据读取器定义在reader.py中。
**模型设置:**
* 模型使用了基于COCO数据集生成的9个先验框:(10x13),(16x30),(33x23),(30x61),(62x45),(59x119),(116x90),(156x198),(373x326)
* 检测过程中,nms_topk=400, nms_posk=100,nms_thresh=0.4
**训练策略:**
* 采用momentum优化算法训练YOLOv3,momentum=0.9。
* 学习率采用warmup算法,前4000轮学习率从0.0线性增加至0.01。在400000,450000轮时使用0.1,0.01乘子进行学习率衰减,最大训练500000轮。
* 学习率采用warmup算法,前1000轮学习率从0.0线性增加至0.01。在400000,450000轮时使用0.1,0.1乘子进行学习率衰减,最大训练500000轮。
## 模型评估
......@@ -119,3 +137,4 @@ YOLOv3
<img src="image/000000515077.jpg" height=300 width=400 hspace='10'/> <br />
YOLOv3 预测可视化
</p>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册