facenet icon indicating copy to clipboard operation
facenet copied to clipboard

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

Open mohammadkhaleghy opened this issue 5 years ago • 12 comments

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?

mohammadkhaleghy avatar Dec 16 '19 23:12 mohammadkhaleghy

Hello, same issue here.

CyruSun avatar Dec 17 '19 13:12 CyruSun

any solution ?

pasa13142 avatar Jan 06 '20 17:01 pasa13142

???

SangriaXinji avatar Jan 08 '20 09:01 SangriaXinji

could someone give a solution to this?

Galahhhad avatar Jan 08 '20 14:01 Galahhhad

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

pasa13142 avatar Jan 27 '20 08:01 pasa13142

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".

pohsienLiu avatar Mar 06 '20 10:03 pohsienLiu

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 avatar Apr 01 '20 03:04 tongvantruong

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 avatar Apr 01 '20 03:04 tongvantruong

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)

tongvantruong avatar Apr 01 '20 04:04 tongvantruong

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 avatar May 07 '21 02:05 lijiale0073

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".

lijiale0073 avatar May 07 '21 02:05 lijiale0073

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

Luxe6 avatar Oct 19 '22 14:10 Luxe6