Skip to content

Simple example of how to load a pretrained model and use it to predict with Tensorflow 2.3.0 C API.

License

Notifications You must be signed in to change notification settings

RoyVII/Tensorflow_C_Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tensorflow C/C++ Example

Simple example of how to load a pretrained model and use it to predict with Tensorflow 2.3.0 C API (CPU only, but probably it also works with GPU). The libraries for Linux used can be downloaded here. It has not been tested with Windows or MacOS libraries, but I guess it should work too. This program will run independently from any Python Tensorflow installation that you may have.

It uses a model pretained with a simple MNIST convolutional network, that can be obtained by saving (model.save(save_path)) the resulting model from following the tutorial Simple MNIST convnet. It loads one image from the dataset and does a class prediction with it.

The saved model needs to be in the SavedModel format and not Keras H5 format or the C API won't load it. Read more about that here.

Dependencies

Tensorflow shared libraries (.so files) need to be downloaded and placed into the lib folder. In order for the program to find these libraries in execution time you need to run in the same terminal:

export LD_LIBRARY_PATH=lib

or you can follow the instructions here.

Compilation and execution

make
./tf_example

About

Simple example of how to load a pretrained model and use it to predict with Tensorflow 2.3.0 C API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published