VGG Face测试的Python版本
来源:互联网 发布:巴洛克的艺术风格 知乎 编辑:程序博客网 时间:2024/06/06 01:38
本人想测试VGG Face Descriptor提供的人脸识别的Caffe版本,官方提供了Matlab版本的测试用例,但是配置了很长时间的Matlab接口一直失败。其中Matlab测试程序为,
% Copyright (c) 2015, Omkar M. Parkhi% All rights reserved.img = imread('ak.png');img = single(img);averageImg = [129.1863,104.7624,93.5940] ;img = cat(3,img(:,:,1)-averageImg(1),... img(:,:,2)-averageImg(2),... img(:,:,3)-averageImg(3));img = img(:, :, [3, 2, 1]); % convert from RGB to BGRimg = permute(img, [2, 1, 3]); % permute width and heightmodel = 'VGG_FACE_16_deploy.prototxt';weights = 'VGG_FACE.caffemodel';caffe.set_mode_cpu();net = caffe.Net(model, weights, 'test'); % create net and load weightsres = net.forward({img});prob = res{1};caffe_ft = net.blobs('fc7').get_data();
于是参考网络上的例子,加上自己的修改完成了下面的Python版本测试用例,
import numpy as npimport cv2 import caffeimg = caffe.io.load_image( "ak.png" )img = img[:,:,::-1]*255.0 # convert RGB->BGRavg = np.array([129.1863,104.7624,93.5940])img = img - avg # subtract mean (numpy takes care of dimensions :)img = img.transpose((2,0,1)) img = img[None,:] # add singleton dimensionnet = caffe.Net("VGG_FACE_deploy.prototxt","VGG_FACE.caffemodel", caffe.TEST) #load netout = net.forward_all( data = img ) # out is probabilitylabels=np.loadtxt('names.txt',str,delimiter='\n') # get the nameprint labels[out['prob'].argmax()]
最终的输出就是Aamir_Khan
阅读全文
0 0
- VGG Face测试的Python版本
- 基于VGG-Face的人脸识别测试
- VGG-Face:Deep Face Recognition 笔记
- [人脸识别]使用VGG Face Model对一张图片进行测试
- deep learning---利用caffe在vgg-face上finetuing自己的人脸数据
- deep learning---利用caffe在vgg-face上finetuing自己的人脸数据
- 利用caffe在vgg-face上finetuing自己的人脸数据
- [人脸识别]使用VGG Face Model微调(Fine tune)自己的数据集
- deep learning---利用caffe在vgg-face上finetuing自己的人脸数据
- 【TensorFlow-windows】(七) CNN之VGG-net的测试
- 深度学习 VGG 网络 实现 face landmark 与 head pose
- Deep Learning学习 - VGG-Face网络人脸识别
- python基于dlib的face landmarks
- python基于dlib的face landmarks
- [x]Face++的Python SDK学习
- VGG
- VGG
- VGG
- 设置模式(3)——策略模式
- Java实现折半插入排序
- SVN 安装部署并设置为自动同步到实际的项目
- 数据结构跑路篇——冒泡排序
- UDP简单例子
- VGG Face测试的Python版本
- 动态顺序表
- 一、python环境搭建
- Python+Selenium注册登录各个功能流程验证脚本
- HTTP method POST is not supported by this URL错误的解决方案
- 配置单臂路由器
- J
- linux下PPTP Server测试环境搭建
- 从文件存取字典,涉及到几个内置函数,对格式的控制