Welcome to the OpenVINO channel
Let's talk about processing TensorFlow models
and preparing them for inference with the Model-optimizer
Unlike a Caffe model, tensorFlow model is a bit more complex to convert
And there are few reasons
1. Tensorflow framework supports many operations,
These operations sometimes cannot even be represented by a simple graph
These operations so metimes are not even related to computer vision..
If you are trying to take a graph as is, without this processing
and accelerate it on a neural-network accelerator
it sometimes just doesn't work
We can fix most of these issues,
We can cut out portions of the topology and replace them with simple graph operations
But it requires work.
A good practice is to check the supported layers..
Go do documentations, and check them out..
Open the index file, go to model-optimizer,
supported layers
You can see the Caffe supported layers
MXNET
Tensor flow And so on..
2. Models are sometimes not frozen
During the training phase of the model, A tensorFlow model will have all the parameters as variables, not as fixed numbers..
Each checkpoint a snapshot of these parameters is taken.
We need to freeze the model. Basically go back to the last check-point and fixate the parameters..
Replace them with fixed numbers..
3. sometimes, special APIs are used to process the model
The TensorFlow SSD API is one example
We can handle many of these cases,
But you will have to know what is the type of the mode, what's its status and how to process it.
Before we even start make sure you have the prerequisites for running tensorFlow..
You can just run this script.
This will install everything you need to get started
So let's start with getting a tensorFlow model
Option number 1: navigate to the documentation and use one of the links to download a model
A nice bonus here that you can see the scaling factors required per each of these models..
We want to download the frozen ones..
Another option is to get it thru our model-downloader..
Some of the topologies available are tensorFlow
Let's download googlenet-v3 for example
And we got the model.pb file
Now we have the .pb file - This model is frozen
If your model is not frozen, you will have to freeze it
Please check the documentation on how to do it..
You'll need the checkpoint file and maybe others, it's a simple one command line.
So how to look into the frozen .pb file? - This is a non-readable binary file
There are 2 ways to read it
Number 1: install tensorFlow..
Let's build a tensor-board directory
run this utility:
convert pb to tensor-board..
And open tensor-board on a browser..
And here is my topology..
Option 2: If you just need to know the input and output layers
We have a small utility that can get it for you
Go to model-optimizer/utils
And run summarize_graph
And you can see the names of the first and last layers..
And now converting the model with Model-Optimizer looks just like we did for Caffe,,,
Specify the model, the output directory and run...
If your model is SSD or any other special case, Please check the documentations on how to process it.
Usually it involves cutting small portions of the graph and replacing them with equivalent simpler operations..
So we have seen how to load a tensorFlow model How to view the inputs/outputs
And how to process it with the model-optimizer..
Subscribe to our channel to get mode videos like this
Thank you.