Skip to content

Converts keras trained models to frozen tensorflow protocol buffers for use with the c++ tensorflow api

License

Notifications You must be signed in to change notification settings

00mjk/convert-to-tensorflow

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

convert-to-tensorflow

Converts a variety of trained models to a frozen tensorflow protocol buffer file for use with the c++ tensorflow api. C++ code is included for using the frozen models.

Supported Architectures

This repo has been tested for convolutional regression and inference networks that contain a single input and a single ouput for image models.

  • Caffe model frozen using caffe-tensorflow
  • Keras models saved to hdf5 format (e.g. model.save('foo/bar.hdf5')

Convert to TfLite

Likley want to run this part with a newer TF - perhaps 1.11 As documented here ...

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/g3doc/python_api.md#api

import tensorflow as tf

graph_def_file = "/path/to/frozen_graph.pb"
input_arrays = ["input"]
output_arrays = ["MobilenetV1/Predictions/Softmax"]

converter = tf.contrib.lite.TocoConverter.from_frozen_graph(graph_def_file, input_arrays, output_arrays)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

About

Converts keras trained models to frozen tensorflow protocol buffers for use with the c++ tensorflow api

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%