How to load checkpoint and inference with C++ for tensorflow?

tidy picture tidy · Jun 13, 2017 · Viewed 9.8k times · Source

I have Tensorflow with python api and got these checkpoint model file:

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

But I want a C/C++ shared library (.so file) when integrating into production. So I need to load these model file and inference with C++ code and compile to a shared library. Is there some tutorial or sample for doing this?

Answer

gdelab picture gdelab · Jun 13, 2017

You can write c++ code to load and use your graph with the instructions given here.

You can use the files here to make a Cmake project with tensorflow outside the TF repository, and compile your library.

However, you'll still need the .ckpt files next to your .so, I don't know how to intergate them inside it.

There are a lot of questions about that on S.O., and a few tutorials (see the two cited in this answer) but since tensorflow is evolving fast, they quickly become outdated, and it's always a bit of struggle to get it to work properly (totally feasible, and getting easier, though).