btwardow / tf-face-recognition

Ral-Time Tensor Flow Face Detection and Recognition
MIT License
68 stars 20 forks source link

Run without docker #2

Open andhana opened 6 years ago

andhana commented 6 years ago

can this be run without docker?

btwardow commented 6 years ago

Sure. It's also very useful while developing on your box.

Just remember to install all prerequisites. I advice to create new virtual env + install everything from the docker/requirements.txt with uncommenting lines with TensorFlow. After just type run server/server.py from the main directory.

andhana commented 6 years ago

Thank you. I have tried it, but there is one error that is the file det1.npy does not exist. in the file mtcnn.py there is det1.npy, det2.npy, det3.npy, where do i get those files? or is there another solution?

btwardow commented 6 years ago

Oh, sorry. Right, this two scripts do the magic: docker/download.py and download_vggace2.py when the docker image is being build (https://github.com/btwardow/tf-face-recognition/blob/master/docker/Dockerfile#L13-L19).

The simplest solution is to create pretrained_models directory in your home directory and run both scripts from there. All necessary data will be downloaded. This directory is pointed by the constant from here: https://github.com/btwardow/tf-face-recognition/blob/master/tensorface/const.py#L10 when you running the server, so if you like you can place models in different dir and change this line.

andhana commented 6 years ago

It works. Can stream video from a webcam but cannot detect faces. there are some errors: ERROR in app: Exception on /detect [POST] Traceback (most recent call last): File "server.py", line 45, in detect faces = recognize(detection.get_faces(image, threshold)) File "/root/tf-face-recognition/tensorface/recognition.py", line 19, in recognize X[i, :] = embedding(img_to_np(img)) File "/root/tf-face-recognition/tensorface/embedding.py", line 44, in embedding images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0") KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."

File "server.py", line 65, in detect print('POST /detect error: %e' % e) TypeError: must be real number, not KeyError

btwardow commented 6 years ago

Ok. lemme check that.

I didn't want to commit a huge binary model files to repository, that's why I decided to download it while building docker image. But, the downside of that is it can be broken if sth change in this external dependencies.

btwardow commented 6 years ago

Ok. I've updated README with the instruction how to run development env step-by-step with frozen version of required packages: https://github.com/btwardow/tf-face-recognition#run-it-without-docker-development

Hope it will help you.

andhana commented 6 years ago

Very helpful and easy to understand. But with that version of VGGModel run without docker, can you still detect faces like when you run it with a docker? Sorry my English is bad 😬, hope you understand what i mean

btwardow commented 6 years ago

Yes. Just give it a try ☺️

andhana commented 6 years ago

Still get this error 😔 https://github.com/btwardow/tf-face-recognition/issues/2#issuecomment-416825664

umairch commented 6 years ago

Getting this error after installing requirments.text 2018-08-30 1

umairch commented 6 years ago

Can you Please elaborate or list down actual Steps needed, how to run on windows environment without docker. After cloning repository what are the steps and commands to follow assume we have python Installed :) @btwardow

btwardow commented 6 years ago

@umairch sorry, I don't have windows box and cannot check it. Also, that's why docker is provided :-)

But it seems for me that you half-way there: you have to add parent directory to PYTHONPATH and make sure that https://github.com/btwardow/tf-face-recognition/blob/master/tensorface/const.py#L10 point to the directory on your windows box where pre-trained models are downloaded.

I change server.py script so that you shouldn't got this error. Checkout this commit: 12c56c8a59cb9445508ad24448bc8e11a8cbc406

@andhana later on I will check and make it more environment independent, as for now I don't have right away solution. Seems like variables from the pertained model cannot by accessed properly.

umairch commented 6 years ago

getting same error which @andhana getting @btwardow

umairch commented 6 years ago

got your error after a lot debugging @andhana :)

umairch commented 6 years ago

@btwardow after a lot struggle now error in def predict error Traceback is

Traceback (most recent call last): File "server.py", line 54, in detect faces = recognize(detection.get_faces(image, threshold)) File "C:\Python World\tf-face-recognition\server\tensorface\recognition.py", line 21, in recognize result = classifier.predict(X) File "C:\Python World\tf-face-recognition\server\tensorface\classifier.py", line 118, in predict return model.predict(X) File "C:\Python World\tf-face-recognition\server\tensorface\classifier.py", line 68, in predict self.dist_threshold: self.dist_threshold_value}) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 900, in run run_metadata_ptr) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1060, in _run raise RuntimeError('The Session graph is empty. Add operations to the ' RuntimeError: The Session graph is empty. Add operations to the graph before calling run(). [2018-08-30 20:27:58,588] ERROR in app: Exception on /detect [POST] Traceback (most recent call last): File "server.py", line 54, in detect faces = recognize(detection.get_faces(image, threshold)) File "C:\Python World\tf-face-recognition\server\tensorface\recognition.py", line 21, in recognize result = classifier.predict(X) File "C:\Python World\tf-face-recognition\server\tensorface\classifier.py", line 118, in predict return model.predict(X) File "C:\Python World\tf-face-recognition\server\tensorface\classifier.py", line 68, in predict self.dist_threshold: self.dist_threshold_value}) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 900, in run run_metadata_ptr) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1060, in _run raise RuntimeError('The Session graph is empty. Add operations to the ' RuntimeError: The Session graph is empty. Add operations to the graph before calling run().

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py", line 35, in reraise raise value File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\umair\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "server.py", line 74, in detect print('POST /detect error: %e' % e) TypeError: must be real number, not RuntimeError 127.0.0.1 - - [30/Aug/2018 20:27:58] "POST /detect HTTP/1.1" 500 -

btwardow commented 6 years ago

Sorry for a late response @umairch.

Seems like importing pre-trained models are not imported properly. Sorry, but I cannot handle such errors in timely manner for windows boxes right now.

If you would like to take care of it and contribute, that would be great!

For novice and windows users I would advice to use Docker.

rebotnix commented 6 years ago

Had the same issue as @umairch on ubunu 16.04. Try to figure out how to fix it.

punnawat commented 6 years ago

(face_recognition_36) [cloud@instance-1 tf-face-recognition-master]$ python server/server.py Traceback (most recent call last): File "server/server.py", line 11, in from tensorface import detection ModuleNotFoundError: No module named 'tensorface'

How to install tensorface module?

btwardow commented 6 years ago

Just add CWD to PYTHONPATH, e.g.: while running type:

PYTHONPATH='.' python server/server.py
punnawat commented 6 years ago

@btwardow I cannot run it; my OS is CentOS7

[pc@instance-1 tf-face-recognition-master]$ pwd
/home/pc/tf-face-reg/tf-face-recognition-master

[pc@instance-1 tf-face-recognition-master]$ PYTHONPATH="." python server/server.py
Traceback (most recent call last):
  File "server/server.py", line 11, in <module>
    from tensorface import detection
  File "/home/pc/tf-face-reg/tf-face-recognition-master/tensorface/detection.py", line 5, in <module>
    from tensorface.mtcnn import detect_face, create_mtcnn
  File "/home/pc/tf-face-reg/tf-face-recognition-master/tensorface/mtcnn.py", line 32, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

[punnawat_cloud@instance-1 tf-face-recognition-master]$ 

I try with docker run --rm -it -p 5000:5000 -v /$(pwd):/workspace btwardow/tf-face-recognition:dev, there is an error as same as Not found docker image

archenroot commented 5 years ago

@punnawat - you are missing tensorflow install with python api enable, try pip install tensorflow under virtualenv or via conda...