Home

Awesome

This is an example how to run a TensorFlow object detection model as web server in TensorFlow C++ API.

Brief Introduction

1). Construct a class for TF model like this:

class Detector {
    std::unique_ptr<tensorflow::Session> session;
    public:
        int loadModel();
        int detect();
};

First, loadModel to initialize and load graph into session, then use session in detect for prediction.

2). use crow the start a web server in main (crow is inspired by python FLASK. If you are familiar with FLASK, crow is easy to use.)

Requirements

Install

Install TensorFlow C++ and OpenCV: see this blog

Install Boost <br>

sudo apt-get install libboost-all-dev

Usage

  1. compile the project <br>
cmake .
make
  1. run tf-cpp web service <br>
./tf_detect_crow
  1. test with python script<br>
python test_cpp_api.py

Acknowledgement

Great appreciation to following project and code snippet: