davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.74k stars 4.8k forks source link

TypeError: true_fn and false_fn arguments to tf.cond must have the same number, type, and overall structure of return values #1228

Open thoongee opened 2 years ago

thoongee commented 2 years ago

Hi,

I am trying to validate on lfw dataset using pretrained model 20180402-114759. [https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw]

This is the run command that I use: python3 src/validate_on_lfw.py /home/sonic/datasets/lfw/lfw_mtcnnpy_160 /home/sonic/models/facenet/20180402-114759 --distance_metric 1 --use_flipped_images --subtract_mean --use_fixed_image_standardization

While I tried to run the test, error was issued.

`Traceback (most recent call last): File "src/validate_on_lfw.py", line 167, in main(parse_arguments(sys.argv[1:])) File "src/validate_on_lfw.py", line 71, in main image_batch, label_batch = facenet.create_input_pipeline(eval_input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder) File "/home/sonic/facenet/src/facenet.py", line 124, in create_input_pipeline image = tf.cond(get_control_flag(control[0], FIXED_STANDARDIZATION), File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1177, in cond return cond_v2.cond_v2(pred, true_fn, false_fn, name) File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/ops/cond_v2.py", line 94, in cond_v2 return _build_cond( File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/ops/cond_v2.py", line 221, in _build_cond _check_same_outputs(_COND, [true_graph, false_graph]) File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/ops/cond_v2.py", line 801, in _check_same_outputs error(b, "%s and %s have different types" % (b0_out, bn_out)) File "/home/sonic/venv/lib/python3.8/site-packages/tensorflow/python/ops/cond_v2.py", line 764, in error raise TypeError( TypeError: true_fn and false_fn arguments to tf.cond must have the same number, type, and overall structure of return values.

true_fn output: Tensor("truediv:0", shape=(160, 160, None), dtype=float32) false_fn output: Tensor("per_image_standardization/convert_image_1:0", shape=(160, 160, None), dtype=uint8)

Error details: Tensor("truediv:0", shape=(160, 160, None), dtype=float32) and Tensor("per_image_standardization/convert_image_1:0", shape=(160, 160, None), dtype=uint8) have different types`

I use Ubuntu 20.04, nvidia driver 510, cuda==11.6, cudnn==8.4.0, tensorflow & tensorflow-gpu==2.2.0, python==3.8.10.

What is the best way to resolve an issue like this? Many thanks in advance!