do you have solution for the error? Please share to me
# Import TensorFlow and TensorRT
import tensorflow as tf
import tensorflow.contrib.tensorrt as trt
# Inference with TF-TRT frozen graph workflow:
graph = tf.Graph()
with graph.as_default():
with tf.Session() as sess:
# First deserialize your frozen graph:
with tf.gfile.GFile("body_25_graph_and_prepare_paf.pb", "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
trt_graph = trt.create_inference_graph(
input_graph_def=graph_def,
outputs=["net_output"],
max_batch_size=1,
max_workspace_size_bytes=1 << 25,
precision_mode="FP16",
minimum_segment_size=50)
# Import the TensorRT graph into a new graph and run:
output_node = tf.import_graph_def(trt_graph,return_elements=["net_output"])
sess.run(output_node)
While running the above code, I am facing the following problem:
I am not sure, where I am making a mistake, please help
InvalidArgumentError: You must feed a value for placeholder tensor 'import/input' with dtype float and shape [?,?,?,3]
[[{{node import/input}}]]
The complete log is given below.
InvalidArgumentError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1334 try:
→ 1335 return fn(*args)
1336 except errors.OpError as e:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
1319 return self._call_tf_sessionrun(
→ 1320 options, feed_dict, fetch_list, target_list, run_metadata)
1321
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
1407 self._session, options, feed_dict, fetch_list, target_list,
→ 1408 run_metadata)
1409
InvalidArgumentError: You must feed a value for placeholder tensor ‘import/input’ with dtype float and shape [?,?,?,3]
[[{{node import/input}}]]
During handling of the above exception, another exception occurred:
InvalidArgumentError Traceback (most recent call last)
in ()
22 # Import the TensorRT graph into a new graph and run:
23 output_node = tf.import_graph_def(trt_graph,return_elements=[“net_output”])
—> 24 sess.run(output_node)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
928 try:
929 result = self._run(None, fetches, feed_dict, options_ptr,
→ 930 run_metadata_ptr)
931 if run_metadata:
932 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1151 if final_fetches or final_targets or (handle and feed_dict_tensor):
1152 results = self._do_run(handle, final_targets, final_fetches,
→ 1153 feed_dict_tensor, options, run_metadata)
1154 else:
1155 results =
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1327 if handle is None:
1328 return self._do_call(_run_fn, feeds, fetches, targets, options,
→ 1329 run_metadata)
1330 else:
1331 return self._do_call(_prun_fn, handle, feeds, fetches)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1347 pass
1348 message = error_interpolation.interpolate(message, self._graph)
→ 1349 raise type(e)(node_def, op, message)
1350
1351 def _extend_graph(self):
InvalidArgumentError: You must feed a value for placeholder tensor ‘import/input’ with dtype float and shape [?,?,?,3]
[[node import/input (defined at :23) ]]
Original stack trace for ‘import/input’:
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/usr/lib/python3/dist-packages/ipykernel_launcher.py”, line 16, in
app.launch_new_instance()
File “/usr/lib/python3/dist-packages/traitlets/config/application.py”, line 658, in launch_instance
app.start()
File “/usr/lib/python3/dist-packages/ipykernel/kernelapp.py”, line 486, in start
self.io_loop.start()
File “/usr/lib/python3/dist-packages/zmq/eventloop/ioloop.py”, line 177, in start
super(ZMQIOLoop, self).start()
File “/usr/lib/python3/dist-packages/tornado/ioloop.py”, line 888, in start
handler_func(fd_obj, events)
File “/usr/lib/python3/dist-packages/tornado/stack_context.py”, line 277, in null_wrapper
return fn(*args, **kwargs)
File “/usr/lib/python3/dist-packages/zmq/eventloop/zmqstream.py”, line 440, in _handle_events
self._handle_recv()
File “/usr/lib/python3/dist-packages/zmq/eventloop/zmqstream.py”, line 472, in _handle_recv
self._run_callback(callback, msg)
File “/usr/lib/python3/dist-packages/zmq/eventloop/zmqstream.py”, line 414, in _run_callback
callback(*args, **kwargs)
File “/usr/lib/python3/dist-packages/tornado/stack_context.py”, line 277, in null_wrapper
return fn(*args, **kwargs)
File “/usr/lib/python3/dist-packages/ipykernel/kernelbase.py”, line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File “/usr/lib/python3/dist-packages/ipykernel/kernelbase.py”, line 233, in dispatch_shell
handler(stream, idents, msg)
File “/usr/lib/python3/dist-packages/ipykernel/kernelbase.py”, line 399, in execute_request
user_expressions, allow_stdin)
File “/usr/lib/python3/dist-packages/ipykernel/ipkernel.py”, line 208, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File “/usr/lib/python3/dist-packages/ipykernel/zmqshell.py”, line 537, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File “/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py”, line 2718, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File “/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py”, line 2822, in run_ast_nodes
if self.run_code(code, result):
File “/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py”, line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 23, in
output_node = tf.import_graph_def(trt_graph,return_elements=[“net_output”])
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py”, line 507, in new_func
return func(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/importer.py”, line 443, in import_graph_def
_ProcessNewOps(graph)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/importer.py”, line 236, in _ProcessNewOps
for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py”, line 3586, in _add_new_tf_operations
for c_op in c_api_util.new_tf_operations(self)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py”, line 3586, in
for c_op in c_api_util.new_tf_operations(self)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py”, line 3478, in _create_op_from_tf_operation
ret = Operation(c_op, self)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py”, line 1954, in init
self._traceback = tf_stack.extract_stack()
ArunKumar.
I think you should use pure TensorRT to optimize your model. When i work with TF-TRT i got many problems. then i change to pure TRT , my model convert to TRT easily. Good luck!
Hi nguyen,
Can you provide a link or a short process to use directly TensorRT ? I’m on JetsonTX2 - JetPack3.3
I have my frozen graph through .pb file and I’d like to use them to create tensor engine to do inference.
Thank you in advance
Hi Nguyen,
I am not sure if I am on right path, but I need your help.
My objective is to convert the Open Pose TensorFlow model (.pb) file to the TensorRT model for inference.
I first tried the Docker Image, and was able to generate the results shown on the following links:
https://github.com/haanjack/openpose-trt-optimize
But this Plugin is based on TensorRT-4 version, and now TensorRT 5 has changed his API revision, so this functionality is broken. Also my dev environment consists the Ubuntu18.04 GCC7.5 and TensorRT5.04 and latest TensorFlow 1.13.
So I started with my Own docker image for Ubuntu18.04, OpenCV4.0 and TensorRT5.04, but still developing the same implementation what JackHann done for TensorRT4.0.
Taking the reference of the comment by JackHann:
https://github.com/haanjack/openpose-trt-optimize/issues/1
I started converting the IPluginV2 APIs in C++.
But suddenly I found that this is done already in TensorFlow1.7 version, so I distracted.
But now you told me to use (Seems) the same approach that JackHann indicated.
Would you like to guide me, what to be followed.
Thanks
Kind Regards
Arun
i convert TF model (.pb) to TRT (plan file) completely but now i can not deploy it on deepstream1.5. If you can deploy TRT (plan file) in deepstream sdk 1.5 please contact me.
You can follow this page that using pure TRT.