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.
MIT License
272 stars 97 forks source link

Error while running on tf2.4 #26

Open harshithdwivedi opened 3 years ago

harshithdwivedi commented 3 years ago

On running the pretrained mobilenet model on tf2.4; I get the following error:


  14:45:53.439 > Traceback (most recent call last):
    File "main.py", line 19, in <module>
    File "_aftershoot.py", line 217, in _aftershoot.run_inference
    File "_aftershoot.py", line 60, in _aftershoot.init_jpegs
    File "raw_handler\img_init.py", line 31, in init raw_handler.img_init
    File "ml_modules\face_detector\FaceDetector.py", line 120, in ml_modules.face_detector.FaceDetector.BatchFaceDetector.__init__
    File "tensorflow\python\training\tracking\util.py", line 2118, in restore
    File "tensorflow\python\training\tracking\util.py", line 2035, in read
    File "tensorflow\python\training\tracking\util.py", line 1320, in restore
    File "tensorflow\python\training\tracking\base.py", line 209, in restore
    File "tensorflow\python\training\tracking\base.py", line 914, in _restore_from_checkpoint_position
    File "tensorflow\python\training\tracking\util.py", line 297, in restore_saveables
    File "tensorflow\python\training\saving\functional_saver.py", line 340, in restore
    File "tensorflow\python\training\saving\functional_saver.py", line 316, in restore_fn        
    File "tensorflow\python\training\saving\functional_saver.py", line 111, in restore
    File "tensorflow\python\training\saving\saveable_object_util.py", line 127, in restore       
    File "tensorflow\python\ops\resource_variable_ops.py", line 311, in shape_safe_assign_variable_handle
    File "tensorflow\python\framework\tensor_shape.py", line 1134, in assert_is_compatible_with  
  ValueError: Shapes (7, 7, 3, 64) and (3, 3, 3, 32) are incompatible

┗ ----------------------------
┏ Electron -------------------

  14:45:53.548 > Sentry is attempting to send 0 pending error messages
  Waiting up to 2 seconds
  Press Ctrl-Break to quit

┗ ----------------------------
┏ Electron -------------------

  14:45:55.347 > close: false

However, the resnet50 model works without any issues.

Any ideas as to what can be done to get the mobilenet model running on Tensorflow 2.4?

@peteryuX

nospotfer commented 3 years ago

I'm having the same issue. Trying to update to TF >= 2.4.0. Have you found a workaround for this?

xsacha commented 3 years ago

Also getting the same error here when testing this repository.

HarikiranCherala commented 2 years ago

Try converting it to saved model format after loading the checkpoint. Then load the saved model with tf >= 2.4.0 and try running.