我已经训练了一个基于Inception的网络来学习新课程 . 输入张量的形状[无,2048] ...我的测试输入图像是使用照片展位mac app拍摄的,其像素尺寸为480 x 720 .

如何输入新图像以获得新图像的预测?

这是我的测试设置:

import argparse
import tensorflow as tf
import utils
from PIL import Image

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--pb_file", required=True, type=str, help="Frozen model file to import")
    parser.add_argument("--img_path", required=True, type=str, help="Path to image for input to model")
    args = parser.parse_args()

    graph = utils.load_graph(args.pb_file)

    for op in graph.get_operations():
        print(op.name + '\t' + str(op.values()))

    x = graph.get_tensor_by_name('input_ph:0')
    y = graph.get_tensor_by_name('FC_layers_1/FC_4/Softmax:0')

    with tf.Session(graph=graph) as sess:
        feed_dict = {x: Image.open(args.img_path)}
        y_out = sess.run(y, feed_dict=feed_dict)
        print(y_out)

--pb_file argment用于最终的冻结模型
--img_path 是我试图输入训练模型的图像
input_ph:0 是输入占位符
我希望 FC_layers_1/FC_4/Softmax:0 softmax输出