cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor
Visitor
189 Views
Registered: ‎02-29-2020

Vitis-AI-1.0 frozen model transformation problem

Hello, I encountered several problems when using vitis-ai quantization. My software environment is as follows:

 

Training framework: tensorflow_gpu_1.14

 

Python version: python3.5

 

Vitis-ai version: 1.0

 

Using the latest tensorflow/models/research/object_detection/model_main trained py, the configuration file is:tensorflow/models/research/object_detection/samples/configs/ssdlite_mobilenet_v2_coco.config

The training results are as follows:

 

 

 

Question 1:

 

Tensorflow model of I want to put my training into frozen_graph.pb, I use tensorflow/models/research/object_detection/export_inference_graph.py, convert command is as follows:

python3 export_inference_graph.py \

     --input_type image_tensor \

     --pipeline_config_path /home/seacean/SSD_TEST/tensorflow/data2/data/config/ssdlite_mobilenet_v2_coco.config \

     --trained_checkpoint_prefix /home/seacean/SSD_TEST/tensorflow/data2/data/model/train/model.ckpt-200000 \

     --output_directory /home/seacean/SSD_TEST/tensorflow/data2/data/model/train/export_graph

The conversion results are as follows:

 

1,Copy the tf_ssd_voc_300_300_64.81G folder in all_models to vitis-ai /mpsoc/vitis-ai-tool-example and rename it to tf_ssd_voc. Then copy the frozen_inference_graph.pb converted from above to tf_ssd_voc/float/ and replace the frozen.pb

2,Modify the contents of vitis-ai/mpsoc/vitis-ai-tool-example/4_tf_quantize.sh as follows:

#!/bin/sh

 

vai_q_tensorflow quantize --input_frozen_graph ${TF_NETWORK_PATH}/float/frozen.pb \

  --input_fn ${TF_NETWORK_PATH}.input_fn.calib_input \

  --output_dir ${TF_NETWORK_PATH}/vai_q_output \

                  --input_nodes image \

  --output_nodes ssd300/Reshape_1 \

  --input_shapes ?,300,300,3 \

  --calib_iter 50 \

 

Execute the 4_tf_quantize.sh error message as follows:

(vitis-ai-tensorflow) seacean@seacean:/workspace/mpsoc/vitis-ai-tool-example$ sh 4_tf_quantize.sh

Traceback (most recent call last):

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/vai_q_tensorflow", line 10, in <module>

    sys.exit(run_main())

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 744, in run_main

    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run

    _sys.exit(main(argv))

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 743, in <lambda>

    my_main = lambda unused_args: main(unused_args, FLAGS)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 520, in main

    input_nodes = _parse_input_nodes(input_graph_def, flags.input_nodes)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 146, in _parse_input_nodes

    check_node_names(input_graph_def, input_nodes)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/utils.py", line 37, in check_node_names

    raise NameError("Node '{}' not found in graph.".format(node_name))

NameError: Node 'image' not found in graph.

 

Problem 2:

 

I used the freeze_graph transformation model included in vitis-ai1.0. The command is as follows:

freeze_graph \

--input_graph ./graph.pbtxt  \   

--input_checkpoint ./model.ckpt-200000 \    

--input_binary false \    

--output_graph ./frozen_graph.pb  \   

--output_node_names ssd300/Reshape_1

 

The error message is as follows:

(vitis-ai-tensorflow) seacean@seacean:/workspace/mpsoc/vitis-ai-tool-example/train$ freeze_graph     --input_graph ./graph.pbtxt     --input_checkpoint ./model.ckpt-200000     --input_binary false     --output_graph ./frozen_graph.pb     --output_node_names ssd300/Reshape_1

WARNING:tensorflow:From /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py:249: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.

Instructions for updating:

Use tf.gfile.GFile.

