GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - borarak/tensorflow2_cpp: Build Tensorflow C++ API, load a SavedModel and serve predictions

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
include
include
 
 
CMakeLists.txt
CMakeLists.txt
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
get_prediction.cpp
get_prediction.cpp
 
 
sample_prediction.jpg
sample_prediction.jpg
 
 
saved_model_loader.h
saved_model_loader.h
 
 
test-image-anoir-chafik-2_3c4dIFYFU-unsplash.jpg
test-image-anoir-chafik-2_3c4dIFYFU-unsplash.jpg
 
 

Repository files navigation

tensorflow2_cpp

Sample example how to load a Tensorflow Object detection API v2 model and serve prediction in C++

Accompanying Medium post here

Build and installation

The current config uses the following dependencies (based on Tensorflow tested build). Check out build from source configs for more details.

  1. Tensorflow 2.3.0
  2. CUDA 10.1
  3. cuDNN 7.6
  4. Bazel 3.1.0
  5. Protobuf 3.9.2
  6. OpenCV 4.3.0 (required only for the example)

Build Docker image

docker build . -t boraraktim/tensorflow2_cpp

Compile source

  1. Download the object detection model from TF object detection model zoo. We use the efficientdet_d3_coco17_tpu-32 for this example and unpack it.

  2. Start container and mount the model volume

docker run --gpus all -it --rm -v efficientdet_d3_coco17_tpu-32/:/object_detection/models/ boraraktim/tensorflow2_cpp

directory structure

-|/object_detection/models/
    -|efficientdet_d3_coco17_tpu-32
    	|--saved_model
            |--assets/
            |--saved_model.pb
            |-- ...
  1. Build the project using cmake
root@8122f3e1dc5b:/object_detection# mkdir build
root@8122f3e1dc5b:/object_detection# cd build && cmake ..
root@8122f3e1dc5b:/object_detection/build# make

Predict

./get_prediction <path/to/saved_model> <path/to/image.jpg> <path/to/output.jpg>

Example,

root@8122f3e1dc5b:/object_detection/build# ./get_prediction ../models/efficientdet_d3_coco17_tpu-32/saved_model/ ../test-image-anoir-chafik-2_3c4dIFYFU-unsplash.jpg ../sample_prediction.jpg

sample_prediction_doggies.jpg

Image from Unspalsh

About

Build Tensorflow C++ API, load a SavedModel and serve predictions

medium.com/@reachraktim/using-the-new-tensorflow-2-x-c-api-for-object-detection-inference-ad4b7fd5fecc

Topics

cppobject-detectiontensorflowtensorflow-cpptensorflow-object-detection-apitensorflow2

Resources

Readme
CC0-1.0 license
Activity

Stars

41 stars

Watchers

3 watching

Forks

12 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.