2017-05-23 3 views
0

10 이미지를 배치 크기로 테스트하고 출력으로 특정 영역의 분할을 얻으려고합니다. 여기에 내가 모델tensorflow 모델에서 이미지 테스트

def run(model_path, image_path,graph_path ,output_path): 
with tf.Session() as sess: 
    model_saver = tf.train.import_meta_graph(graph_path, clear_devices=True) 
    model_saver.restore(sess,tf.train.latest_checkpoint(LOGDIR)) 
    sess.run(tf.global_variables_initializer()) 
    graph = tf.get_default_graph() 
    x=tf.placeholder(tf.float32,shape=[10, 400, 600, 3]) 
    output = graph.get_tensor_by_name("prediction:0") 
    print("Model restored.") 
    print('Initialized') 
    temp=[] 
    import glob 
    from scipy import misc 
    for file in os.listdir(image_path): 
    if file.endswith(".jpg"): 
     img = misc.imread(image_path + file) 
     img = img.astype('Float32') 
     img = np.resize(img,(400,600,3)) 
     temp.append(img) 
    prediction = sess.run(output, feed_dict={x:temp}) 
    cv2.imwrite(output_path, prediction * 255) 

를로드하는 데 사용하고 코드는하지만 다음과 같은 오류가 발생합니다 :

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'x' with dtype float and shape [10,400,600,3] 
    [[Node: x = Placeholder[dtype=DT_FLOAT, shape=[10,400,600,3], _device="/job:localhost/replica:0/task:0/gpu:0"]()]] 
    [[Node: prediction/_265 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_28_prediction", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]] 

사람이 버그가 나 있었다 알고 있습니까 모델을 테스트하는 또 다른 방법이있는 경우 .

+0

여기에 x를 다시 정의하고 있다고 생각합니다. 대신 이름으로 피드하십시오. 따라서 x = placeholder() 줄을 제거하고 { 'x : 0': temp}를 피드 dict로 사용하여 어떤 일이 발생하는지 알려주세요. –

+0

@AlWld 고마워요! –

+0

청중을 기쁘게 해드 리고 대답으로 추가하십시오. 해결했다고 표시 할 수 있다면 좋을 것입니다. 고맙습니다. –

답변

0

여기에 x를 다시 정의한다고 생각합니다. 대신 이름으로 피드하십시오. 그래서 x = placeholder() 줄을 제거하고 { 'x : 0': temp}를 피드 dict로 사용하십시오.

관련 문제