VGG Pool5 Feature Map特征提取

来源:互联网 发布:怎么查网络是否丢包 编辑:程序博客网 时间:2024/06/03 04:07

首先还是对tf不熟练,tensor的概念还是有不懂的?如果有新的收获会补充进来。
现在的版本是基于np的。
如有错误,还望各位指出;
vgg的网络结构不在此追述;
源码来自:
https://github.com/machrisaa/tensorflow-vgg

下面pool5特征提取的py代码:

import scipy.io as siofrom scipy.misc import imread,imresizeimport vgg16import tensorflow as tfimport utilsimport numpy as npsess=tf.Session()imgs=tf.placeholder(tf.float32, [None, 224, 224, 3])vgg=vgg16.Vgg16()vgg.build(imgs)img1 = utils.load_image("./test_data/tiger.jpeg")batch1 = img1.reshape((1, 224, 224, 3))feature=sess.run(vgg.pool5,feed_dict={imgs:batch1})feature = np.reshape(feature,[7,7,512])dic = {'features':feature}sio.savemat('G:/wgq/coin_project/'+'tiger'+'.mat',dic)

此代码借鉴了:
http://blog.csdn.net/weixin_38208741/article/details/78572342
中的代码。

阅读全文
0 0
原创粉丝点击