尝试为我正在处理的项目运行 deepface 代码时出现导入错误
Traceback (most recent call last):
File "face.py", line 3, in <module>
from deepface import DeepFace
File "/home/pi/.local/lib/python3.7/site-packages/deepface/DeepFace.py", line 15, in <module>
from deepface.basemodels import VGGFace, OpenFace, Facenet, Facenet512, FbDeepFace, DeepID, DlibWrapper, ArcFace, Boosting
File "/home/pi/.local/lib/python3.7/site-packages/deepface/basemodels/VGGFace.py", line 9, in <module>
from keras.models import Model, Sequential
File "/home/pi/.local/lib/python3.7/site-packages/keras/__init__.py", line 25, in <module>
from keras import models
File "/home/pi/.local/lib/python3.7/site-packages/keras/models.py", line 19, in <module>
from keras import backend
File "/home/pi/.local/lib/python3.7/site-packages/keras/backend.py", line 36, in <module>
from tensorflow.python.eager.context import get_config
ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' (/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py)
这是我的代码
import cv2
from deepface import DeepFace
img1 = "simg.jpb"
img2 = "simg2.jpg"
print ("before")
resp = DeepFace.verify(img1_path=img1m, img2_path=img2)
print ("after")
if resp['verified']:
print("access granted")
else:
print("Access denied")
我已经尝试了这里给出的许多解决方案ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context'和许多其他站点,但仍然得到相同的错误。
我在 Raspberry Pi 4 上运行代码。
帮助表示赞赏。