OpenCV + TensorFlow面部Landmark识别python 3.7到3.9报错

Python + OpenCV + TensorFlow视频面部标记点显示_Sinfinder的博客-CSDN博客

上述代码在python 3.7环境下正常运行(虽然有WARNING)

但当在python 3.9下运行报错如下:

WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), *NOT* tf.saved_model.save(). To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory.
Traceback (most recent call last):
  File "/Users/sunchenglong/PycharmProjects/FRCTRe/test.py", line 178, in
    landmark_model = get_landmark_model()
  File "/Users/sunchenglong/PycharmProjects/FRCTRe/test.py", line 69, in get_landmark_model
    model = keras.models.load_model(saved_model)
  File "/Users/sunchenglong/opt/anaconda3/envs/FRcam_CTRcon/lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/Users/sunchenglong/opt/anaconda3/envs/FRcam_CTRcon/lib/python3.9/site-packages/keras/saving/saved_model/load.py", line 227, in _generate_object_paths
    for reference in object_graph_def.nodes[current_node].children:
IndexError: list index (0) out of range

参考:

eye_tracker: IndexError: list index (0) out of range. · Issue #34 · vardanagarwal/Proctoring-AI · GitHub

修改 line 71

#model = keras.models.load_model(saved_model)
model = tf.saved_model.load(saved_model)

可正常运行。

你可能感兴趣的:(OpenCV + TensorFlow面部Landmark识别python 3.7到3.9报错)