seathiefwang / facerecognition-tensorflow Goto Github PK
View Code? Open in Web Editor NEW基于TensorFlow训练的人脸识别神经网络
基于TensorFlow训练的人脸识别神经网络
1
# 输出层
Wout = weightVariable([512,2])
bout = weightVariable([2])
#out = tf.matmul(dropf, Wout) + bout
out = tf.add(tf.matmul(dropf, Wout), bout)
return out
问题1:第二行bout这里为什么给的是权值,不应该是给偏差值吗?(The second row “bout” here why give "weightVariable“, should not be given ”biasVariable”?)
2
def is_my_face(image):
#run(fetches,feed_dict=None,options=None, run_metadata=None)
#tf.Session.run()执行fetches中的操作,计算fetches中的张量值。返回值为fetches的执行结果
res = sess.run(predict, feed_dict={x: [image/255.0], keep_prob_5:1.0, keep_prob_75: 1.0})
if res[0] == 1:
return True
else:
return False
问题2:res = sess.run(predict, feed_dict={x: [image/255.0], keep_prob_5:1.0, keep_prob_75: 1.0})
res[0] == 1这一句看不懂,为什么==1就是真了? (Res[0] = = 1, this sentence does not understand why ==1 is true?)
我在做本科毕设,有些问题不懂,可以加好友请教一下吗?QQ1198265517 微信xu17862702083
非常感谢你!
2018-03-27 00:28:52.140186: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at mkl_conv_ops.cc:655 : Aborted: Operation received an exception:Status: 3, message: could not set native handle, in file tensorflow/core/kernels/mkl_conv_ops.cc:652
Traceback (most recent call last):
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1361, in _do_call
return fn(*args)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _run_fn
target_list, status, run_metadata)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.AbortedError: Operation received an exception:Status: 3, message: could not set native handle, in file tensorflow/core/kernels/mkl_conv_ops.cc:652
[[Node: Conv2D = _MklConv2D[T=DT_FLOAT, _kernel="MklOp", data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_Placeholder_0_0, Variable/read, DMT/_0, DMT/_1)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 175, in
cnnTrain()
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 167, in cnnTrain
acc = accuracy.eval({x:test_x, y_:test_y, keep_prob_5:1.0, keep_prob_75:1.0})
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 656, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 4901, in _eval_using_default_session
return session.run(tensors, feed_dict)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 905, in run
run_metadata_ptr)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1137, in _run
feed_dict_tensor, options, run_metadata)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1355, in _do_run
options, run_metadata)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1374, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.AbortedError: Operation received an exception:Status: 3, message: could not set native handle, in file tensorflow/core/kernels/mkl_conv_ops.cc:652
[[Node: Conv2D = _MklConv2D[T=DT_FLOAT, _kernel="MklOp", data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_Placeholder_0_0, Variable/read, DMT/_0, DMT/_1)]]
Caused by op 'Conv2D', defined at:
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 175, in
cnnTrain()
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 133, in cnnTrain
out = cnnLayer()
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 97, in cnnLayer
conv1 = tf.nn.relu(conv2d(x, W1) + b1)
File "/home/wanlu/PycharmProjects/untitled1/train_faces.py", line 84, in conv2d
return tf.nn.conv2d(x, W, strides=[1,1,1,1], padding='SAME')
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 631, in conv2d
data_format=data_format, dilations=dilations, name=name)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3271, in create_op
op_def=op_def)
File "/home/wanlu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1650, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
AbortedError (see above for traceback): Operation received an exception:Status: 3, message: could not set native handle, in file tensorflow/core/kernels/mkl_conv_ops.cc:652
[[Node: Conv2D = _MklConv2D[T=DT_FLOAT, _kernel="MklOp", data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_Placeholder_0_0, Variable/read, DMT/_0, DMT/_1)]]
sometimes it happened,when running to a hundredfold,anyone can handle it,please tell me,thank you so much !
比如get_my_faces我用摄像头提取了10000张自己的照片,如果is_my_face运行时候是别人,比如是Tom的坐在电脑前,那么怎么能判断出这个人是谁?目前是不是只能判断出是不是自己,判断不了具体是谁?
请问这个项目还在继续研发吗?方便建个qq群一起交流开发吗?
打扰了,已经解决。
功能比较单一,只能识别本人,而且识别度好像不算太好,有他人来的时候也显示true,希望在博客中也能介绍一下整个模型搭建的原理之类的,对初学者可能更加友好
ok very good
can you tell me the result that if it is correct,and i train my own model ,i test this but it is not correct .thanks
您好,神经网络最后一层神经元的个数是等于训练数据中人员数量吧。但如果实际应用中,那个人不是训练数据中的人,那么向量匹配时会不会有什么影响,还是得重新训练网络?
在进行测试的时候,真人识别情况下,每个人都识别为我的脸,如果用照片,则显示结果正确,为何?
您好!我看了您的博客和本项目,严格按照您博客的说明步骤进行,但是在第一步时我只拍了4k张照片。
在第二步时,执行“train_faces.py”源文件时,发生了如下错误:
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,2] [[node Placeholder_1 (defined at F:/ProgramDesign/Python-Spyder/FaceRe/train_faces.py:69) ]]
我对您的代码修改了两处:
注释了train_faces.py的第10行代码:# other_faces_path = './other_faces'
注释了train_faces.py的第50行代码:# readData(other_faces_path)
我的运行环境:win10、TensorFlow1.13.1、Python3.6、Anaconda Spyder3.3.4;
请问这样该如何解决呢?(菜鸟自学AI,所提问题若有冒犯,还请见谅!)
OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\imgproc\src\color.cpp:11147: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
出现这个报错,怎么查都找不到是啥原因
摄像头得到的RGB难道不是0~255?求教
I have a question whether the project was completed by yourself?
如题,train_test_split是不是不在sklearn这个包了?
请问:cv2.error: OpenCV(3.4.2) /io/opencv/modules/imgproc/src/color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'
这是为何
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp, line 3229
Traceback (most recent call last):
File "/home/wanlu/PycharmProjects/untitled1/set_other_faces.py", line 46, in
face = cv2.resize(face, (size, size))
cv2.error: /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp:3229: error: (-215) ssize.area() > 0 in function resize
请问您遇到过这种情况吗?网上说是图像文件为空,但是我设置了判断也无济于事,期待您的回复!
from sklearn.model_selection import train_test_split出错,这个train_test_split是什么?
程序能运行,本人在摄像头前面的时候可以识别,Is this my face? True。
但是我用手机自拍然后把照片放在摄像头前面就识别不出来,Is this my face? False
请问这是怎么回事?
saver.restore(sess, tf.train.latest_checkpoint('.'))
报错为值为none
为何不论识别谁都显示True呢
楼主,您好!
当我运行运行is_my_face.py文件时,出现File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1264, in restore
raise ValueError("Can't load save_path when it is None.")
ValueError: Can't load save_path when it is None.
请问我应该如何解决这个问题,是什么原因导致了错误了呢。期待尽快得到你的回复。谢谢
File "G:/pycharm/untitled1/venv/is_my_face.py", line 145, in
saver.restore(sess, tf.train.latest_checkpoint('.'))
File "G:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1751, in restore
raise ValueError("Can't load save_path when it is None.")
ValueError: Can't load save_path when it is None.
How to tackle this problem? Thanks!
整个python文件运行时没有出现报错,但就是没有生成相应的model文件,想请加下是什么问题
运行is_myface:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\Facerecognition (1)\is_my_face.py", line 135, in
saver.restore(sess, tf.train.latest_checkpoint('.'))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\training\saver.py", line 1796, in restore
raise ValueError("Can't load save_path when it is None.")
ValueError: Can't load save_path when it is None.
Hi! I ran your code and found that accuracy is not high ,as for me I wore the glasses so I found some glasses man but code think that it is me....
so HOW CAN I IMPORVE FACE RECOGNITION ACCURACY?
HOW TRAIN ? AND HOW TO IMPORVE REFUSE POSSIBILITY?
THANK YOU!
python的cv2安装不上,能不能用别的框架替换一下??
E:\ProgramData\Anaconda3\python.exe "D:/360c/FaceRecognition-tensorflow-master (1)/FaceRecognition-tensorflow-master/get_my_faces.py"
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
File "D:/360c/FaceRecognition-tensorflow-master (1)/FaceRecognition-tensorflow-master/get_my_faces.py", line 1, in
import cv2
ImportError: numpy.core.multiarray failed to import
不好意思,问题已解决
您好,我学习您项目时候,通过摄像头获取自己的脸时候,时间很长,用了接近4小时才获取到10000张自拍,问一下您知道是什么原因吗?我用的是dlib
小弟幾個月前也在做類似的東西, 參考作者的圖片輸入,
發現原來之前自己對於圖片內容想法是錯的,
經修改後, 再參考作者卷積層加入dropout的想法, 成功實現相同功能~
但小弟這邊有個問題
神經網路中:
#全連接層
Wf = weightVariable([8*16*32, 512])
小弟覺得是: Wf = weightVariable([8*8*64, 512])
雖然結果是一樣的, 但意義感覺不一樣
想問問作者您怎麼覺得是: Wf = weightVariable([8*16*32, 512]) 呢~
请问,您是用pip 还是pip3?
error: OpenCV(3.4.1) C:\bld\opencv_1520732670222\work\opencv-3.4.1\modules\imgproc\src\color.cpp:11147: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
在运行get_my_face时缺没有这个问题。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.