VGG convolution neural network model to resolve

  VGG convolution neural network model to resolve

  A: VGG Introduction to Model

  VGG stands for Visual Geometry Group belongs to the Department of Science at Oxford University, which released a series of convolutions network model at the beginning of VGG, it can be applied to face recognition, image classification, etc., respectively, from VGG16 ~ VGG19. Convolution depth research network VGG mind is trying to figure out how to network convolution depth the impact of large-scale image classification and identification of precision and accuracy, initially VGG-16 is known as a very deep network called the convolution (GG-Very -Deep-16 CNN), VGG while in deeper layers of the network in order to avoid too many parameters in all layers using a small 3x3 convolution kernel, the convolution step is set to level 1. VGG input is set to 224x244 RGB image size, the image in the training set for all the RGB image calculating mean, and then passed as input image convolutional networks VGG, using a 1x1 or 3x3 filter, the convolution step 1 is fixed . VGG layer 3 fully connected layer, from VGG11 ~ VGG19, VGG11 least 8 convolution with three layers fully connected layers depending convolutional layer + the total number of full-connection layer, most convolution 16 layers VGG19 +3 fully connected layers, in addition networks VGG not keep up with a layer behind each convolution pooled layer, or the total number of five cell layers, distribution layers under different convolution, the lower figure is VGG11 ~ GVV19 the structure diagram:

  

VGG convolution neural network model to resolve

 

  Considering the structure of the entire network streamline display, ReLU activation function and is not displayed in the above structure. Some structures described above:

  conv denotes convolution layer

  FC represents the whole connection layer

  conv3 layer represents the convolution using 3x3 filters

  64 represents the depth conv3-64

  maxpool represents the largest pool of

  Total VGG11 ~ VGG19 above parameters are listed below:

  

VGG convolution neural network model to resolve

 

  在实际处理中还可以对第一个全连接层改为7x7的卷积网络,后面两个全连接层改为1x1的卷积网络,这个整个VGG就变成一个全卷积网络FCN。在VGG网络之前,卷积神经网络CNN很少有突破10层的,VGG在加深CNN网络深度方面首先做出了贡献,但是VGG也有自身的局限性,不能无限制的加深网络,在网络加深到一定层数之后就会出现训练效果褪化、梯度消逝或者梯度爆炸等问题,总的来说VGG在刚提出的时候也是风靡一时,在ImageNet竞赛数据集上都取得了不错的效果

  

VGG convolution neural network model to resolve

 

  在其他类似数据上同样表现不俗:

  

VGG convolution neural network model to resolve

 

  二:预训练模型使用(Caffe)

  VGG本身提供了预训练模型供大家可以自由使用,预训练的VGG-16模型与VGG-19模型下载地址可以在这里发现:

  http://www.robots.ox.ac.uk/~vgg/research/very_deep/

  下载VGG-16模型之后使用OpenCV DNN模块相关API,就可以实现一个图像分类器,支持1000种图像分类,基于ImageNet 2014-ILSVRC数据集训练。原图:

  

VGG convolution neural network model to resolve

 

  VGG-16预测分类结果:

  

VGG convolution neural network model to resolve

 

  稍微有点尴尬的是,OpenCL初始化内存不够了,只能说我的机器不给力:

  

VGG convolution neural network model to resolve

 

  演示网络加载与图像分类的OpenCV程序代码如下:  郑州不孕不育医院:http://yyk.39.net/zz3/zonghe/1d427.html/郑州不孕不育医院哪家好:http://yyk.39.net/zz3/zonghe/1d427.html/郑州不孕不育医院排名:http://yyk.39.net/zz3/zonghe/1d427.html/

  Net net = readNetFromCaffe(model_txt_file, model_bin_file);

  if (net.empty()) {

  printf("read caffe model data failure...\n");

  return -1;

  }

  Mat inputBlob = blobFromImage(src, 1.0, Size(w, h), Scalar(104, 117, 123));

  Mat prob;

  for (int i = 0; i < 10; i++) {

  net.setInput(inputBlob, "data");

  prob = net.forward("prob");

  }

  Mat probMat = prob.reshape(1, 1);

  Point classNumber;

  double classProb;

  minMaxLoc(probMat, NULL, &classProb, NULL, &classNumber);

  int classidx = classNumber.x;

  printf("\n current image classification : %s, possible : %.2f", labels.at(classidx).c_str(), classProb);

  putText(src, labels.at(classidx), Point(20, 20), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 255), 2, 8);

  imshow("Image Classification", src);

Guess you like

Origin www.cnblogs.com/sushine1/p/11369353.html