Traceback (most recent call last):

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/freeze_graph", line 10, in <module>

    sys.exit(run_main())

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 488, in run_main

    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run

    _sys.exit(main(argv))

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 487, in <lambda>

    my_main = lambda unused_args: main(unused_args, flags)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 381, in main

    flags.saved_model_tags, checkpoint_version)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 340, in freeze_graph

    input_graph_def = _parse_input_graph_proto(input_graph, input_binary)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 253, in _parse_input_graph_proto

    text_format.Merge(f.read(), input_graph_def)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 693, in Merge

    allow_unknown_field=allow_unknown_field)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 760, in MergeLines

    return parser.MergeLines(lines, message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 785, in MergeLines

    self._ParseOrMerge(lines, message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 807, in _ParseOrMerge

    self._MergeField(tokenizer, message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 932, in _MergeField

    merger(tokenizer, message, field)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1006, in _MergeMessageField

    self._MergeField(tokenizer, sub_message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 932, in _MergeField

    merger(tokenizer, message, field)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1006, in _MergeMessageField

    self._MergeField(tokenizer, sub_message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 932, in _MergeField

    merger(tokenizer, message, field)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1006, in _MergeMessageField

    self._MergeField(tokenizer, sub_message)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/google/protobuf/text_format.py", line 899, in _MergeField

    (message_descriptor.full_name, name))

google.protobuf.text_format.ParseError: 859790:7 : Message type "tensorflow.OpDef" has no field named "control_output".

 

 

I hope to get your help

0 Kudos
5 Replies
Highlighted
Xilinx Employee
Xilinx Employee
160 Views
Registered: ‎11-29-2007

Re: Vitis-AI-1.0 frozen model transformation problem

hello,

probably this will not fix all your errors, but for Vitis AI 1.0 you should use TF 1.12 for training, or better, train inside the docker, after activating the vitis-ai-tensorflow conda environment.

 

 

Highlighted
Visitor
Visitor
131 Views
Registered: ‎02-29-2020

Re: Vitis-AI-1.0 frozen model transformation problem

Thank you very much for your reply.
If I upgrade tensorflow to version 1.15 and then use vitis-ai-1.1, can I solve this problem? Does it correspond to the version?
0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
119 Views
Registered: ‎07-16-2008

Re: Vitis-AI-1.0 frozen model transformation problem

Yes, Vitis AI 1.1 is supposed to support TF 1.15.

-------------------------------------------------------------------------
Don't forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
99 Views
Registered: ‎02-29-2020

Re: Vitis-AI-1.0 frozen model transformation problem

hello
I demoted tensorflow to 1.12, and after training, converted to pb files using the following command:
python3 export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/config/ssdlite_mobilenet_v2_coco.config \
--trained_checkpoint_prefix /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/model/train/model.ckpt-100000 \
--output_directory /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/model/train/export_graph

However, there was still an error in the quantification(Vitis-AI-1.0). The error message is as follows:
(vitis-ai-tensorflow) seacean@seacean:/workspace/mpsoc/vitis-ai-tool-example$ sh 4_tf_quantize.sh
Traceback (most recent call last):
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/vai_q_tensorflow", line 10, in <module>
sys.exit(run_main())
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 744, in run_main
app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 743, in <lambda>
my_main = lambda unused_args: main(unused_args, FLAGS)
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 520, in main
input_nodes = _parse_input_nodes(input_graph_def, flags.input_nodes)
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 146, in _parse_input_nodes
check_node_names(input_graph_def, input_nodes)
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/utils.py", line 37, in check_node_names
raise NameError("Node '{}' not found in graph.".format(node_name))
NameError: Node 'image' not found in graph.

Could you please tell me how to convert the files obtained from the training? I hope to get your help again
0 Kudos
Highlighted
Visitor
Visitor
71 Views
Registered: ‎02-29-2020

Re: Vitis-AI-1.0 frozen model transformation problem

hello

I'm sorry,but I'm at my wit's end

I demoted tensorflow to 1.12, and after training, converted to pb files using the following command:

python3 export_inference_graph.py \

--input_type image_tensor \

--pipeline_config_path /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/config/ssdlite_mobilenet_v2_coco.config \

--trained_checkpoint_prefix /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/model/train/model.ckpt-100000 \

--output_directory /home/seacean/SSD_TEST/tensorflow/vitis-ai-1.0/data/data/model/train/export_graph

However, there was still an error in the quantification(Vitis-AI-1.0). The error message is as follows:

(vitis-ai-tensorflow) seacean@seacean:/workspace/mpsoc/vitis-ai-tool-example$ sh 4_tf_quantize.sh

Traceback (most recent call last):

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/vai_q_tensorflow", line 10, in <module>

    sys.exit(run_main())

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 744, in run_main

    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run

    _sys.exit(main(argv))

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 743, in <lambda>

    my_main = lambda unused_args: main(unused_args, FLAGS)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 520, in main

    input_nodes = _parse_input_nodes(input_graph_def, flags.input_nodes)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/decent_q.py", line 146, in _parse_input_nodes

    check_node_names(input_graph_def, input_nodes)

  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow/contrib/decent_q/python/utils.py", line 37, in check_node_names

    raise NameError("Node '{}' not found in graph.".format(node_name))

NameError: Node 'image' not found in graph.

I hope to get your help again

0 Kudos