All Projects → serizba → Cppflow

serizba / Cppflow

Licence: mit
Run TensorFlow models in C++ without installation and without Bazel

Programming Languages

c
50402 projects - #5 most used programming language
cpp
1120 projects

Projects that are alternatives of or similar to Cppflow

Automatic Speech Recognition
🎧 Automatic Speech Recognition: DeepSpeech & Seq2Seq (TensorFlow)
Stars: ✭ 192 (-46.22%)
Mutual labels:  neural-networks, tensorflow-models
gans-2.0
Generative Adversarial Networks in TensorFlow 2.0
Stars: ✭ 76 (-78.71%)
Mutual labels:  tensorflow-models, tensorflow-examples
TensorFlow-Binary-Image-Classification-using-CNN-s
Binary Image Classification in TensorFlow
Stars: ✭ 26 (-92.72%)
Mutual labels:  tensorflow-models, tensorflow-examples
Nnpack
Acceleration package for neural networks on multi-core CPUs
Stars: ✭ 1,538 (+330.81%)
Mutual labels:  neural-networks, inference
Tensorflow-Wide-Deep-Local-Prediction
This project demonstrates how to run and save predictions locally using exported tensorflow estimator model
Stars: ✭ 28 (-92.16%)
Mutual labels:  tensorflow-models, tensorflow-examples
Nlp Pretrained Model
A collection of Natural language processing pre-trained models.
Stars: ✭ 122 (-65.83%)
Mutual labels:  neural-networks, model
Age-Gender Estimation TF-Android
Age + Gender Estimation on Android with TensorFlow Lite
Stars: ✭ 34 (-90.48%)
Mutual labels:  tensorflow-models, tensorflow-examples
Open model zoo
Pre-trained Deep Learning models and demos (high quality and extremely fast)
Stars: ✭ 2,925 (+719.33%)
Mutual labels:  model, tensorflow-models
nn-Meter
A DNN inference latency prediction toolkit for accurately modeling and predicting the latency on diverse edge devices.
Stars: ✭ 211 (-40.9%)
Mutual labels:  inference, tensorflow-models
Awesome-Tensorflow2
基于Tensorflow2开发的优秀扩展包及项目
Stars: ✭ 45 (-87.39%)
Mutual labels:  tensorflow-models, tensorflow-examples
Ai Platform
An open-source platform for automating tasks using machine learning models
Stars: ✭ 61 (-82.91%)
Mutual labels:  neural-networks, tensorflow-models
Bmw Tensorflow Inference Api Gpu
This is a repository for an object detection inference API using the Tensorflow framework.
Stars: ✭ 277 (-22.41%)
Mutual labels:  inference, tensorflow-models
Xnnpack
High-efficiency floating-point neural network inference operators for mobile, server, and Web
Stars: ✭ 808 (+126.33%)
Mutual labels:  neural-networks, inference
Emlearn
Machine Learning inference engine for Microcontrollers and Embedded devices
Stars: ✭ 154 (-56.86%)
Mutual labels:  neural-networks, inference
Machine Learning
머신러닝 입문자 혹은 스터디를 준비하시는 분들에게 도움이 되고자 만든 repository입니다. (This repository is intented for helping whom are interested in machine learning study)
Stars: ✭ 705 (+97.48%)
Mutual labels:  neural-networks, tensorflow-examples
Neural-Turing-Machine
TensorFlow implementation of a Neural Turing Machine
Stars: ✭ 23 (-93.56%)
Mutual labels:  tensorflow-models, tensorflow-examples
Tensorflow Cmake
TensorFlow examples in C, C++, Go and Python without bazel but with cmake and FindTensorFlow.cmake
Stars: ✭ 418 (+17.09%)
Mutual labels:  inference, tensorflow-examples
Awesome Coreml Models
Largest list of models for Core ML (for iOS 11+)
Stars: ✭ 5,192 (+1354.34%)
Mutual labels:  model, tensorflow-models
go-topics
Latent Dirichlet Allocation
Stars: ✭ 23 (-93.56%)
Mutual labels:  model, inference
Android-Machine-Learning-With-TensorFlow
Tensor Flow implementation for Android
Stars: ✭ 17 (-95.24%)
Mutual labels:  tensorflow-models, tensorflow-examples

CppFlow 2

Run TensorFlow models in c++ without Bazel, without TensorFlow installation and without compiling Tensorflow. Perform tensor manipulation, use eager execution and run saved models directly from C++.

// Read the graph
cppflow::model model("saved_model_folder");

// Load an image
auto input = cppflow::decode_jpeg(cppflow::read_file(std::string("image.jpg")));

// Cast it to float, normalize to range [0, 1], and add batch_dimension
input = cppflow::cast(input, TF_UINT8, TF_FLOAT);
input = input / 255.f;
input = cppflow::expand_dims(input, 0);

// Run
auto output = model(input);

// Show the predicted class
std::cout << cppflow::arg_max(output, 1) << std::endl;

You can take a look to the examples to see a full example on how to load a deep network and feed it with a sample image.

CppFlow uses Tensorflow C API to run the models, meaning you can use it without installing Tensorflow and without compiling the whole Tensorflow repository with bazel, you just need to download the C API. With this project you can manage and run your models in C++ without worrying about void, malloc or free. With CppFlow you easily can:

  • Open saved models created with Python
  • Execute Tensorflow neural networks in C++
  • Perform tensor manipulation directly from C++

How To Run It

Since it uses TensorFlow 2 C API you just have to download it, check the docs to see a guide on how to do it.

You can either install the library system wide or you can just place the contents of the archive in a folder called libtensorflow2 in your HOME directory.

Afterwards, you can run the examples:

git clone [email protected]:serizba/cppflow.git
cd cppflow/examples/load_model
mkdir build
cd build
cmake ..
make
./example

Documentation

Check the docs at https://serizba.github.io/cppflow/.

There you can find quickstart guides and more information about how to install the library and run the examples.

Development

CppFlow is basically a wrapper over Tensorflow C API. The basic class, tensor is a wrapper of a TF eager tensor, and it just constains a pointer to its TF representation.

The TF C API provides the tools to call all the TF raw ops, but using them is confusing. CppFlow includes a facade over these functions, so they can be called easily as normal C++ functions. To achieve this, the file ops contains (mostly) all the TF raw ops functions, but with a simple C++ interface. This file has been generated automatically using a small script.

CppFlow also includes a wrapper on TF saved models, the model class, so they can be easily opened and executed.

There are still many things to implement... some of them may be:

  • Model complex invoking
  • Model eager API: Calling model with the eager API instead of the TF_SessionRun API. I have tried using TF_GraphToFunction but I could not achieve it.
  • Cover more raw_ops: Currently, the generator that creates the raw_ops facade converts many of the raw_ops but not all of them. Improve the generator to cover these cases (which are marked in the generator code).
  • Include testing

Cppflow 1

You can also use the older version of this work.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].