Home

Awesome

tensorflow_catkin

Catkin package wrapper for Tensorflow 1.8 C++

Note: some features are disabled, such as GRPC support, Python bindings, and JPEG- and PNG-related ops like image encoding and decoding (the latter interferes with OpenCV but can be enabled by deleting the relevant patch).

Usage

package.xml

<?xml version="1.0" encoding="UTF-8"?>
<package format="2">
  <name>test_tensorflow</name>
  <version>0.0.0</version>
  <description>test_tensorflow</description>
  <maintainer email="some@example.com">Author</maintainer>
  <license>Apache 2.0</license>

  <buildtool_depend>catkin_simple</buildtool_depend>
  <buildtool_depend>catkin</buildtool_depend>
  <depend>tensorflow_catkin</depend>
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(test_tensorflow)

find_package(catkin_simple REQUIRED)
catkin_simple()

cs_add_executable(example example.cpp)

cs_install()
cs_export()

example.cpp

#include <tensorflow/core/public/session.h>
#include <tensorflow/core/platform/env.h>
#include <iostream>
using namespace std;
using namespace tensorflow;

int main()
{
    Session* session;
    Status status = NewSession(SessionOptions(), &session);
    if (!status.ok()) {
        cout << status.ToString() << endl;
        return 1;
    }
    cout << "Session successfully created." << endl;
}