Skip to content

Add a gRPC client in C++ for inception serving. - #300

Merged
nfiedel merged 2 commits into
tensorflow:masterfrom
isiosia:inception_client_cc
Feb 21, 2017
Merged

Add a gRPC client in C++ for inception serving.#300
nfiedel merged 2 commits into
tensorflow:masterfrom
isiosia:inception_client_cc

Conversation

@isiosia

@isiosia isiosia commented Jan 22, 2017

Copy link
Copy Markdown
Contributor

#281

This is a gRPC client which written in C++ and can run with the inception serving demo.

Build this demo with the following command:

bazel build tensorflow_serving/example:inception_client_cc

And run:

bazel-bin/tensorflow_serving/example/inception_client_cc --image=/file/to/my_cat.jpg

@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@isiosia isiosia changed the title Add an gRPC client in C++ for inception. Add a gRPC client in C++ for inception. Jan 22, 2017
@isiosia isiosia changed the title Add a gRPC client in C++ for inception. Add a gRPC client in C++ for inception serving. Jan 22, 2017
using tensorflow::serving::PredictResponse;
using tensorflow::serving::PredictionService;

const std::string SERVING_HOST = "localhost:9000";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these parameters configurable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please update SERVING_HOST to something like ADDRESS and make flag configurable.
Input file name should also be flag configurable.
And please s/SERVICE_NAME/MODEL_NAME, and make configurable. Can default to "inception".
Thanks!



int main(int argc, char** argv) {
// Expect only arg: --db_path=path/to/route_guide_db.json.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this here

for(iter = map_outputs.begin();iter != map_outputs.end(); ++iter){
std::cout << "output " << output_index << " name is "<< iter->first << std::endl;

std::cout << "output " << output_index << " type is "<<

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can probably reuse helper methods from tensorflow/core/framework/tensor.cc, specifically
Tensor::FromProto and Tensor::DebugString(). This should let you delete the code from here to approx line 120 of the current PR.

};


std::string GetImagePath(int argc, char** argv) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please try tensorflow::Flag(...), which will allow you to delete this method?

@nfiedel nfiedel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this PR and apologies for the delayed reply. This is definitely useful, both for inception and as an example for others wanting to create gRPC clients.

Please take a look at the comments and ping back when ready for another review.

Thanks!

…sult

make the server_address/model_name/image_file configurable using Tensorflow flag
@isiosia

isiosia commented Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

@nfiedel @tobegit3hub Thanks for your review, and I rewrote the code mentioned in the comments.The parameter processing and output are now using the methods provided by tensorflow. Would you please give another review?

@nfiedel

nfiedel commented Feb 18, 2017

Copy link
Copy Markdown
Contributor

Hi isiosia@,
Thanks for making the changes. Looking good!

@tensorflow-jenkins : test this please

@nfiedel
nfiedel merged commit c20f6c1 into tensorflow:master Feb 21, 2017
@atisman89

Copy link
Copy Markdown

Is there a way to build the C++ gRPC client on Windows?

@syagev

syagev commented Aug 6, 2018

Copy link
Copy Markdown

@atisman89 were you able to do this eventually?

simon-mo pushed a commit to simon-mo/serving that referenced this pull request Sep 2, 2018
* Add an inception client in cc.

* use the Tensor::FromProto and Tensor::SummarizeValue to output the result
make the server_address/model_name/image_file configurable using Tensorflow flag
@Opeiz

Opeiz commented Jun 2, 2020

Copy link
Copy Markdown

Hi all,
I used these example with conda to run it but its says "grpc++/create_channel.h no such file or directory"
anyone know how to fix it?

@rasapala rasapala left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants