1.AttributeError: module 'tensorflow' has no attribute 'variable_scope'
解决:
将原代码:
import tensorflow as tf
改为:
import tensorflow.compat.v1 as tf
若未能解决,重新下载tensorflow
.whl文件:Links for tensorflow
源代码:https://github.com/tensorflow/tensorflow
注:若下载源代码文件,将原来的tensorflow文件替换为下载好的tensorflow文件即可
2.AttributeError: module 'cv2' has no attribute 'face'
解决:需要opencv-contrib-python,在win+R中输入cmd进入windows命令行程序,输入pip install opencv-contrib-python,并检查opencv-python和opencv-contrib-python是否同版本
3.Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'
解决:原来是我的项目中,cv2的 imwrite仅支持png和jpeg格式,将jpg改成png即可