我正在开发一个人脸识别桌面应用程序。我正在使用人脸识别库(https://pypi.org/project/face-recognition/)和deepface(https://pypi.org/project/deepface/)。我正在使用 venv 虚拟环境,我可以确认我的代码是正确的(因为它可以在 colab 上运行)。运行应用程序时,我收到以下警告,并且当触发使用 Face_recognition 库的编码生成时,我的应用程序崩溃。请注意,使用 Face_recognition 的编码生成在卸载 keras 时有效(但 Deepface 需要 Keras)。
警告:
2024-02-04 12:16:00.858406: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
WARNING:tensorflow:From C:\Users\xxx\Desktop\xxxx\xxxxx\xxxxxx\venv\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
我因此被屏蔽,任何帮助将不胜感激。
Keras版本:2.15.0 张量流版本:2.15.0
我的进口:
import tkinter as tk
from tkinter import filedialog
from PIL import ImageTk, Image
import json
from imutils import paths
import argparse
import pickle
import cv2
import os
import face_recognition
import time
from deepface import DeepFace
from retinaface import RetinaFace
from imutils.video import VideoStream
import imutils
我尝试使用部门的版本,但没有成功。我还使用 os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' 来消除警告,但效果不佳。我也尝试过:设置 TF_ENABLE_ONEDNN_OPTS=0
附注我使用的是 Windows 10
正如 Kevin Ball 在 Stack Overflow 上所建议的:
import os
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
import keras