How to create a TensorProto in c#?
<p>This is a snipped of the c# client I created to query the tensorflow server I set up using this tutorial: <a href="https://tensorflow.github.io/serving/serving_inception.html" rel="nofollow">https://tensorflow.github.io/serving/serving_inception.html</a></p>

<pre><code>        var channel = new Channel("TFServer:9000", ChannelCredentials.Insecure);

        var request = new PredictRequest();

        request.ModelSpec = new ModelSpec();
        request.ModelSpec.Name = "inception";

        var imgBuffer = File.ReadAllBytes(@"sample.jpg");

        ByteString jpeg = ByteString.CopyFrom(imgBuffer, 0, imgBuffer.Length);

        var jpgeproto = new TensorProto();
        jpgeproto.StringVal.Add(jpeg);
        jpgeproto.Dtype = DataType.DtStringRef;


        request.Inputs.Add("images", jpgeproto); // new TensorProto{TensorContent = jpeg});

        PredictionClient client = new PredictionClient(channel);
</code></pre>

<p>I found out that most classes needed to be generated from proto files using protoc </p>

<p>The only thing which I cant find is how to construct the TensorProto. The error I keep getting is : Additional information: Status(StatusCode=InvalidArgument, Detail="tensor parsing error: images")</p>

<p>There is a sample client (<a href="https://github.com/tensorflow/serving/blob/master/tensorflow_serving/example/inception_client.py" rel="nofollow">https://github.com/tensorflow/serving/blob/master/tensorflow_serving/example/inception_client.py</a>) byt my Python skills are not sufficient to understand the last bit.</p>

<p>I also implemented that client in another language (Java).  </p>

<p>Try to change </p>

<pre><code>jpgeproto.Dtype = DataType.DtStringRef; 
</code></pre>

<p>to </p>

<pre><code>jpgeproto.Dtype = DataType.DtString;
</code></pre>

<p>You may also need to add a tensor shape with a dimension to your tensor proto.  Here's my working solution in Java, should be similar in C#:</p>

<pre><code>TensorShapeProto.Dim dim = TensorShapeProto.Dim.newBuilder().setSize(1).build();
TensorShapeProto shape = TensorShapeProto.newBuilder().addDim(dim).build();
TensorProto proto = TensorProto.newBuilder()
                .addStringVal(ByteString.copyFrom(imageBytes))
                .setTensorShape(shape)
                .setDtype(DataType.DT_STRING)
                .build();
ModelSpec spec = ModelSpec.newBuilder().setName("inception").build();
PredictRequest r = PredictRequest.newBuilder()
                .setModelSpec(spec)
                .putInputs("images", proto).build();
PredictResponse response = blockingStub.predict(r); 
</code></pre>

c# python tensorflow