{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/serving/issues/485","repository_url":"https://api.github.com/repos/tensorflow/serving","labels_url":"https://api.github.com/repos/tensorflow/serving/issues/485/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/serving/issues/485/comments","events_url":"https://api.github.com/repos/tensorflow/serving/issues/485/events","html_url":"https://github.com/tensorflow/serving/issues/485","id":236274552,"node_id":"MDU6SXNzdWUyMzYyNzQ1NTI=","number":485,"title":"How to call Tensorflow Serving from Golang?","user":{"login":"mauri870","id":10168637,"node_id":"MDQ6VXNlcjEwMTY4NjM3","avatar_url":"https://avatars2.githubusercontent.com/u/10168637?v=4","gravatar_id":"","url":"https://api.github.com/users/mauri870","html_url":"https://github.com/mauri870","followers_url":"https://api.github.com/users/mauri870/followers","following_url":"https://api.github.com/users/mauri870/following{/other_user}","gists_url":"https://api.github.com/users/mauri870/gists{/gist_id}","starred_url":"https://api.github.com/users/mauri870/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauri870/subscriptions","organizations_url":"https://api.github.com/users/mauri870/orgs","repos_url":"https://api.github.com/users/mauri870/repos","events_url":"https://api.github.com/users/mauri870/events{/privacy}","received_events_url":"https://api.github.com/users/mauri870/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-06-15T18:22:07Z","updated_at":"2018-07-13T23:30:09Z","closed_at":null,"author_association":"NONE","body":"Hi, I'm trying to implement a tensorflow serving client specifically for the inception example.\r\n\r\nWhat I have so far is:\r\n\r\n```go\r\nimageBytes, err := ioutil.ReadFile('image.jpg')\r\nImageTensor, err := tf.NewTensor(string(imageBytes))\r\nif err != nil {\r\n    ...\r\n}\r\n```\r\nThis tensor has a DType 0x7(DataType_DT_STRING)\r\nThen I use `tensorString, ok := imageTensor.Value().(string)` to get the tensor value as string since `Value()` return an interface.\r\n\r\nAnd the grpc request trying to mimic the python and c++ examples:\r\n```go\r\nrequest := &pb.PredictRequest{\r\n\tModelSpec: &pb.ModelSpec{\r\n\t\tName:          \"inception\",\r\n\t\tSignatureName: \"predict_images\",\r\n\t\tVersion: &google_protobuf.Int64Value{\r\n\t\t\tValue: 1,\r\n\t\t},\r\n\t},\r\n\tInputs: map[string]*tfframework.TensorProto{\r\n\t\t\"images\": &tfframework.TensorProto{\r\n\t\t\tDtype: tfframework.DataType_DT_STRING,\r\n\t\t\tTensorShape: &tfframework.TensorShapeProto{\r\n\t\t\t\tDim: []*tfframework.TensorShapeProto_Dim{\r\n\t\t\t\t\t&tfframework.TensorShapeProto_Dim{\r\n\t\t\t\t\t\tSize: int64(1),\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\tTensorContent: []byte(tensorString),\r\n\t\t},\r\n\t},\r\n}\r\n\r\nresp, err := h.GrpcClient.Predict(context.Background(), request)\r\n```\r\n\r\nWhen I run the code I get the following error back:\r\n```\r\nrpc error: code = InvalidArgument desc = tensor parsing error: images\r\n```\r\n\r\nI can't see any related logs in the tensorflow serving container.\r\n\r\nEdit: My problem seems to be related with this [piece of code](https://github.com/tensorflow/serving/blob/master/tensorflow_serving/servables/tensorflow/predict_impl.cc#L187-L190). Any workround to get a valid proto tensor from Go?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/serving/issues/comments/404978771","html_url":"https://github.com/tensorflow/serving/issues/485#issuecomment-404978771","issue_url":"https://api.github.com/repos/tensorflow/serving/issues/485","id":404978771,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDk3ODc3MQ==","user":{"login":"mauri870","id":10168637,"node_id":"MDQ6VXNlcjEwMTY4NjM3","avatar_url":"https://avatars2.githubusercontent.com/u/10168637?v=4","gravatar_id":"","url":"https://api.github.com/users/mauri870","html_url":"https://github.com/mauri870","followers_url":"https://api.github.com/users/mauri870/followers","following_url":"https://api.github.com/users/mauri870/following{/other_user}","gists_url":"https://api.github.com/users/mauri870/gists{/gist_id}","starred_url":"https://api.github.com/users/mauri870/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauri870/subscriptions","organizations_url":"https://api.github.com/users/mauri870/orgs","repos_url":"https://api.github.com/users/mauri870/repos","events_url":"https://api.github.com/users/mauri870/events{/privacy}","received_events_url":"https://api.github.com/users/mauri870/received_events","type":"User","site_admin":false},"created_at":"2018-07-13T23:30:09Z","updated_at":"2018-07-13T23:30:09Z","author_association":"NONE","body":"Unfortunately I can't build with latest r1.8 tf / serving branch.\r\n\r\nBut the following is working for the r1.7 branch:\r\n\r\n```bash\r\nPROTOC_OPTS='-I lib/tensorflow -I lib/serving --go_out=plugins=grpc:vendor'\r\n\r\neval \"protoc $PROTOC_OPTS lib/serving/tensorflow_serving/apis/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/serving/tensorflow_serving/config/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/serving/tensorflow_serving/util/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/serving/tensorflow_serving/sources/storage_path/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/tensorflow/tensorflow/core/framework/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/tensorflow/tensorflow/core/example/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/tensorflow/tensorflow/core/lib/core/*.proto\"\r\neval \"protoc $PROTOC_OPTS lib/tensorflow/tensorflow/core/protobuf/{saver,meta_graph}.proto\"\r\n```"}}
{"actor":{"display_login":"mauri870"}}