davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.81k stars 4.81k forks source link

Outputs of true_fn and false_fn must have the same type: float32, uint8 #1122

Open mohammadkhaleghy opened 4 years ago

mohammadkhaleghy commented 4 years ago

Hi Thanks for this awesome project I have a problem when I try to train the model I get this error

Traceback (most recent call last): File "src/train_softmax.py", line 582, in <module> main(parse_arguments(sys.argv[1:])) File "src/train_softmax.py", line 129, in main image_batch, label_batch = facenet.create_input_pipeline(input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder) File "/Users/mohammadkhaleghi/AI/facenet/src/facenet.py", line 122, in create_input_pipeline lambda:tf.image.per_image_standardization(image)) File "/opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/ops/control_flow_ops.py", line 1274, in cond "%s, %s" % (x.dtype.name, y.dtype.name)) ValueError: Outputs of true_fn and false_fn must have the same type: float32, uint8 any idea what can be problem?

CyruSun commented 4 years ago

Hello, same issue here.

pasa13142 commented 4 years ago

any solution ?

SangriaXinji commented 4 years ago

???

Galahhhad commented 4 years ago

could someone give a solution to this?

pasa13142 commented 4 years ago

pip install tensorflow-gpu==1.7 or 1.4 or 1.14

pohsienLiu commented 4 years ago

This error means that your image is uint8 format, So you neet to add

 image = tf.to_float(image)

in "facenet/src/facenet.py:121".

tongvantruong commented 4 years ago

pip install tensorflow-gpu==1.7

cannot run it with the error: ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==1.7 (from versions: none)

tongvantruong commented 4 years ago

same error here. I could not install tensorflow==1.7 or tensorflow-gpu==1.7. Error: Could not find a version that satisfies the requirement

tongvantruong commented 4 years ago

I managed to fix it by downgrading these:

  1. pip install tensorflow==1.13.0rc1
  2. pip install scipy==1.1.0 (optional)
  3. pip install numpy==1.16.1 (optional)
lijiale0073 commented 3 years ago

Hi Thanks for this awesome project I have a problem when I try to train the model I get this error

Traceback (most recent call last): File "src/train_softmax.py", line 582, in <module> main(parse_arguments(sys.argv[1:])) File "src/train_softmax.py", line 129, in main image_batch, label_batch = facenet.create_input_pipeline(input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder) File "/Users/mohammadkhaleghi/AI/facenet/src/facenet.py", line 122, in create_input_pipeline lambda:tf.image.per_image_standardization(image)) File "/opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/ops/control_flow_ops.py", line 1274, in cond "%s, %s" % (x.dtype.name, y.dtype.name)) ValueError: Outputs of true_fn and false_fn must have the same type: float32, uint8 any idea what can be problem?

lijiale0073 commented 3 years ago

you need change: image = tf.cond(get_control_flag(control[0], FIXED_STANDARDIZATION), lambda:(tf.cast(image, dtype=tf.float32) - 127.5)/128.0, lambda:tf.image.per_image_standardization(tf.cast(image, dtype=tf.float32))) in "facenet/src/facenet.py:122".

Luxe6 commented 2 years ago

you need change: image = tf.cond(get_control_flag(control[0], FIXED_STANDARDIZATION), lambda:(tf.cast(image, dtype=tf.float32) - 127.5)/128.0, lambda:tf.image.per_image_standardization(tf.cast(image, dtype=tf.float32))) in "facenet/src/facenet.py:122".

Incredibly correct