yinguobing / cnn-facial-landmark

Training code for facial landmark detection based on deep convolutional neural network.
MIT License
623 stars 183 forks source link

test.py #97

Open waquey opened 4 years ago

waquey commented 4 years ago

Is there any test code we can try to inference?

After training, I've tried to assign placeholder and inference.

However, it'll get the following errors:

tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value layer2/conv2d/kernel [[node layer2/conv2d/kernel/read (defined at test.py:967) ]]

===================== Code ========================= input_name ='image_tensor'

t_input = tf.compat.v1.placeholder(
    shape=[1, 128, 128, 3], dtype=tf.float32,
    name=input_name)

saver = tf.compat.v1.train.import_meta_graph(input_checkpoint + '.meta', 
                           clear_devices=True,
                           input_map={'Cast:0': t_input})
graph = tf.compat.v1.get_default_graph()
input_operation = graph.get_operation_by_name(input_name)

## define output node 
output_name = 'layer5/final_dense'
output_operation = graph.get_operation_by_name(output_name)

.... assign 1 image as cropped_ims, which is 1x128x128x3 ... 

with tf.compat.v1.Session(graph=graph) as sess: ONet_point_results = sess.run([ output_operation.outputs[0] ], {input_operation.outputs[0]: cropped_ims})

yinguobing commented 4 years ago

I have not figure out how to write a proper test code. For now you need to export the model for inference.

zhouqianyu0918 commented 3 years ago

您好,我想请问一下,我使用新的数据集训练网络,那么训练完成后怎么对它进行测试呢?请问有测试的代码吗?

yinguobing commented 3 years ago

@zhouqianyu0918 先实现推演,这是测试的基础。至于测试,它需要有明确的测试数据,测试指标等等。可以尝试在论文里找找通用的测试协议。