btwardow / tf-face-recognition

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

The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph. #4

Open rebotnix opened 6 years ago

rebotnix commented 6 years ago

Hi,

thanks for this project.

I used tensorflow 1.7.0 with GPU and get this error, it seems something wrong with the graph.

File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3478, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3520, in _as_graph_element_locked "graph." % (repr(name), repr(op_name))) KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."

During handling of the above exception, another exception occurred:

When i use the docker container it works. I would like to implement and share a save function from the trained new model.

Thanks for any help.

btwardow commented 6 years ago

Hi, @garybruckheimer,

I will be happy to help you and make this more easy to run. But first few simple questions that help me understand what we are up to.

I assume you trying to run everything on your box without the container, right?

During handling of the above exception, another exception occurred:

How you handle that and what is the mentioned exception? Seems that the stack trace/info about the exception after the header is missing.

rebotnix commented 6 years ago

Dear btwardow,

thank you very much for your help. I spent some more time and got now the face detection part running.

I had to change in embedding.py - in function

def embedding(face_np): global sess

images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")

#embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0")
#phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0")

images_placeholder = sess.graph.get_tensor_by_name("input:0")
embeddings = sess.graph.get_tensor_by_name("embeddings:0")
phase_train_placeholder = sess.graph.get_tensor_by_name("phase_train:0")

...

Face Detection is now working in the browser. When I captured the faces, I can see the thumbnails, but in my terminal console i saw this error when i try to train the captured thumbnails.

) -> physical GPU (device: 0, name: Tesla V100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 7.0) Traceback (most recent call last): File "server.py", line 49, in detect faces = recognize(detection.get_faces(image, threshold)) File "/opt/tf-face-recognition/tensorface/recognition.py", line 21, in recognize result = classifier.predict(X) File "/opt/tf-face-recognition/tensorface/classifier.py", line 118, in predict return model.predict(X) File "/opt/tf-face-recognition/tensorface/classifier.py", line 88, in predict result.append((UNKNOWN_CLASS, None, None, None)) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1545, in exit self._default_graph_context_manager.exit(exec_type, exec_value, exec_tb) File "/usr/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller yield g File "/usr/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 4896, in get_controller yield default File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller yield g File "/opt/tf-face-recognition/tensorface/classifier.py", line 68, in predict self.dist_threshold: self.dist_threshold_value}) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 905, in run run_metadata_ptr) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1065, 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-09-22 21:53:54,353] ERROR in app: Exception on /detect [POST] Traceback (most recent call last): File "server.py", line 49, in detect faces = recognize(detection.get_faces(image, threshold)) File "/opt/tf-face-recognition/tensorface/recognition.py", line 21, in recognize result = classifier.predict(X) File "/opt/tf-face-recognition/tensorface/classifier.py", line 118, in predict return model.predict(X) File "/opt/tf-face-recognition/tensorface/classifier.py", line 88, in predict result.append((UNKNOWN_CLASS, None, None, None)) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1545, in exit self._default_graph_context_manager.exit(exec_type, exec_value, exec_tb) File "/usr/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller yield g File "/usr/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 4896, in get_controller yield default File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller yield g File "/opt/tf-face-recognition/tensorface/classifier.py", line 68, in predict self.dist_threshold: self.dist_threshold_value}) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 905, in run run_metadata_ptr) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1065, 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 "/home/ubuntu/.local/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/ubuntu/.local/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/ubuntu/.local/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/ubuntu/.local/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/ubuntu/.local/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/ubuntu/.local/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "server.py", line 69, in detect print('POST /detect error: %e' % e) TypeError: a float is required

suryapa1 commented 5 years ago

Please help me out with the error.. Even am facing the same..

archenroot commented 5 years ago

I am having now same issue: tensorboard==1.13.1 tensorflow==1.13.1 tensorflow-estimator==1.13.0 tensorflow-gpu==1.13.1

archenroot commented 5 years ago

Related to #10

archenroot commented 5 years ago

Related to #9 - all these are having same root cause seems to me.

archenroot commented 5 years ago

To reproduce such issue I did "pipreqs ." to get just project requirments and this is result:

six==1.11.0
requests==2.21.0
Flask==1.0.2
numpy==1.16.1
tensorflow_gpu==1.13.1
Pillow==6.0.0
scikit_learn==0.21.1
tensorflow==1.13.1
typing==3.6.6
opecv is provided by OS package 3.4.1-r5

Can someone provide versions where this project is stable and runnable?

archenroot commented 5 years ago

So I run docker now and examine the environment, so we have there following: Python 3.5.2 vs local 3.6.5 Packages; numpy==1.14.2 Flask==0.12.2 opencv_python==3.4.0.12 tensorflow==1.7.0 requests==2.18.4 six==1.11.0 Pillow==6.0.0 scikit_learn==0.21.1 typing==3.6.6

archenroot commented 5 years ago

So when I reverted locally all versions via pip to what I find in docker container loaded in docker hub:

I get error on startup, but the application starts ok:

angetsu@andromeda ~/proj/prometheus-core/tf-face-recognition/server $ PYTHONPATH=".." python server.py
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
Model filename: /home/zangetsu/pretrained_models/20180402-114759/20180402-114759.pb
 * Running on https://0.0.0.0:5000/ (Press CTRL+C to quit)

When I open GUI it can capture 10 samples, but when I do update model I get:

raceback (most recent call last):
  File "server.py", line 49, in detect
    faces = recognize(detection.get_faces(image, threshold))
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/recognition.py", line 21, in recognize
    result = classifier.predict(X)
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/classifier.py", line 119, in predict
    return model.predict(X)
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/classifier.py", line 71, in predict
    if _valid_nn_num == self.K:
NameError: name '_valid_nn_num' is not defined
[2019-05-18 13:57:36,965] ERROR in app: Exception on /detect [POST]
Traceback (most recent call last):
  File "server.py", line 49, in detect
    faces = recognize(detection.get_faces(image, threshold))
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/recognition.py", line 21, in recognize
    result = classifier.predict(X)
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/classifier.py", line 119, in predict
    return model.predict(X)
  File "/home/zangetsu/proj/prometheus-core/tf-face-recognition/tensorface/classifier.py", line 71, in predict
    if _valid_nn_num == self.K:
NameError: name '_valid_nn_num' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/zangetsu/.local/lib64/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 69, in detect
    print('POST /detect error: %e' % e)
TypeError: must be real number, not NameError
127.0.0.1 - - [18/May/2019 13:57:36] "POST /detect HTTP/1.1" 500 -

I used this docker image in dockerhub which works just fine, but the code is probably different against what is in the repository: docker run -it --rm -p 5000:5000 btwardow/tf-face-recognition:1.0.0