gsethi2409 / tf-pose-estimation

Hey! This is a clone of the tf-pose-estimation by Ildoo Kim modified to work with Tensorflow 2.0+!
Apache License 2.0
160 stars 117 forks source link

tf2.2 cannot run #6

Open ccl-private opened 4 years ago

ccl-private commented 4 years ago

KeyError: "The name 'TfPoseEstimator/image:0' refers to a Tensor which does not exist. The operation, 'TfPoseEstimator/image', does not exist in the graph."

After I change 'TfPoseEstimator/image:0' to 'image:0', new error occured. TypeError: An op outside of the function building code is being passed a "Graph" tensor. It is possible to have Graph tensors leak out of the function building context by including a tf.init_scope in your function building code. For example, the following function will fail: @tf.function def has_init_scope(): my_constant = tf.constant(1.) with tf.init_scope(): added = my_constant * 2 The graph tensor has name: Openpose/concat_stage7:0

rlayne commented 4 years ago

Exact same error for tf2.1. This repo needs better documentation as well, for those unfamiliar with the original work. It's definitely not 'ported' to tf2.x

aaqa112233 commented 4 years ago

tf2.3也不行啊!伙计赶紧更新啊

tylertroy commented 3 years ago

Hello @gsethi2409 You say this is compatible with TF2 but this is not so. Would you care to comment on what needs to be done to that made this work for you?

parthbs commented 3 years ago

Hello @gsethi2409 You say this is compatible with TF2 but this is not so. Would you care to comment on what needs to be done to that made this work for you?

Hi @tylertroy it's true, not compatible entirely with TF2.X, but somehow I can manage to run it with TF2.3.0. You can specify the block which is not working to get a solution.

Maqar commented 3 years ago

Привет @ gsethi2409 Вы говорите, что это совместимо с TF2, но это не так. Не могли бы вы прокомментировать, что нужно сделать, чтобы эта работа сработала для вас?

Привет, @tylertroy, это правда, не полностью совместим с TF2.X, но каким-то образом мне удается запустить его с TF2.3.0. Вы можете указать блок, который не работает, чтобы получить решение.

Hi, @parthbs image

in pose_estimate_video(video_name, path_video, path_out) 9 def pose_estimate_video(video_name, path_video=PATH_VIDEOS, path_out=PATH_OUTPUT): 10 w, h = model_wh("432x368") ---> 11 e = TfPoseEstimator(get_graph_path("mobilenet_thin"), target_size=(w, h)) 12 #e = TfPoseEstimator(get_graph_path("cmu"), target_size=(w, h)) 13 input_file = os.path.join(path_video, video_name ) /content/tf-pose-estimation/tf_pose/estimator.py in __init__(self, graph_path, target_size, tf_config, trt_bool) 335 print(ts) 336 --> 337 self.tensor_image = self.graph.get_tensor_by_name('TfPoseEstimator/image:0') 338 self.tensor_output = self.graph.get_tensor_by_name('TfPoseEstimator/Openpose/concat_stage7:0') 339 self.tensor_heatMat = self.tensor_output[:, :, :, :19] /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in get_tensor_by_name(self, name) 3844 raise TypeError("Tensor names are strings (or similar), not %s." % 3845 type(name).__name__) -> 3846 return self.as_graph_element(name, allow_tensor=True, allow_operation=False) 3847 3848 def _get_tensor_by_tf_output(self, tf_output): /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in as_graph_element(self, obj, allow_tensor, allow_operation) 3668 3669 with self._lock: -> 3670 return self._as_graph_element_locked(obj, allow_tensor, allow_operation) 3671 3672 def _as_graph_element_locked(self, obj, allow_tensor, allow_operation): /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation) 3710 raise KeyError("The name %s refers to a Tensor which does not " 3711 "exist. The operation, %s, does not exist in the " -> 3712 "graph." % (repr(name), repr(op_name))) 3713 try: 3714 return op.outputs[out_n] KeyError: "The name 'TfPoseEstimator/image:0' refers to a Tensor which does not exist. The operation, 'TfPoseEstimator/image', does not exist in the graph."
wetAloe commented 3 years ago

Try to add this line tf.compat.v1.disable_eager_execution() in the start of init function of TfPoseEstimator class

Maqar commented 3 years ago

Try to add this line tf.compat.v1.disable_eager_execution() in the start of init function of TfPoseEstimator class

Thanks, @oleggrigoryev22 ! It is work, but tf.compat.v1.disable_eager_execution() need to add in start of 'run*.py' file