RCNN介绍
RCNN(Regions with CNN features)是将CNN方法应用到目标检测问题上,由年轻有为的RBG大神提出,借助CNN良好的特征提取和分类性能,通过RegionProposal方法实现目标检测问题的转化。
算法分为三步:
1)候选区域选择,根据提取的目标图像进行归一化,作为CNN的标准输入。
2)CNN特征提取,标准的CNN过程就是根据输入进行卷积/池化等操作,得到固定维度的输出
3)分类与边界回归,包含两个子步骤,一是对上一步的输出向量进行分类(需要根据特征训练分类器),二是通过边界回归得到精准的目标区域。
Fast-RCNN
Faster RCNN是一个目标检测模型,将特征提取、候选框提取、bounding box回归、分类集成在了一个网络中,使得检测速度和精度有所提升。
Fast-RCNN主要贡献就是在于对RCNN进行加速,在以下方面得到改进:
1)借鉴SPP思路,提出了简化版的ROI池化层,同时加入了候选框映射功能,使得网络能够反向传播,解决了SPP的整体网络训练问题。
2)多任务的loss层
21)softmaxloss代替了SVM,证明了softmax比SVM有更好的效果。
22)smoothloss取代了boudingbox回归
将分类和边框回归进行合并,通过多任务loss层进一步整合深度网络,统一了训练过程,提高了算法的准确性。
3)全连接层通过SVD加速
4)结合上面的改进,模型训练时可对所有层进行更新,除了速度提升外(训练速度是SPP的3倍,测试速度10倍),得到了更好的检测效果(VOCO7数据集mAP为70,mAP,是目标检测中衡量识别精度的指标,多个类别目标检测中,每个类别都可以根据召回率和准确率绘制一条曲线,AP就是该曲线下的面积,mAP意思是对每一类的AP再求平均。)
这里使用了paddlepaddle中的PaddleX进行Faster RCNN,所以先安装PaddelX
安装paddlex,地址是https://mirror.baidu.com/pypi/simple,地址下面是有下划线的
! pip install paddlex -i https://mirror.baidu.com/pypi/simple
Looking in indexes: https://mirror.baidu.com/pypi/simple Collecting paddlex Downloading https://mirror.baidu.com/pypi/packages/d6/e3/da77d8ef8c08d190199e02ba6296ead5f92ea556f0785c3bd27dce7cc28f/paddlex-0.1.4-py3-none-any.whl (190kB) |████████████████████████████████| 194kB 10.9MB/s eta 0:00:01 Collecting pycocotools (from paddlex) Downloading https://mirror.baidu.com/pypi/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz (1.5MB) |████████████████████████████████| 1.5MB 20.0MB/s eta 0:00:01 Collecting colorama (from paddlex) Downloading https://mirror.baidu.com/pypi/packages/c9/dc/45cdef1b4d119eb96316b3117e6d5708a08029992b2fee2c143c7a0a5cc5/colorama-0.4.3-py2.py3-none-any.whl Requirement already satisfied: tqdm in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlex) (4.36.1) Collecting paddleslim==1.0.1 (from paddlex) Downloading https://mirror.baidu.com/pypi/packages/69/3c/880afac020e3393da5a55b4e0b504d2b644a7ebe91092d953185f09660d1/paddleslim-1.0.1-py2.py3-none-any.whl (103kB) |████████████████████████████████| 112kB 12.5MB/s eta 0:00:01 Requirement already satisfied: pyyaml in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlex) (5.1.2) Requirement already satisfied: visualdl==1.3.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlex) (1.3.0) Collecting paddlehub>=1.6.2 (from paddlex) Downloading https://mirror.baidu.com/pypi/packages/6e/07/d4839d63853c01d2f9d040ff079e63e007c9e4084e74f447baf46b426811/paddlehub-1.6.2-py3-none-any.whl (207kB) |████████████████████████████████| 215kB 22.6MB/s eta 0:00:01 Requirement already satisfied: Flask in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl==1.3.0->paddlex) (1.1.1) Requirement already satisfied: numpy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl==1.3.0->paddlex) (1.16.4) Requirement already satisfied: protobuf>=3.1.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl==1.3.0->paddlex) (3.10.0) Requirement already satisfied: Pillow in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl==1.3.0->paddlex) (6.2.0) Requirement already satisfied: scipy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl==1.3.0->paddlex) (1.3.0) Requirement already satisfied: opencv-python in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (4.1.1.26) Requirement already satisfied: cma==2.7.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (2.7.0) Requirement already satisfied: gunicorn>=19.10.0; sys_platform != "win32" in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (20.0.4) Requirement already satisfied: chardet==3.0.4 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (3.0.4) Requirement already satisfied: colorlog in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (4.1.0) Requirement already satisfied: tensorboard>=1.15 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (2.1.0) Requirement already satisfied: pre-commit in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (1.21.0) Requirement already satisfied: six>=1.10.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (1.12.0) Requirement already satisfied: tb-paddle in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (0.3.6) Requirement already satisfied: yapf==0.26.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (0.26.0) Requirement already satisfied: pandas; python_version >= "3" in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (0.23.4) Requirement already satisfied: sentencepiece in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (0.1.85) Requirement already satisfied: requests in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (2.22.0) Requirement already satisfied: nltk in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (3.4.5) Requirement already satisfied: flake8 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlehub>=1.6.2->paddlex) (3.7.9) Requirement already satisfied: click>=5.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->visualdl==1.3.0->paddlex) (7.0) Requirement already satisfied: itsdangerous>=0.24 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->visualdl==1.3.0->paddlex) (1.1.0) Requ