tensorflow_cpp

Helpful model wrappers around TensorFlow C++ API

https://github.com/ika-rwth-aachen/tensorflow_cpp

Science Score: 72.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 3 committers (66.7%) from academic institutions
  • Institutional organization owner
    Organization ika-rwth-aachen has institutional domain (www.ika.rwth-aachen.de)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary

Keywords

cpp helper ros tensorflow
Last synced: 6 months ago · JSON representation ·

Repository

Helpful model wrappers around TensorFlow C++ API

Basic Info
  • Host: GitHub
  • Owner: ika-rwth-aachen
  • License: mit
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 983 KB
Statistics
  • Stars: 20
  • Watchers: 4
  • Forks: 1
  • Open Issues: 0
  • Releases: 7
Topics
cpp helper ros tensorflow
Created over 3 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

tensorflow_cpp

tensorflow_cpp is a header-only library that provides helpful wrappers around the TensorFlow C++ API, allowing you to easily load, inspect, and run saved models and frozen graphs in C++. The library is easy to integrate into CMake projects, but is also available as a ROS and ROS2 package.

[!IMPORTANT]
This repository is open-sourced and maintained by the Institute for Automotive Engineering (ika) at RWTH Aachen University.
Deep Learning is one of many research topics within our Vehicle Intelligence & Automated Driving domain.
If you would like to learn more about how we can support your deep learning or automated driving efforts, feel free to reach out to us!
     Timo Woopen - Manager Research Area Vehicle Intelligence & Automated Driving
     +49 241 80 23549
     timo.woopen@ika.rwth-aachen.de

If you are looking for an easy way to install the TensorFlow C++ API, we suggest that you also check out our repository libtensorflow_cc. There, we provide a pre-built library and a Docker image for easy installation and usage of the TensorFlow C++ API.


Examples

Loading and running a single-input/single-output model

```cpp

include

include

include

include

include

// load single-input/single-output model std::string modelpath = "/PATH/TO/MODEL"; tensorflowcpp::Model model; model.loadModel(model_path);

// log model info std::cout << model.getInfoString() << std::endl;

// get input/output shape/type, if required std::vector inputshape = model.getInputShape(); tensorflow::DataType outputtype = model.getOutputType(); // ... do something ...

// create and fill input tensor tensorflow::Tensor input_tensor; // ... fill input tensor ...

// run model tensorflow::Tensor outputtensor = model(inputtensor); ```

Loading and running a multi-input/multi-output model ```cpp #include #include #include #include #include // load multi-input/multi-output model std::string model_path = "/PATH/TO/MODEL"; tensorflow_cpp::Model model; model.loadModel(model_path); // log model info std::cout << model.getInfoString() << std::endl; // input/output layer names are determined automatically, // but could potentially have different order than expected // get input/output shapes/types, if required std::vector input_shape_1 = model.getNodeShapes()[0]; tensorflow::DataType output_type_2 = model.getNodeTypes()[1]; // ... do something ... // create and fill input tensors tensorflow::Tensor input_tensor_1; tensorflow::Tensor input_tensor_2; // ... fill input tensors ... // run model auto outputs = model({input_tensor_1, input_tensor_2}); tensorflow::Tensor output_tensor_1& = outputs[0]; tensorflow::Tensor output_tensor_2& = outputs[1]; ```
Loading and running a multi-input/multi-output model with specific inputs/outputs ```cpp #include #include #include #include #include // load multi-input/multi-output model std::string model_path = "/PATH/TO/MODEL"; tensorflow_cpp::Model model; model.loadModel(model_path); // log model info std::cout << model.getInfoString() << std::endl; // set model input/output layer names (see `model.logInfo()`) const std::string kModelInputName1 = "input1"; const std::string kModelInputName2 = "input2"; const std::string kModelOutputName1 = "output1"; const std::string kModelOutputName2 = "output2"; // get input/output shapes/types, if required std::vector input_shape_1 = model.getNodeShape(kModelInputName1); tensorflow::DataType output_type_2 = model.getNodeType(kModelOutputName2); // ... do something ... // create and fill input tensors tensorflow::Tensor input_tensor_1; tensorflow::Tensor input_tensor_2; // ... fill input tensors ... // run model auto outputs = model({{kModelInputName1, input_tensor_1}, {kModelInputName2, input_tensor_2}}, {kModelOutputName1, kModelOutputName2}); tensorflow::Tensor output_tensor_1& = outputs[kModelOutputName1]; tensorflow::Tensor output_tensor_2& = outputs[kModelOutputName2]; ```

Installation

Dependencies

tensorflow_cpp is a wrapper around the official TensorFlow C++ API. The C++ API including libtensorflow_cc.so must be installed on the system.

