peteryuX / retinaface-tf2

RetinaFace (Single-stage Dense Face Localisation in the Wild, 2019) implemented (ResNet50, MobileNetV2 trained on single GPU) in Tensorflow 2.0+. This is an unofficial implementation. With Colab.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error Test.py on one image

EsrtG opened this issue · comments

commented

Hi,

Thank you for your repo retinaface.
I have some trouble to use your implementation (my configuration : Python 3.7 / Tensorflow 2.4 - CPU).
I simply wanted to infer RetinaFace with your pretrained weights.
When I use the command line
python test.py --cfg_path="./configs/retinaface_res50.yaml" --img_path=MYIMAGEPATH --down_scale_factor=1.0
I got this error :
tensorflow.python.framework.errors_impl.InvalidArgumentError: ConcatOp : Dimensions of inputs should match: shape[0] = [45056,2] vs. shape[1] = [22528,2] [Op:ConcatV2] name: concat

Do you have any idea what may cause this error?

Thank you in advance

Same issue here. This is the error I get with mobilenetV2 backend.

status = self.read(save_path, options=options)
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/tracking/util.py", line 2148, in read
      return self._saver.restore(save_path=save_path, options=options)
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/tracking/util.py", line 1336, in restore
      base.CheckpointPosition(
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 253, in restore
      restore_ops = trackable._restore_from_checkpoint_position(self)  # pylint: disable=protected-access
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 972, in _restore_from_checkpoint_position
      current_position.checkpoint.restore_saveables(
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/tracking/util.py", line 307, in restore_saveables
      new_restore_ops = functional_saver.MultiDeviceSaver(
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/saving/functional_saver.py", line 345, in restore
      restore_ops = restore_fn()
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/saving/functional_saver.py", line 321, in restore_fn
      restore_ops.update(saver.restore(file_prefix, options))
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/saving/functional_saver.py", line 115, in restore
      restore_ops[saveable.name] = saveable.restore(
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 131, in restore
      return resource_variable_ops.shape_safe_assign_variable_handle(
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 307, in shape_safe_assign_variable_handle
      shape.assert_is_compatible_with(value_tensor.shape)
    File "/Users/harshithdwivedi/.pyenv/versions/tf_macos_orig/lib/python3.8/site-packages/tensorflow/python/framework/tensor_shape.py", line 1134, in assert_is_compatible_with
      raise ValueError("Shapes %s and %s are incompatible" % (self, other))
  ValueError: Shapes (1, 1, 192, 64) and (1, 1, 32, 64) are incompatible

It will work at tensorflow-gpu==2.1.0.

pip install tensorflow-gpu==2.1.0

meet the same issue that can not work with mobilenet_v2

(env-tf2.1) gnar@ubuntu:~/python/retinaface-tf2$ python test.py --cfg_path="./configs/retinaface_mbv2.yaml" --img_path="./data/0_Parade_marchingband_1_149.jpg" --down_scale_factor=1.0
Traceback (most recent call last):
File "test.py", line 130, in
app.run(main)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "test.py", line 44, in main
checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/util.py", line 2260, in restore
status = self.read(save_path, options=options)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/util.py", line 2148, in read
return self._saver.restore(save_path=save_path, options=options)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/util.py", line 1337, in restore
checkpoint=checkpoint, proto_id=0).restore(self._graph_view.root)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py", line 253, in restore
restore_ops = trackable._restore_from_checkpoint_position(self) # pylint: disable=protected-access
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py", line 973, in _restore_from_checkpoint_position
tensor_saveables, python_saveables))
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/tracking/util.py", line 308, in restore_saveables
validated_saveables).restore(self.save_path_tensor, self.options)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/saving/functional_saver.py", line 345, in restore
restore_ops = restore_fn()
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/saving/functional_saver.py", line 321, in restore_fn
restore_ops.update(saver.restore(file_prefix, options))
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/saving/functional_saver.py", line 116, in restore
restored_tensors, restored_shapes=None)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 132, in restore
self.handle_op, self._var_shape, restored_tensor)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 307, in shape_safe_assign_variable_handle
shape.assert_is_compatible_with(value_tensor.shape)
File "/home/gnar/Documents/env-tf2.1/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py", line 1134, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (1, 1, 192, 64) and (1, 1, 32, 64) are incompatible

I get same issue in MobileNetV2

Shapes (1, 1, 192, 64) and (1, 1, 32, 64) are incompatible

I get same issue in MobileNetV2

Shapes (1, 1, 192, 64) and (1, 1, 32, 64) are incompatible

Please ensure the model file is trained/saved and loaded with the same version of TensorFlow.

pip install tensorflow-gpu==2.1.0
ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==2.1.0
ERROR: No matching distribution found for tensorflow-gpu==2.1.0

In Ubuntu, is this repo is Windows only?

Dear all,

I got the same error: Shapes (1, 1, 192, 64) and (1, 1, 32, 64) are incompatible

I need to check if it is due to tensorflow version incomapatibility , and since working on colab should we reproduce training to get checkpoint compatible version?

Thanks for help