{"id":28938886,"url":"https://github.com/ika-rwth-aachen/tensorflow_cpp","last_synced_at":"2025-09-17T16:37:26.514Z","repository":{"id":61642028,"uuid":"537518212","full_name":"ika-rwth-aachen/tensorflow_cpp","owner":"ika-rwth-aachen","description":"Helpful model wrappers around TensorFlow C++ API","archived":false,"fork":false,"pushed_at":"2024-01-05T15:39:51.000Z","size":1007,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-04T19:25:12.572Z","etag":null,"topics":["cpp","helper","ros","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ika-rwth-aachen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-16T15:35:41.000Z","updated_at":"2025-01-21T02:50:04.000Z","dependencies_parsed_at":"2024-01-05T16:50:48.557Z","dependency_job_id":null,"html_url":"https://github.com/ika-rwth-aachen/tensorflow_cpp","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ika-rwth-aachen/tensorflow_cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ika-rwth-aachen%2Ftensorflow_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ika-rwth-aachen%2Ftensorflow_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ika-rwth-aachen%2Ftensorflow_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ika-rwth-aachen%2Ftensorflow_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ika-rwth-aachen","download_url":"https://codeload.github.com/ika-rwth-aachen/tensorflow_cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ika-rwth-aachen%2Ftensorflow_cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275623933,"owners_count":25498457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","helper","ros","tensorflow"],"created_at":"2025-06-22T23:32:35.124Z","updated_at":"2025-09-17T16:37:26.506Z","avatar_url":"https://github.com/ika-rwth-aachen.png","language":"C++","readme":"# tensorflow_cpp\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/v/release/ika-rwth-aachen/tensorflow_cpp\"/\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/ika-rwth-aachen/tensorflow_cpp\"/\u003e\n  \u003ca href=\"https://zenodo.org/badge/latestdoi/537518212\"\u003e\u003cimg src=\"https://zenodo.org/badge/537518212.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ika-rwth-aachen/tensorflow_cpp/actions/workflows/build.yml\"\u003e\u003cimg src=\"https://github.com/ika-rwth-aachen/tensorflow_cpp/actions/workflows/build.yml/badge.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ika-rwth-aachen/tensorflow_cpp/actions/workflows/test.yml\"\u003e\u003cimg src=\"https://github.com/ika-rwth-aachen/tensorflow_cpp/actions/workflows/test.yml/badge.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://ika-rwth-aachen.github.io/tensorflow_cpp\"\u003e\u003cimg src=\"https://github.com/ika-rwth-aachen/tensorflow_cpp/actions/workflows/doc.yml/badge.svg\"/\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/ROS1-noetic-green\"/\u003e\n  \u003cimg src=\"https://img.shields.io/badge/ROS2-humble-green\"/\u003e\n  \u003ca href=\"https://github.com/ika-rwth-aachen/tensorflow_cpp\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/ika-rwth-aachen/tensorflow_cpp?style=social\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n*tensorflow_cpp* is a header-only library that provides helpful wrappers around the [TensorFlow C++ API](https://www.tensorflow.org/api_docs/cc), 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](https://www.ros.org/) package.\n\n\u003e [!IMPORTANT]  \n\u003e This repository is open-sourced and maintained by the [**Institute for Automotive Engineering (ika) at RWTH Aachen University**](https://www.ika.rwth-aachen.de/).  \n\u003e **Deep Learning** is one of many research topics within our [*Vehicle Intelligence \u0026 Automated Driving*](https://www.ika.rwth-aachen.de/en/competences/fields-of-research/vehicle-intelligence-automated-driving.html) domain.  \n\u003e 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!  \n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; *Timo Woopen - Manager Research Area Vehicle Intelligence \u0026 Automated Driving*  \n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; *+49 241 80 23549*  \n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; *timo.woopen@ika.rwth-aachen.de*  \n\nIf you are looking for an easy way to install the TensorFlow C++ API, we suggest that you also check out our repository [*libtensorflow_cc*](https://github.com/ika-rwth-aachen/libtensorflow_cc). There, we provide a pre-built library and a Docker image for easy installation and usage of the TensorFlow C++ API. \u003ca href=\"https://github.com/ika-rwth-aachen/libtensorflow_cc\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/ika-rwth-aachen/libtensorflow_cc?style=social\"/\u003e\u003c/a\u003e\n\n---\n\n- [tensorflow\\_cpp](#tensorflow_cpp)\n  - [Examples](#examples)\n  - [Installation](#installation)\n    - [Dependencies](#dependencies)\n    - [CMake](#cmake)\n    - [ROS/ROS2](#rosros2)\n  - [Testing](#testing)\n  - [Documentation](#documentation)\n  - [Acknowledgements](#acknowledgements)\n  - [Notice](#notice)\n\n\n## Examples\n\n*Loading and running a single-input/single-output model*\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n\n#include \u003ctensorflow/core/framework/tensor.h\u003e\n#include \u003ctensorflow_cpp/model.h\u003e\n\n// load single-input/single-output model\nstd::string model_path = \"/PATH/TO/MODEL\";\ntensorflow_cpp::Model model;\nmodel.loadModel(model_path);\n\n// log model info\nstd::cout \u003c\u003c model.getInfoString() \u003c\u003c std::endl;\n\n// get input/output shape/type, if required\nstd::vector\u003cint\u003e input_shape = model.getInputShape();\ntensorflow::DataType output_type = model.getOutputType();\n// ... do something ...\n\n// create and fill input tensor\ntensorflow::Tensor input_tensor;\n// ... fill input tensor ...\n\n// run model\ntensorflow::Tensor output_tensor = model(input_tensor);\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003eLoading and running a multi-input/multi-output model\u003c/i\u003e\u003c/summary\u003e\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n\n#include \u003ctensorflow/core/framework/tensor.h\u003e\n#include \u003ctensorflow_cpp/model.h\u003e\n\n// load multi-input/multi-output model\nstd::string model_path = \"/PATH/TO/MODEL\";\ntensorflow_cpp::Model model;\nmodel.loadModel(model_path);\n\n// log model info\nstd::cout \u003c\u003c model.getInfoString() \u003c\u003c std::endl;\n\n// input/output layer names are determined automatically,\n// but could potentially have different order than expected\n\n// get input/output shapes/types, if required\nstd::vector\u003cint\u003e input_shape_1 = model.getNodeShapes()[0];\ntensorflow::DataType output_type_2 = model.getNodeTypes()[1];\n// ... do something ...\n\n// create and fill input tensors\ntensorflow::Tensor input_tensor_1;\ntensorflow::Tensor input_tensor_2;\n// ... fill input tensors ...\n\n// run model\nauto outputs = model({input_tensor_1, input_tensor_2});\ntensorflow::Tensor output_tensor_1\u0026 = outputs[0];\ntensorflow::Tensor output_tensor_2\u0026 = outputs[1];\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003eLoading and running a multi-input/multi-output model with specific inputs/outputs\u003c/i\u003e\u003c/summary\u003e\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n\n#include \u003ctensorflow/core/framework/tensor.h\u003e\n#include \u003ctensorflow_cpp/model.h\u003e\n\n// load multi-input/multi-output model\nstd::string model_path = \"/PATH/TO/MODEL\";\ntensorflow_cpp::Model model;\nmodel.loadModel(model_path);\n\n// log model info\nstd::cout \u003c\u003c model.getInfoString() \u003c\u003c std::endl;\n\n// set model input/output layer names (see `model.logInfo()`)\nconst std::string kModelInputName1 = \"input1\";\nconst std::string kModelInputName2 = \"input2\";\nconst std::string kModelOutputName1 = \"output1\";\nconst std::string kModelOutputName2 = \"output2\";\n\n// get input/output shapes/types, if required\nstd::vector\u003cint\u003e input_shape_1 = model.getNodeShape(kModelInputName1);\ntensorflow::DataType output_type_2 = model.getNodeType(kModelOutputName2);\n// ... do something ...\n\n// create and fill input tensors\ntensorflow::Tensor input_tensor_1;\ntensorflow::Tensor input_tensor_2;\n// ... fill input tensors ...\n\n// run model\nauto outputs = model({{kModelInputName1, input_tensor_1}, {kModelInputName2, input_tensor_2}}, {kModelOutputName1, kModelOutputName2});\ntensorflow::Tensor output_tensor_1\u0026 = outputs[kModelOutputName1];\ntensorflow::Tensor output_tensor_2\u0026 = outputs[kModelOutputName2];\n```\n\n\u003c/details\u003e\n\n\n## Installation\n\n### Dependencies\n\n*tensorflow_cpp* is a wrapper around the official [TensorFlow C++ API](https://www.tensorflow.org/api_docs/cc). The C++ API including `libtensorflow_cc.so` must be installed on the system.\n\nInstead of having to build the C++ API from source yourself, we recommend to check out our repository [*libtensorflow_cc*](https://github.com/ika-rwth-aachen/libtensorflow_cc). There, we provide a pre-built library and a Docker image for easy installation and usage of the TensorFlow C++ API.\n\nInstallation is as easy as the following. Head over to [*libtensorflow_cc*](https://github.com/ika-rwth-aachen/libtensorflow_cc) for more details.\n```\nARCH=$(dpkg --print-architecture)\nwget https://github.com/ika-rwth-aachen/libtensorflow_cc/releases/download/v2.9.2/libtensorflow-cc_2.9.2-gpu_${ARCH}.deb\nsudo dpkg -i libtensorflow-cc_2.9.2-gpu_${ARCH}.deb\nldconfig\n```\n\nIf you have already installed the C++ API another way, you can use the provided [`TensorFlowConfig.cmake`](cmake/TensorFlowConfig.cmake) to enable the `find_package(TensorFlow REQUIRED)` call in *tensorflow_cpp's* [`CMakeLists.txt`](CMakeLists.txt).\n\n### CMake\n\n1. Clone this repository.\n\n    ```bash\n    git clone https://github.com/ika-rwth-aachen/tensorflow_cpp.git\n    cd tensorflow_cpp\n    ```\n\n2. Install *tensorflow_cpp* system-wide.\n\n    ```bash\n    # tensorflow_cpp$\n    mkdir -p build\n    cd build\n    cmake ..\n    sudo make install\n    ```\n\n3. Use `find_package()` to locate and integrate *tensorflow_cpp* into your CMake project. See the [CMake example project](examples/cmake/).\n\n    ```cmake\n    # CMakeLists.txt\n    find_package(tensorflow_cpp REQUIRED)\n    # ...\n    add_executable(foo ...) # / add_library(foo ...)\n    # ...\n    target_link_libraries(foo tensorflow_cpp)\n    ```\n\n### ROS/ROS2\n\n1. Clone this repository into your ROS/ROS2 workspace.\n\n    ```bash\n    git clone https://github.com/ika-rwth-aachen/tensorflow_cpp.git\n    cd tensorflow_cpp\n    ```\n\n1. 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`.\n\n    ```xml\n    \u003c!-- package.xml --\u003e\n    \u003cdepend\u003etensorflow_cpp\u003c/depend\u003e\n    ```\n\n    ```cmake\n    # CMakeLists.txt\n\n    # ROS\n    find_package(catkin REQUIRED COMPONENTS\n      tensorflow_cpp\n    )\n\n    # ROS2\n    find_package(tensorflow_cpp REQUIRED)\n    ament_target_dependencies(\u003cTARGET\u003e tensorflow_cpp)\n    ```\n\n\n## Testing\n\nIn order to build and run the test cases defined in [`tests/`](tests/), execute the following.\n\n```bash\n# tensorflow_cpp$\nmkdir -p build\ncd build\ncmake -DBUILD_TESTING=ON ..\nmake\nctest\n```\n\n\n## Documentation\n\n[Click here](https://ika-rwth-aachen.github.io/tensorflow_cpp) to be taken to the full API documentation.\n\nThe documentation can be generated by running [Doxygen](https://doxygen.nl/).\n\n```bash\n# tensorflow_cpp/doc$\ndoxygen\n```\n\n\n## Acknowledgements\n\nThis work is accomplished within the projects [6GEM](https://6gem.de/) (FKZ 16KISK038) and [UNICAR*agil*](https://www.unicaragil.de/) (FKZ 16EMO0284K). We acknowledge the financial support for the projects by the Federal Ministry of Education and Research of Germany (BMBF).\n\n\n## Notice\n\nThis repository is not endorsed by or otherwise affiliated with [TensorFlow](https://www.tensorflow.org) or Google. TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc. [TensorFlow](https://github.com/tensorflow/tensorflow) is released under the [Apache License 2.0](https://github.com/tensorflow/tensorflow/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fika-rwth-aachen%2Ftensorflow_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fika-rwth-aachen%2Ftensorflow_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fika-rwth-aachen%2Ftensorflow_cpp/lists"}