Instead of having to build the C++ API from source yourself, we recommend to check out our repository libtensorflow_cc. There, we provide a pre-built library and a Docker image for easy installation and usage of the TensorFlow C++ API.

Installation is as easy as the following. Head over to libtensorflow_cc for more details. ARCH=$(dpkg --print-architecture) wget https://github.com/ika-rwth-aachen/libtensorflow_cc/releases/download/v2.9.2/libtensorflow-cc_2.9.2-gpu_${ARCH}.deb sudo dpkg -i libtensorflow-cc_2.9.2-gpu_${ARCH}.deb ldconfig

If you have already installed the C++ API another way, you can use the provided TensorFlowConfig.cmake to enable the find_package(TensorFlow REQUIRED) call in tensorflow_cpp's CMakeLists.txt.

CMake

  1. Clone this repository.

    bash git clone https://github.com/ika-rwth-aachen/tensorflow_cpp.git cd tensorflow_cpp

  2. Install tensorflow_cpp system-wide.

    ```bash

    tensorflow_cpp$

    mkdir -p build cd build cmake .. sudo make install ```

  3. Use find_package() to locate and integrate tensorflow_cpp into your CMake project. See the CMake example project.

    ```cmake

    CMakeLists.txt

    findpackage(tensorflowcpp REQUIRED)

    ...

    addexecutable(foo ...) # / addlibrary(foo ...)

    ...

    targetlinklibraries(foo tensorflow_cpp) ```

ROS/ROS2

  1. Clone this repository into your ROS/ROS2 workspace.

    bash git clone https://github.com/ika-rwth-aachen/tensorflow_cpp.git cd tensorflow_cpp

  2. In order to include tensorflow_cpp in a ROS/ROS2 package, specify the dependency in its package.xml and use find_package() in your package's CMakeLists.txt.

    xml <!-- package.xml --> <depend>tensorflow_cpp</depend>

    ```cmake

    CMakeLists.txt

    ROS

    findpackage(catkin REQUIRED COMPONENTS tensorflowcpp )

    ROS2

    findpackage(tensorflowcpp REQUIRED) amenttargetdependencies( tensorflow_cpp) ```

Testing

In order to build and run the test cases defined in tests/, execute the following.

```bash

tensorflow_cpp$

mkdir -p build cd build cmake -DBUILD_TESTING=ON .. make ctest ```

Documentation

Click here to be taken to the full API documentation.

The documentation can be generated by running Doxygen.

```bash

tensorflow_cpp/doc$

doxygen ```

Acknowledgements

This work is accomplished within the projects 6GEM (FKZ 16KISK038) and UNICARagil (FKZ 16EMO0284K). We acknowledge the financial support for the projects by the Federal Ministry of Education and Research of Germany (BMBF).

Notice

This repository is not endorsed by or otherwise affiliated with TensorFlow or Google. TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc. TensorFlow is released under the Apache License 2.0.

Owner

  • Name: Institut für Kraftfahrzeuge, RWTH Aachen, ika
  • Login: ika-rwth-aachen
  • Kind: organization
  • Location: Aachen, Germany

Citation (CITATION.cff)

cff-version: 1.2.0

title: ika-rwth-aachen/tensorflow_cpp
doi: 10.5281/zenodo.7227948
type: software
repository-code: "https://github.com/ika-rwth-aachen/tensorflow_cpp.git"
authors:
  - given-names: Lennart
    family-names: Reiher
    email: "lennart.reiher@rwth-aachen.de"
    affiliation: "Institute for Automotive Engineering (ika), RWTH Aachen University"
    orcid: 0000-0002-7309-164X
  - given-names: Bastian
    family-names: Lampe
    email: "bastian.lampe@rwth-aachen.de"
    affiliation: "Institute for Automotive Engineering (ika), RWTH Aachen University"
    orcid: 0000-0002-4414-6947
  - given-names: Raphael
    family-names: van Kempen
    email: "raphael.vankempen@ika.rwth-aachen.de"
    affiliation: "Institute for Automotive Engineering (ika), RWTH Aachen University"
    orcid: 0000-0001-5017-7494

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 54
  • Total Committers: 3
  • Avg Commits per committer: 18.0
  • Development Distribution Score (DDS): 0.148
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Lennart Reiher l****r@i****e 46
FabianThomsen 5****n 7
Lukas Zanger l****r@i****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 2
  • Total pull requests: 8
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 4.0
  • Average comments per pull request: 0.13
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zjd1988 (1)
  • BKjungle (1)
Pull Request Authors
  • lreiher (5)
  • FabianThomsen (3)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v3 composite
.github/workflows/doc.yml actions
  • actions/checkout v3 composite
  • mattnotmitt/doxygen-action v1.1.0 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite