Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

How to convert tensorflow model to IR

li__wei_bin
Beginner
509 Views

Hi :

Is the first time I use tensorflow to generate trained model. The below is my step:

1. I implemented tensorflow internal "cifar10_input.py" , "cifar10.py", "cifar10_train.py" python file. Then, it generated the model below:

model.ckpt-999999.data-00000-of-00001
model.ckpt-999999.index
model.ckpt-999999.meta

2. I used "freeze_graph.py" to generate "*.pb" file.

python3 freeze_graph.py  \
--input_binary /tmp/cifar10_train/model.ckpt-999999.data-00000-of-00001 \
--input_checkpoint /tmp/checkpoints/inception_v1.ckpt \
--output_node_names InceptionV1/Logits/Predictions/Reshape_1 \
--output_graph model_frozen.pb

3.But, I met some problems, the detailed log message as below :

2018-07-03 10:54:54.342712: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
  File "freeze_graph.py", line 382, in <module>
    run_main()
  File "freeze_graph.py", line 379, in run_main
    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
  File "/root/tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "freeze_graph.py", line 378, in <lambda>
    my_main = lambda unused_args: main(unused_args, flags)
  File "freeze_graph.py", line 272, in main
    flags.saved_model_tags, checkpoint_version)
  File "freeze_graph.py", line 254, in freeze_graph
    checkpoint_version=checkpoint_version)
  File "freeze_graph.py", line 128, in freeze_graph_with_def_protos
    var_list=var_list, write_version=checkpoint_version)
  File "/root/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1338, in __init__
    self.build()
  File "/root/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1347, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/root/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1372, in _build
    raise ValueError("No variables to save")
ValueError: No variables to save

As I understand, I need to generate ".pb" file, then I can use mo_ft.py to generate IR file.

Whether I omit any step?

Thanks a lot.

 

0 Kudos
1 Solution
Monique_J_Intel
Employee
509 Views

Hi Bruce,

Input binary takes on the value true or false. So the reason its throwing the error is because you haven't given it an input_graph. When you trained your model in your code did you have graph definition file generated? If not, then you may be able to freeze it by doing the following:

python3 freeze_graph.py  \
 --input_meta_graph /tmp/cifar10_train/model.ckpt-999999.meta \
 --input_checkpoint /tmp/checkpoints/inception_v1.ckpt \
 --output_node_names InceptionV1/Logits/Predictions/Reshape_1 \
 --output_graph model_frozen.pb

If that doesn't work then you can generate the graph definition by using the export_inference_graph.py that can find in tensorflow/models/research/slim directory that will generate a graph def file that you can use.

Kind Regards,

Monique Jones

View solution in original post

0 Kudos
1 Reply
Monique_J_Intel
Employee
510 Views

Hi Bruce,

Input binary takes on the value true or false. So the reason its throwing the error is because you haven't given it an input_graph. When you trained your model in your code did you have graph definition file generated? If not, then you may be able to freeze it by doing the following:

python3 freeze_graph.py  \
 --input_meta_graph /tmp/cifar10_train/model.ckpt-999999.meta \
 --input_checkpoint /tmp/checkpoints/inception_v1.ckpt \
 --output_node_names InceptionV1/Logits/Predictions/Reshape_1 \
 --output_graph model_frozen.pb

If that doesn't work then you can generate the graph definition by using the export_inference_graph.py that can find in tensorflow/models/research/slim directory that will generate a graph def file that you can use.

Kind Regards,

Monique Jones

0 Kudos
Reply