AIRobolab-unilu / qt-pepper-emotion-classification

This repository aims to perform emotion classification with the QT robot and Pepper in order to have a better understanding of the human-robot interacton context.
MIT License
0 stars 0 forks source link

Unable to perform the face classification when subscribing to a camera topic to get the images to process #1

Open chris-ibrahim opened 6 years ago

chris-ibrahim commented 6 years ago

From this command roslaunch face_classification face_classification.launch or any other command that calls a node which subscribes to a camera topic to get the images to process, the following error occurs. It seems that it has something to do with the keras library and the tensroflow backend. I have tried to look for someone who got the same problem but the only thing I found so far was this google conversation group. He got the same error in a similar algorithm that uses keras. However no working solution has been proposed yet.

Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "/home/ibrahim/catkin_ws_airobolab/src/qt-pepper-emotion-classification/face_classification/src/video_emotion_color_demo_topics.py", line 113, in callback
    emotion_prediction = self.emotion_classifier.predict(gray_face)
  File "/home/ibrahim/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1745, in predict
    self._make_predict_function()
  File "/home/ibrahim/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1029, in _make_predict_function
    **kwargs)
  File "/home/ibrahim/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2356, in function
    return Function(inputs, outputs, updates=updates, **kwargs)
  File "/home/ibrahim/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2305, in __init__
    with tf.control_dependencies(self.outputs):
  File "/home/ibrahim/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 4863, in control_dependencies
    return get_default_graph().control_dependencies(control_inputs)
  File "/home/ibrahim/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 4481, in control_dependencies
    c = self.as_graph_element(c)
  File "/home/ibrahim/.local/lib/python2.7/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/ibrahim/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3557, in _as_graph_element_locked
    raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("predictions/Softmax:0", shape=(?, 7), dtype=float32) is not an element of this graph.
fjrodl commented 6 years ago

It was added a workaround as described in the link below to solve the multithread issue generated: https://github.com/keras-team/keras/issues/2397 https://www.tensorflow.org/api_guides/python/framework#get_default_graph