aster icon indicating copy to clipboard operation
aster copied to clipboard

Which output node names to select for freezing the network

Open DeepanshuMakkar opened this issue 5 years ago • 6 comments

Can anyone tell which output node names can be selected in order to freeze the network?

DeepanshuMakkar avatar May 09 '19 13:05 DeepanshuMakkar

output_graph_def = tf.graph_util.convert_variables_to_constants( sess, # The session is used to retrieve the weights tf.get_default_graph().as_graph_def(), # The graph_def is used to retrieve the nodes #output nodes for fetches ["Placeholder", "Postprocess/AggregateRecognitionResults/GatherNd","LocalizationNet/Reshape_1","Sampler/Reshape"]

nikita0511 avatar May 10 '19 09:05 nikita0511

Hi @nikita0511 thanks for your reply. I tried to give the output node names as you mentioned. Although it had to be given as "Postprocess/AggregateRecognitionResults/GatherNd,Placeholder,LocalizationNet/Reshape_1,Sampler/Reshape" because the argument has to be a string with comma seperated,

But once I use these nodes and freeze the network and later try to load the graph it raises an error :- "ValueError: No op named GatherTree in defined operations."

Could you share your thoughts on it? thanks in advance :)

DeepanshuMakkar avatar May 13 '19 09:05 DeepanshuMakkar

Thank you for sharing the output nodes.

However, I'm encountering a problem. Those nodes are available when I open the checkpoint graph in tensorboard but when I try to access them to freeze them, it says they don't exist.

How did you both have access to these nodes?

Edit: I realized that I wasn't viewing the actual .ckpt model, but rather the properly configured evaluation model. To get around the node accessing problem, I had to replicate the set-up steps in demo.py and eval.py in my model freezing script.

dsandii avatar Jul 26 '19 19:07 dsandii

@DeepanshuMakkar I encountered the same error ValueError: No op named GatherTree in defined operations. and another different one related to string operations after using this method.

I was able to get around it by importing /aster/builders/model_builder.py and /aster/builders/input_reader_builder.py.

I assume tf doesn't know how to parse the .pb without these being defined in the global scope. If either of you know why this happens or how we can get around it so we can simply use the .pb as-is please let me know.

dsandii avatar Jul 30 '19 13:07 dsandii

@DeepanshuMakkar @nikita0511 @dsandii Can you share the pb file if you have converted? Thanks in advance

vikramreddy0307 avatar Oct 14 '19 07:10 vikramreddy0307

@nikita0511

I am able to generate .pb file but when I try to load and run it on a image, I am getting this error

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid loop structure: Loop "Forward/Predictor/decoder/while/while_context" has more than one LoopCond node: {{node Forward/Predictor/decoder/while/LoopCond_1}} and {{node Forward/Predictor/decoder/while/LoopCond}}. This is an internal bug, please file a bug report with instructions on how to reproduce the error.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "create_tesorrt_model.py", line 119, in tmp = sess.run(tmp, feed_dict={input_images: img}) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid loop structure: Loop "Forward/Predictor/decoder/while/while_context" has more than one LoopCond node: node Forward/Predictor/decoder/while/LoopCond_1 (defined at create_tesorrt_model.py:113) and node Forward/Predictor/decoder/while/LoopCond (defined at create_tesorrt_model.py:102) . This is an internal bug, please file a bug report with instructions on how to reproduce the error.

Can you share the code snippet you used to generate .pb file?

123mw123 avatar Apr 29 '21 19:04 123mw123