from tensorflow.python.platform import gfile
image_data = gfile.FastGFile("E:\\TensorFlowpicture\\picture\\datasets\\0\\+¿+F2_0 - 副本 - 副本.jpg", 'rb').read()
import os
MODEL_DIR = 'E:\\TensorFlowpicture\\picture\\inception_dec_2015'
MODEL_FILE= 'tensorflow_inception_graph.pb'
BOTTLENECK_TENSOR_NAME = 'pool_3/_reshape:0'
JPEG_DATA_TENSOR_NAME = 'DecodeJpeg/contents:0'
import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
with gfile.FastGFile(os.path.join(MODEL_DIR, MODEL_FILE), 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
bottleneck_tensor, jpeg_data_tensor = tf.import_graph_def(
graph_def, return_elements=[BOTTLENECK_TENSOR_NAME, JPEG_DATA_TENSOR_NAME])
bottleneck_values=sess.run(bottleneck_tensor,{jpeg_data_tensor:image_data})
bottleneck_string=','.join(str(x) for x in bottleneck_tensor)
读取特征向量
最新推荐文章于 2024-01-13 02:39:16 发布