├── .gitignore ├── README.md ├── learning ├── Readme.md └── mnist_deep_training.py └── src ├── BaseLibs └── TensorFlowServingClient │ ├── Properties │ └── AssemblyInfo.cs │ ├── Service │ ├── AllocationDescription.cs │ ├── ApiDef.cs │ ├── AttrValue.cs │ ├── Classification.cs │ ├── Cluster.cs │ ├── Config.cs │ ├── ControlFlow.cs │ ├── CostGraph.cs │ ├── Debug.cs │ ├── DeviceAttributes.cs │ ├── DeviceProperties.cs │ ├── Example.cs │ ├── ExampleParserConfiguration.cs │ ├── Feature.cs │ ├── Function.cs │ ├── GetModelMetadata.cs │ ├── Graph.cs │ ├── GraphTransferInfo.cs │ ├── Inference.cs │ ├── Input.cs │ ├── Iterator.cs │ ├── KernelDef.cs │ ├── LogMemory.cs │ ├── Master.cs │ ├── MasterService.cs │ ├── MetaGraph.cs │ ├── Model.cs │ ├── NamedTensor.cs │ ├── NodeDef.cs │ ├── OpDef.cs │ ├── OpGenOverrides.cs │ ├── Predict.cs │ ├── PredictionService.cs │ ├── PredictionServiceGrpc.cs │ ├── ReaderBase.cs │ ├── Regression.cs │ ├── RemoteFusedGraphExecuteInfo.cs │ ├── ResourceHandle.cs │ ├── RewriterConfig.cs │ ├── SavedModel.cs │ ├── Saver.cs │ ├── StepStats.cs │ ├── Summary.cs │ ├── Tensor.cs │ ├── TensorBundle.cs │ ├── TensorDescription.cs │ ├── TensorShape.cs │ ├── TensorSlice.cs │ ├── TensorflowServer.cs │ ├── Types.cs │ ├── Variable.cs │ ├── Versions.cs │ ├── Worker.cs │ └── WorkerService.cs │ ├── TensorFlowServingClient.csproj │ ├── Utils │ ├── ImageUtils.cs │ ├── ModelMethodClasses.cs │ ├── TensorBuilder.cs │ └── TextUtils.cs │ ├── app.config │ ├── build_proto.bat │ └── packages.config ├── Clients ├── ConsoleTensorFlowServingClient │ ├── App.config │ ├── ConsoleTensorFlowServingClient.csproj │ ├── Examples │ │ ├── 0.bmp │ │ ├── 1.bmp │ │ ├── 2.bmp │ │ ├── 3.bmp │ │ ├── 4.bmp │ │ ├── 5.bmp │ │ ├── 6.bmp │ │ ├── 7.bmp │ │ ├── 8.bmp │ │ └── 9.bmp │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config └── WebTensorFlowServingClient │ ├── .gitignore │ ├── ClientApp │ ├── boot-client.tsx │ ├── boot-server.tsx │ ├── components │ │ ├── BarChart.tsx │ │ ├── DrawComponent.tsx │ │ ├── Layout.tsx │ │ ├── NavMenu.tsx │ │ └── NumberPredictComponent.tsx │ ├── configureStore.ts │ ├── css │ │ └── site.css │ ├── routes.tsx │ └── store │ │ ├── NumberPredict.ts │ │ └── index.ts │ ├── Controllers │ ├── HomeController.cs │ └── MnistDeepController.cs │ ├── Models │ ├── PredictionRequest.cs │ └── PredictionResult.cs │ ├── Program.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── WebTensorFlowServingClient.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── npm-shrinkwrap.json │ ├── package.json │ ├── tsconfig.json │ ├── webpack.config.js │ ├── webpack.config.vendor.js │ └── wwwroot │ └── favicon.ico ├── TensorFlowServingCSharp.sln └── content └── preview.png /.gitignore: -------------------------------------------------------------------------------- 1 | /src/BaseLibs/TensorFlowServingClient/protos 2 | packages 3 | .vs 4 | bin 5 | obj 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Depricated] !!!Example of integration between Tensorflow Serving 2.0 and NetCore Client App is available [here](https://github.com/iminakov/TensorFlow2ServingDotNet5Client). 2 | 3 | # TensorFlow Serving MNIST Deep C# client 4 | 5 | This is example of C# clients for TensorFlow Serving gRPC service. 6 | Repository contains the following content: 7 | - [learning](https://github.com/Wertugo/TensorFlowServingCSharpClient/tree/master/learning) - python script with MNIST deep training model prepare and Readme short instructions how to execute TensorFlow serving with this model. 8 | - [ClientBaseLib](https://github.com/Wertugo/TensorFlowServingCSharpClient/tree/master/src/BaseLibs/TensorFlowServingClient) - base library with TF Serving gRPC generated classes and utils classes to create Tensors. 9 | - [Console Client](https://github.com/Wertugo/TensorFlowServingCSharpClient/tree/master/src/Clients/ConsoleTensorFlowServingClient) - simple console client application MNIST prediction example 10 | - [ASP.NET Core 2.0/ ReactJS Client](https://github.com/Wertugo/TensorFlowServingCSharpClient/tree/master/src/Clients/WebTensorFlowServingClient) - SPA application gRPC client for MNIST prediction TensorFlow Serving 11 | 12 | ## How to start web application 13 | - Run TensorFlow Serving with instructions [here](https://github.com/Wertugo/TensorFlowServingCSharpClient/tree/master/learning) 14 | - Open .NET solution. 15 | - Update appsetting.json with TensorFlow Serving address: 16 | ```sh 17 | "TfServer": { 18 | "ServerUrl": "192.168.1.38:9000" 19 | } 20 | ``` 21 | - Start web application with IIS express 22 | - Test prediction 23 | 24 | ![.NET TensorFlow Client](https://raw.githubusercontent.com/Wertugo/TensorFlowServingCSharpClient/master/src/content/preview.png) 25 | 26 | -------------------------------------------------------------------------------- /learning/Readme.md: -------------------------------------------------------------------------------- 1 | # How to train model 2 | 3 | - Install TensorFLow: follow official site instructions: https://www.tensorflow.org/install/ 4 | - Open Visual Studio Code with curent folder and execute in terminal: 5 | 6 | ```sh 7 | python ./mnist_deep_training.py --training_iteration=1000 --model_version=1 "Model Training Folder Path" 8 | ``` 9 | 10 | This is start python script and train MNIST deep model with 1000 iterations. After that it will save model in directory. Please keep in mind to increament model_version parameter value after every training. 11 | 12 | - Install TensorFlow Serving: follow official site instructions: https://www.tensorflow.org/serving/ 13 | 14 | - Start TensorFlow Serving with the following command: 15 | 16 | ```sh 17 | tensorflow_model_server --port=9000 --model_name=mnist --model_base_path="odel Training Folder Path" 18 | ``` 19 | -------------------------------------------------------------------------------- /learning/mnist_deep_training.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import tensorflow as tf 4 | from tensorflow.examples.tutorials.mnist import input_data 5 | 6 | tf.app.flags.DEFINE_integer('training_iteration', 1000, 7 | 'number of training iterations.') 8 | tf.app.flags.DEFINE_integer('model_version', 1, 'version number of the model.') 9 | tf.app.flags.DEFINE_string('work_dir', '/tmp', 'Working directory.') 10 | FLAGS = tf.app.flags.FLAGS 11 | 12 | def main(_): 13 | 14 | mnist = input_data.read_data_sets('MNIST_data', one_hot=True) 15 | 16 | def weight_variable(shape): 17 | initial = tf.truncated_normal(shape, stddev=0.1) 18 | return tf.Variable(initial) 19 | 20 | def bias_variable(shape): 21 | initial = tf.constant(0.1, shape=shape) 22 | return tf.Variable(initial) 23 | 24 | def conv2d(x, W): 25 | return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') 26 | 27 | def max_pool_2x2(x): 28 | return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') 29 | 30 | x = tf.placeholder(tf.float32, shape=[None, 784], name='x') 31 | y_ = tf.placeholder(tf.float32, shape=[None, 10]) 32 | 33 | W = tf.Variable(tf.zeros([784,10])) 34 | b = tf.Variable(tf.zeros([10])) 35 | 36 | y = tf.matmul(x,W) + b 37 | 38 | #First Conv Layer 39 | W_conv1 = weight_variable([5, 5, 1, 32]) 40 | b_conv1 = bias_variable([32]) 41 | 42 | x_image = tf.reshape(x, [-1, 28, 28, 1]) 43 | 44 | h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1) 45 | h_pool1 = max_pool_2x2(h_conv1) 46 | 47 | 48 | #Second Conv Layer 49 | W_conv2 = weight_variable([5, 5, 32, 64]) 50 | b_conv2 = bias_variable([64]) 51 | 52 | h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) 53 | h_pool2 = max_pool_2x2(h_conv2) 54 | 55 | #Conn Layer 56 | W_fc1 = weight_variable([7 * 7 * 64, 1024]) 57 | b_fc1 = bias_variable([1024]) 58 | 59 | h_pool2_flat = tf.reshape(h_pool2, [-1, 7*7*64]) 60 | h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1) 61 | 62 | #DropOut 63 | keep_prob = tf.placeholder(tf.float32, name="keep_prob_training") 64 | h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob) 65 | 66 | #Readout Layer 67 | W_fc2 = weight_variable([1024, 10]) 68 | b_fc2 = bias_variable([10]) 69 | 70 | y_conv = tf.matmul(h_fc1_drop, W_fc2) + b_fc2 71 | 72 | y_softmax = tf.nn.softmax(logits=y_conv, name='y') 73 | cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_softmax), [1])) 74 | train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy) 75 | 76 | values, indices = tf.nn.top_k(y_softmax, 10) 77 | table = tf.contrib.lookup.index_to_string_table_from_tensor(tf.constant([str(i) for i in range(10)])) 78 | prediction_classes = table.lookup(tf.to_int64(indices)) 79 | 80 | correct_prediction = tf.equal(tf.argmax(y_conv, 1), tf.argmax(y_, 1)) 81 | accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) 82 | 83 | sess = tf.InteractiveSession() 84 | sess.run(tf.global_variables_initializer()) 85 | for i in range(FLAGS.training_iteration): 86 | batch = mnist.train.next_batch(50) 87 | if i % 100 == 0: 88 | train_accuracy = accuracy.eval(feed_dict={x: batch[0], y_: batch[1], keep_prob: 1.0}) 89 | print('step %d, training accuracy %g' % (i, train_accuracy)) 90 | train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5}) 91 | 92 | export_path_base = sys.argv[-1] 93 | print ('Try continue here !!! ', export_path_base) 94 | export_path = os.path.join( 95 | tf.compat.as_bytes(export_path_base), 96 | tf.compat.as_bytes(str(FLAGS.model_version))) 97 | print ('Exporting trained model to', export_path) 98 | builder = tf.saved_model.builder.SavedModelBuilder(export_path) 99 | 100 | tensor_info_x = tf.saved_model.utils.build_tensor_info(x) 101 | tensor_info_y = tf.saved_model.utils.build_tensor_info(y_softmax) 102 | tensor_info_keep_prob = tf.saved_model.utils.build_tensor_info(keep_prob) 103 | prediction_signature = ( 104 | tf.saved_model.signature_def_utils.build_signature_def( 105 | inputs={'images': tensor_info_x, 'keep_prob': tensor_info_keep_prob}, 106 | outputs={'scores': tensor_info_y}, 107 | method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME)) 108 | legacy_init_op = tf.group(tf.tables_initializer(), name='legacy_init_op') 109 | builder.add_meta_graph_and_variables( 110 | sess, [tf.saved_model.tag_constants.SERVING], 111 | signature_def_map={ 112 | 'predict_images': 113 | prediction_signature, 114 | }, 115 | legacy_init_op=legacy_init_op) 116 | builder.save() 117 | print ('Done exporting!') 118 | 119 | 120 | if __name__ == '__main__': 121 | tf.app.run() -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TensorFlowServingClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TensorFlowServingClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("73169028-08e0-45d3-8673-241b7164163a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/AllocationDescription.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/allocation_description.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/allocation_description.proto 13 | public static partial class AllocationDescriptionReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/allocation_description.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static AllocationDescriptionReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CjZ0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL2FsbG9jYXRpb25fZGVzY3Jp", 26 | "cHRpb24ucHJvdG8SCnRlbnNvcmZsb3ciowEKFUFsbG9jYXRpb25EZXNjcmlw", 27 | "dGlvbhIXCg9yZXF1ZXN0ZWRfYnl0ZXMYASABKAMSFwoPYWxsb2NhdGVkX2J5", 28 | "dGVzGAIgASgDEhYKDmFsbG9jYXRvcl9uYW1lGAMgASgJEhUKDWFsbG9jYXRp", 29 | "b25faWQYBCABKAMSHAoUaGFzX3NpbmdsZV9yZWZlcmVuY2UYBSABKAgSCwoD", 30 | "cHRyGAYgASgEQjwKGG9yZy50ZW5zb3JmbG93LmZyYW1ld29ya0IbQWxsb2Nh", 31 | "dGlvbkRlc2NyaXB0aW9uUHJvdG9zUAH4AQFiBnByb3RvMw==")); 32 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 33 | new pbr::FileDescriptor[] { }, 34 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 35 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.AllocationDescription), global::Tensorflow.AllocationDescription.Parser, new[]{ "RequestedBytes", "AllocatedBytes", "AllocatorName", "AllocationId", "HasSingleReference", "Ptr" }, null, null, null) 36 | })); 37 | } 38 | #endregion 39 | 40 | } 41 | #region Messages 42 | public sealed partial class AllocationDescription : pb::IMessage { 43 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AllocationDescription()); 44 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 45 | public static pb::MessageParser Parser { get { return _parser; } } 46 | 47 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 48 | public static pbr::MessageDescriptor Descriptor { 49 | get { return global::Tensorflow.AllocationDescriptionReflection.Descriptor.MessageTypes[0]; } 50 | } 51 | 52 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 53 | pbr::MessageDescriptor pb::IMessage.Descriptor { 54 | get { return Descriptor; } 55 | } 56 | 57 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 58 | public AllocationDescription() { 59 | OnConstruction(); 60 | } 61 | 62 | partial void OnConstruction(); 63 | 64 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 65 | public AllocationDescription(AllocationDescription other) : this() { 66 | requestedBytes_ = other.requestedBytes_; 67 | allocatedBytes_ = other.allocatedBytes_; 68 | allocatorName_ = other.allocatorName_; 69 | allocationId_ = other.allocationId_; 70 | hasSingleReference_ = other.hasSingleReference_; 71 | ptr_ = other.ptr_; 72 | } 73 | 74 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 75 | public AllocationDescription Clone() { 76 | return new AllocationDescription(this); 77 | } 78 | 79 | /// Field number for the "requested_bytes" field. 80 | public const int RequestedBytesFieldNumber = 1; 81 | private long requestedBytes_; 82 | /// 83 | /// Total number of bytes requested 84 | /// 85 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 86 | public long RequestedBytes { 87 | get { return requestedBytes_; } 88 | set { 89 | requestedBytes_ = value; 90 | } 91 | } 92 | 93 | /// Field number for the "allocated_bytes" field. 94 | public const int AllocatedBytesFieldNumber = 2; 95 | private long allocatedBytes_; 96 | /// 97 | /// Total number of bytes allocated if known 98 | /// 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 100 | public long AllocatedBytes { 101 | get { return allocatedBytes_; } 102 | set { 103 | allocatedBytes_ = value; 104 | } 105 | } 106 | 107 | /// Field number for the "allocator_name" field. 108 | public const int AllocatorNameFieldNumber = 3; 109 | private string allocatorName_ = ""; 110 | /// 111 | /// Name of the allocator used 112 | /// 113 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 114 | public string AllocatorName { 115 | get { return allocatorName_; } 116 | set { 117 | allocatorName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 118 | } 119 | } 120 | 121 | /// Field number for the "allocation_id" field. 122 | public const int AllocationIdFieldNumber = 4; 123 | private long allocationId_; 124 | /// 125 | /// Identifier of the allocated buffer if known 126 | /// 127 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 128 | public long AllocationId { 129 | get { return allocationId_; } 130 | set { 131 | allocationId_ = value; 132 | } 133 | } 134 | 135 | /// Field number for the "has_single_reference" field. 136 | public const int HasSingleReferenceFieldNumber = 5; 137 | private bool hasSingleReference_; 138 | /// 139 | /// Set if this tensor only has one remaining reference 140 | /// 141 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 142 | public bool HasSingleReference { 143 | get { return hasSingleReference_; } 144 | set { 145 | hasSingleReference_ = value; 146 | } 147 | } 148 | 149 | /// Field number for the "ptr" field. 150 | public const int PtrFieldNumber = 6; 151 | private ulong ptr_; 152 | /// 153 | /// Address of the allocation. 154 | /// 155 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 156 | public ulong Ptr { 157 | get { return ptr_; } 158 | set { 159 | ptr_ = value; 160 | } 161 | } 162 | 163 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 164 | public override bool Equals(object other) { 165 | return Equals(other as AllocationDescription); 166 | } 167 | 168 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 169 | public bool Equals(AllocationDescription other) { 170 | if (ReferenceEquals(other, null)) { 171 | return false; 172 | } 173 | if (ReferenceEquals(other, this)) { 174 | return true; 175 | } 176 | if (RequestedBytes != other.RequestedBytes) return false; 177 | if (AllocatedBytes != other.AllocatedBytes) return false; 178 | if (AllocatorName != other.AllocatorName) return false; 179 | if (AllocationId != other.AllocationId) return false; 180 | if (HasSingleReference != other.HasSingleReference) return false; 181 | if (Ptr != other.Ptr) return false; 182 | return true; 183 | } 184 | 185 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 186 | public override int GetHashCode() { 187 | int hash = 1; 188 | if (RequestedBytes != 0L) hash ^= RequestedBytes.GetHashCode(); 189 | if (AllocatedBytes != 0L) hash ^= AllocatedBytes.GetHashCode(); 190 | if (AllocatorName.Length != 0) hash ^= AllocatorName.GetHashCode(); 191 | if (AllocationId != 0L) hash ^= AllocationId.GetHashCode(); 192 | if (HasSingleReference != false) hash ^= HasSingleReference.GetHashCode(); 193 | if (Ptr != 0UL) hash ^= Ptr.GetHashCode(); 194 | return hash; 195 | } 196 | 197 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 198 | public override string ToString() { 199 | return pb::JsonFormatter.ToDiagnosticString(this); 200 | } 201 | 202 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 203 | public void WriteTo(pb::CodedOutputStream output) { 204 | if (RequestedBytes != 0L) { 205 | output.WriteRawTag(8); 206 | output.WriteInt64(RequestedBytes); 207 | } 208 | if (AllocatedBytes != 0L) { 209 | output.WriteRawTag(16); 210 | output.WriteInt64(AllocatedBytes); 211 | } 212 | if (AllocatorName.Length != 0) { 213 | output.WriteRawTag(26); 214 | output.WriteString(AllocatorName); 215 | } 216 | if (AllocationId != 0L) { 217 | output.WriteRawTag(32); 218 | output.WriteInt64(AllocationId); 219 | } 220 | if (HasSingleReference != false) { 221 | output.WriteRawTag(40); 222 | output.WriteBool(HasSingleReference); 223 | } 224 | if (Ptr != 0UL) { 225 | output.WriteRawTag(48); 226 | output.WriteUInt64(Ptr); 227 | } 228 | } 229 | 230 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 231 | public int CalculateSize() { 232 | int size = 0; 233 | if (RequestedBytes != 0L) { 234 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(RequestedBytes); 235 | } 236 | if (AllocatedBytes != 0L) { 237 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(AllocatedBytes); 238 | } 239 | if (AllocatorName.Length != 0) { 240 | size += 1 + pb::CodedOutputStream.ComputeStringSize(AllocatorName); 241 | } 242 | if (AllocationId != 0L) { 243 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(AllocationId); 244 | } 245 | if (HasSingleReference != false) { 246 | size += 1 + 1; 247 | } 248 | if (Ptr != 0UL) { 249 | size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Ptr); 250 | } 251 | return size; 252 | } 253 | 254 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 255 | public void MergeFrom(AllocationDescription other) { 256 | if (other == null) { 257 | return; 258 | } 259 | if (other.RequestedBytes != 0L) { 260 | RequestedBytes = other.RequestedBytes; 261 | } 262 | if (other.AllocatedBytes != 0L) { 263 | AllocatedBytes = other.AllocatedBytes; 264 | } 265 | if (other.AllocatorName.Length != 0) { 266 | AllocatorName = other.AllocatorName; 267 | } 268 | if (other.AllocationId != 0L) { 269 | AllocationId = other.AllocationId; 270 | } 271 | if (other.HasSingleReference != false) { 272 | HasSingleReference = other.HasSingleReference; 273 | } 274 | if (other.Ptr != 0UL) { 275 | Ptr = other.Ptr; 276 | } 277 | } 278 | 279 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 280 | public void MergeFrom(pb::CodedInputStream input) { 281 | uint tag; 282 | while ((tag = input.ReadTag()) != 0) { 283 | switch(tag) { 284 | default: 285 | input.SkipLastField(); 286 | break; 287 | case 8: { 288 | RequestedBytes = input.ReadInt64(); 289 | break; 290 | } 291 | case 16: { 292 | AllocatedBytes = input.ReadInt64(); 293 | break; 294 | } 295 | case 26: { 296 | AllocatorName = input.ReadString(); 297 | break; 298 | } 299 | case 32: { 300 | AllocationId = input.ReadInt64(); 301 | break; 302 | } 303 | case 40: { 304 | HasSingleReference = input.ReadBool(); 305 | break; 306 | } 307 | case 48: { 308 | Ptr = input.ReadUInt64(); 309 | break; 310 | } 311 | } 312 | } 313 | } 314 | 315 | } 316 | 317 | #endregion 318 | 319 | } 320 | 321 | #endregion Designer generated code 322 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Cluster.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/protobuf/cluster.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/protobuf/cluster.proto 13 | public static partial class ClusterReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/protobuf/cluster.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static ClusterReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CiZ0ZW5zb3JmbG93L2NvcmUvcHJvdG9idWYvY2x1c3Rlci5wcm90bxIKdGVu", 26 | "c29yZmxvdyJyCgZKb2JEZWYSDAoEbmFtZRgBIAEoCRIsCgV0YXNrcxgCIAMo", 27 | "CzIdLnRlbnNvcmZsb3cuSm9iRGVmLlRhc2tzRW50cnkaLAoKVGFza3NFbnRy", 28 | "eRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAk6AjgBIi0KCkNsdXN0ZXJE", 29 | "ZWYSHwoDam9iGAEgAygLMhIudGVuc29yZmxvdy5Kb2JEZWZCMAoab3JnLnRl", 30 | "bnNvcmZsb3cuZGlzdHJ1bnRpbWVCDUNsdXN0ZXJQcm90b3NQAfgBAWIGcHJv", 31 | "dG8z")); 32 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 33 | new pbr::FileDescriptor[] { }, 34 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 35 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.JobDef), global::Tensorflow.JobDef.Parser, new[]{ "Name", "Tasks" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, }), 36 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.ClusterDef), global::Tensorflow.ClusterDef.Parser, new[]{ "Job" }, null, null, null) 37 | })); 38 | } 39 | #endregion 40 | 41 | } 42 | #region Messages 43 | /// 44 | /// Defines a single job in a TensorFlow cluster. 45 | /// 46 | public sealed partial class JobDef : pb::IMessage { 47 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new JobDef()); 48 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 49 | public static pb::MessageParser Parser { get { return _parser; } } 50 | 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 52 | public static pbr::MessageDescriptor Descriptor { 53 | get { return global::Tensorflow.ClusterReflection.Descriptor.MessageTypes[0]; } 54 | } 55 | 56 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 57 | pbr::MessageDescriptor pb::IMessage.Descriptor { 58 | get { return Descriptor; } 59 | } 60 | 61 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 62 | public JobDef() { 63 | OnConstruction(); 64 | } 65 | 66 | partial void OnConstruction(); 67 | 68 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 69 | public JobDef(JobDef other) : this() { 70 | name_ = other.name_; 71 | tasks_ = other.tasks_.Clone(); 72 | } 73 | 74 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 75 | public JobDef Clone() { 76 | return new JobDef(this); 77 | } 78 | 79 | /// Field number for the "name" field. 80 | public const int NameFieldNumber = 1; 81 | private string name_ = ""; 82 | /// 83 | /// The name of this job. 84 | /// 85 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 86 | public string Name { 87 | get { return name_; } 88 | set { 89 | name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 90 | } 91 | } 92 | 93 | /// Field number for the "tasks" field. 94 | public const int TasksFieldNumber = 2; 95 | private static readonly pbc::MapField.Codec _map_tasks_codec 96 | = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForString(18), 18); 97 | private readonly pbc::MapField tasks_ = new pbc::MapField(); 98 | /// 99 | /// Mapping from task ID to "hostname:port" string. 100 | /// 101 | /// If the `name` field contains "worker", and the `tasks` map contains a 102 | /// mapping from 7 to "example.org:2222", then the device prefix 103 | /// "/job:worker/task:7" will be assigned to "example.org:2222". 104 | /// 105 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 106 | public pbc::MapField Tasks { 107 | get { return tasks_; } 108 | } 109 | 110 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 111 | public override bool Equals(object other) { 112 | return Equals(other as JobDef); 113 | } 114 | 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public bool Equals(JobDef other) { 117 | if (ReferenceEquals(other, null)) { 118 | return false; 119 | } 120 | if (ReferenceEquals(other, this)) { 121 | return true; 122 | } 123 | if (Name != other.Name) return false; 124 | if (!Tasks.Equals(other.Tasks)) return false; 125 | return true; 126 | } 127 | 128 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 129 | public override int GetHashCode() { 130 | int hash = 1; 131 | if (Name.Length != 0) hash ^= Name.GetHashCode(); 132 | hash ^= Tasks.GetHashCode(); 133 | return hash; 134 | } 135 | 136 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 137 | public override string ToString() { 138 | return pb::JsonFormatter.ToDiagnosticString(this); 139 | } 140 | 141 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 142 | public void WriteTo(pb::CodedOutputStream output) { 143 | if (Name.Length != 0) { 144 | output.WriteRawTag(10); 145 | output.WriteString(Name); 146 | } 147 | tasks_.WriteTo(output, _map_tasks_codec); 148 | } 149 | 150 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 151 | public int CalculateSize() { 152 | int size = 0; 153 | if (Name.Length != 0) { 154 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); 155 | } 156 | size += tasks_.CalculateSize(_map_tasks_codec); 157 | return size; 158 | } 159 | 160 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 161 | public void MergeFrom(JobDef other) { 162 | if (other == null) { 163 | return; 164 | } 165 | if (other.Name.Length != 0) { 166 | Name = other.Name; 167 | } 168 | tasks_.Add(other.tasks_); 169 | } 170 | 171 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 172 | public void MergeFrom(pb::CodedInputStream input) { 173 | uint tag; 174 | while ((tag = input.ReadTag()) != 0) { 175 | switch(tag) { 176 | default: 177 | input.SkipLastField(); 178 | break; 179 | case 10: { 180 | Name = input.ReadString(); 181 | break; 182 | } 183 | case 18: { 184 | tasks_.AddEntriesFrom(input, _map_tasks_codec); 185 | break; 186 | } 187 | } 188 | } 189 | } 190 | 191 | } 192 | 193 | /// 194 | /// Defines a TensorFlow cluster as a set of jobs. 195 | /// 196 | public sealed partial class ClusterDef : pb::IMessage { 197 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ClusterDef()); 198 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 199 | public static pb::MessageParser Parser { get { return _parser; } } 200 | 201 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 202 | public static pbr::MessageDescriptor Descriptor { 203 | get { return global::Tensorflow.ClusterReflection.Descriptor.MessageTypes[1]; } 204 | } 205 | 206 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 207 | pbr::MessageDescriptor pb::IMessage.Descriptor { 208 | get { return Descriptor; } 209 | } 210 | 211 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 212 | public ClusterDef() { 213 | OnConstruction(); 214 | } 215 | 216 | partial void OnConstruction(); 217 | 218 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 219 | public ClusterDef(ClusterDef other) : this() { 220 | job_ = other.job_.Clone(); 221 | } 222 | 223 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 224 | public ClusterDef Clone() { 225 | return new ClusterDef(this); 226 | } 227 | 228 | /// Field number for the "job" field. 229 | public const int JobFieldNumber = 1; 230 | private static readonly pb::FieldCodec _repeated_job_codec 231 | = pb::FieldCodec.ForMessage(10, global::Tensorflow.JobDef.Parser); 232 | private readonly pbc::RepeatedField job_ = new pbc::RepeatedField(); 233 | /// 234 | /// The jobs that comprise the cluster. 235 | /// 236 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 237 | public pbc::RepeatedField Job { 238 | get { return job_; } 239 | } 240 | 241 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 242 | public override bool Equals(object other) { 243 | return Equals(other as ClusterDef); 244 | } 245 | 246 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 247 | public bool Equals(ClusterDef other) { 248 | if (ReferenceEquals(other, null)) { 249 | return false; 250 | } 251 | if (ReferenceEquals(other, this)) { 252 | return true; 253 | } 254 | if(!job_.Equals(other.job_)) return false; 255 | return true; 256 | } 257 | 258 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 259 | public override int GetHashCode() { 260 | int hash = 1; 261 | hash ^= job_.GetHashCode(); 262 | return hash; 263 | } 264 | 265 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 266 | public override string ToString() { 267 | return pb::JsonFormatter.ToDiagnosticString(this); 268 | } 269 | 270 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 271 | public void WriteTo(pb::CodedOutputStream output) { 272 | job_.WriteTo(output, _repeated_job_codec); 273 | } 274 | 275 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 276 | public int CalculateSize() { 277 | int size = 0; 278 | size += job_.CalculateSize(_repeated_job_codec); 279 | return size; 280 | } 281 | 282 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 283 | public void MergeFrom(ClusterDef other) { 284 | if (other == null) { 285 | return; 286 | } 287 | job_.Add(other.job_); 288 | } 289 | 290 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 291 | public void MergeFrom(pb::CodedInputStream input) { 292 | uint tag; 293 | while ((tag = input.ReadTag()) != 0) { 294 | switch(tag) { 295 | default: 296 | input.SkipLastField(); 297 | break; 298 | case 10: { 299 | job_.AddEntriesFrom(input, _repeated_job_codec); 300 | break; 301 | } 302 | } 303 | } 304 | } 305 | 306 | } 307 | 308 | #endregion 309 | 310 | } 311 | 312 | #endregion Designer generated code 313 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Example.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/example/example.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/example/example.proto 13 | public static partial class ExampleReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/example/example.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static ExampleReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CiV0ZW5zb3JmbG93L2NvcmUvZXhhbXBsZS9leGFtcGxlLnByb3RvEgp0ZW5z", 26 | "b3JmbG93GiV0ZW5zb3JmbG93L2NvcmUvZXhhbXBsZS9mZWF0dXJlLnByb3Rv", 27 | "IjEKB0V4YW1wbGUSJgoIZmVhdHVyZXMYASABKAsyFC50ZW5zb3JmbG93LkZl", 28 | "YXR1cmVzImkKD1NlcXVlbmNlRXhhbXBsZRIlCgdjb250ZXh0GAEgASgLMhQu", 29 | "dGVuc29yZmxvdy5GZWF0dXJlcxIvCg1mZWF0dXJlX2xpc3RzGAIgASgLMhgu", 30 | "dGVuc29yZmxvdy5GZWF0dXJlTGlzdHNCLAoWb3JnLnRlbnNvcmZsb3cuZXhh", 31 | "bXBsZUINRXhhbXBsZVByb3Rvc1AB+AEBYgZwcm90bzM=")); 32 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 33 | new pbr::FileDescriptor[] { global::Tensorflow.FeatureReflection.Descriptor, }, 34 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 35 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.Example), global::Tensorflow.Example.Parser, new[]{ "Features" }, null, null, null), 36 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.SequenceExample), global::Tensorflow.SequenceExample.Parser, new[]{ "Context", "FeatureLists" }, null, null, null) 37 | })); 38 | } 39 | #endregion 40 | 41 | } 42 | #region Messages 43 | public sealed partial class Example : pb::IMessage { 44 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Example()); 45 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 46 | public static pb::MessageParser Parser { get { return _parser; } } 47 | 48 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 49 | public static pbr::MessageDescriptor Descriptor { 50 | get { return global::Tensorflow.ExampleReflection.Descriptor.MessageTypes[0]; } 51 | } 52 | 53 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 54 | pbr::MessageDescriptor pb::IMessage.Descriptor { 55 | get { return Descriptor; } 56 | } 57 | 58 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 59 | public Example() { 60 | OnConstruction(); 61 | } 62 | 63 | partial void OnConstruction(); 64 | 65 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 66 | public Example(Example other) : this() { 67 | Features = other.features_ != null ? other.Features.Clone() : null; 68 | } 69 | 70 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 71 | public Example Clone() { 72 | return new Example(this); 73 | } 74 | 75 | /// Field number for the "features" field. 76 | public const int FeaturesFieldNumber = 1; 77 | private global::Tensorflow.Features features_; 78 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 79 | public global::Tensorflow.Features Features { 80 | get { return features_; } 81 | set { 82 | features_ = value; 83 | } 84 | } 85 | 86 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 87 | public override bool Equals(object other) { 88 | return Equals(other as Example); 89 | } 90 | 91 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 92 | public bool Equals(Example other) { 93 | if (ReferenceEquals(other, null)) { 94 | return false; 95 | } 96 | if (ReferenceEquals(other, this)) { 97 | return true; 98 | } 99 | if (!object.Equals(Features, other.Features)) return false; 100 | return true; 101 | } 102 | 103 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 104 | public override int GetHashCode() { 105 | int hash = 1; 106 | if (features_ != null) hash ^= Features.GetHashCode(); 107 | return hash; 108 | } 109 | 110 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 111 | public override string ToString() { 112 | return pb::JsonFormatter.ToDiagnosticString(this); 113 | } 114 | 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public void WriteTo(pb::CodedOutputStream output) { 117 | if (features_ != null) { 118 | output.WriteRawTag(10); 119 | output.WriteMessage(Features); 120 | } 121 | } 122 | 123 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 124 | public int CalculateSize() { 125 | int size = 0; 126 | if (features_ != null) { 127 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Features); 128 | } 129 | return size; 130 | } 131 | 132 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 133 | public void MergeFrom(Example other) { 134 | if (other == null) { 135 | return; 136 | } 137 | if (other.features_ != null) { 138 | if (features_ == null) { 139 | features_ = new global::Tensorflow.Features(); 140 | } 141 | Features.MergeFrom(other.Features); 142 | } 143 | } 144 | 145 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 146 | public void MergeFrom(pb::CodedInputStream input) { 147 | uint tag; 148 | while ((tag = input.ReadTag()) != 0) { 149 | switch(tag) { 150 | default: 151 | input.SkipLastField(); 152 | break; 153 | case 10: { 154 | if (features_ == null) { 155 | features_ = new global::Tensorflow.Features(); 156 | } 157 | input.ReadMessage(features_); 158 | break; 159 | } 160 | } 161 | } 162 | } 163 | 164 | } 165 | 166 | public sealed partial class SequenceExample : pb::IMessage { 167 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SequenceExample()); 168 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 169 | public static pb::MessageParser Parser { get { return _parser; } } 170 | 171 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 172 | public static pbr::MessageDescriptor Descriptor { 173 | get { return global::Tensorflow.ExampleReflection.Descriptor.MessageTypes[1]; } 174 | } 175 | 176 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 177 | pbr::MessageDescriptor pb::IMessage.Descriptor { 178 | get { return Descriptor; } 179 | } 180 | 181 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 182 | public SequenceExample() { 183 | OnConstruction(); 184 | } 185 | 186 | partial void OnConstruction(); 187 | 188 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 189 | public SequenceExample(SequenceExample other) : this() { 190 | Context = other.context_ != null ? other.Context.Clone() : null; 191 | FeatureLists = other.featureLists_ != null ? other.FeatureLists.Clone() : null; 192 | } 193 | 194 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 195 | public SequenceExample Clone() { 196 | return new SequenceExample(this); 197 | } 198 | 199 | /// Field number for the "context" field. 200 | public const int ContextFieldNumber = 1; 201 | private global::Tensorflow.Features context_; 202 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 203 | public global::Tensorflow.Features Context { 204 | get { return context_; } 205 | set { 206 | context_ = value; 207 | } 208 | } 209 | 210 | /// Field number for the "feature_lists" field. 211 | public const int FeatureListsFieldNumber = 2; 212 | private global::Tensorflow.FeatureLists featureLists_; 213 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 214 | public global::Tensorflow.FeatureLists FeatureLists { 215 | get { return featureLists_; } 216 | set { 217 | featureLists_ = value; 218 | } 219 | } 220 | 221 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 222 | public override bool Equals(object other) { 223 | return Equals(other as SequenceExample); 224 | } 225 | 226 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 227 | public bool Equals(SequenceExample other) { 228 | if (ReferenceEquals(other, null)) { 229 | return false; 230 | } 231 | if (ReferenceEquals(other, this)) { 232 | return true; 233 | } 234 | if (!object.Equals(Context, other.Context)) return false; 235 | if (!object.Equals(FeatureLists, other.FeatureLists)) return false; 236 | return true; 237 | } 238 | 239 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 240 | public override int GetHashCode() { 241 | int hash = 1; 242 | if (context_ != null) hash ^= Context.GetHashCode(); 243 | if (featureLists_ != null) hash ^= FeatureLists.GetHashCode(); 244 | return hash; 245 | } 246 | 247 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 248 | public override string ToString() { 249 | return pb::JsonFormatter.ToDiagnosticString(this); 250 | } 251 | 252 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 253 | public void WriteTo(pb::CodedOutputStream output) { 254 | if (context_ != null) { 255 | output.WriteRawTag(10); 256 | output.WriteMessage(Context); 257 | } 258 | if (featureLists_ != null) { 259 | output.WriteRawTag(18); 260 | output.WriteMessage(FeatureLists); 261 | } 262 | } 263 | 264 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 265 | public int CalculateSize() { 266 | int size = 0; 267 | if (context_ != null) { 268 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); 269 | } 270 | if (featureLists_ != null) { 271 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(FeatureLists); 272 | } 273 | return size; 274 | } 275 | 276 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 277 | public void MergeFrom(SequenceExample other) { 278 | if (other == null) { 279 | return; 280 | } 281 | if (other.context_ != null) { 282 | if (context_ == null) { 283 | context_ = new global::Tensorflow.Features(); 284 | } 285 | Context.MergeFrom(other.Context); 286 | } 287 | if (other.featureLists_ != null) { 288 | if (featureLists_ == null) { 289 | featureLists_ = new global::Tensorflow.FeatureLists(); 290 | } 291 | FeatureLists.MergeFrom(other.FeatureLists); 292 | } 293 | } 294 | 295 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 296 | public void MergeFrom(pb::CodedInputStream input) { 297 | uint tag; 298 | while ((tag = input.ReadTag()) != 0) { 299 | switch(tag) { 300 | default: 301 | input.SkipLastField(); 302 | break; 303 | case 10: { 304 | if (context_ == null) { 305 | context_ = new global::Tensorflow.Features(); 306 | } 307 | input.ReadMessage(context_); 308 | break; 309 | } 310 | case 18: { 311 | if (featureLists_ == null) { 312 | featureLists_ = new global::Tensorflow.FeatureLists(); 313 | } 314 | input.ReadMessage(featureLists_); 315 | break; 316 | } 317 | } 318 | } 319 | } 320 | 321 | } 322 | 323 | #endregion 324 | 325 | } 326 | 327 | #endregion Designer generated code 328 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Graph.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/graph.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/graph.proto 13 | public static partial class GraphReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/graph.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static GraphReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CiV0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL2dyYXBoLnByb3RvEgp0ZW5z", 26 | "b3JmbG93Gih0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL25vZGVfZGVmLnBy", 27 | "b3RvGih0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL2Z1bmN0aW9uLnByb3Rv", 28 | "Gih0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3ZlcnNpb25zLnByb3RvIp0B", 29 | "CghHcmFwaERlZhIhCgRub2RlGAEgAygLMhMudGVuc29yZmxvdy5Ob2RlRGVm", 30 | "EigKCHZlcnNpb25zGAQgASgLMhYudGVuc29yZmxvdy5WZXJzaW9uRGVmEhMK", 31 | "B3ZlcnNpb24YAyABKAVCAhgBEi8KB2xpYnJhcnkYAiABKAsyHi50ZW5zb3Jm", 32 | "bG93LkZ1bmN0aW9uRGVmTGlicmFyeUIsChhvcmcudGVuc29yZmxvdy5mcmFt", 33 | "ZXdvcmtCC0dyYXBoUHJvdG9zUAH4AQFiBnByb3RvMw==")); 34 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 35 | new pbr::FileDescriptor[] { global::Tensorflow.NodeDefReflection.Descriptor, global::Tensorflow.FunctionReflection.Descriptor, global::Tensorflow.VersionsReflection.Descriptor, }, 36 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 37 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.GraphDef), global::Tensorflow.GraphDef.Parser, new[]{ "Node", "Versions", "Version", "Library" }, null, null, null) 38 | })); 39 | } 40 | #endregion 41 | 42 | } 43 | #region Messages 44 | /// 45 | /// Represents the graph of operations 46 | /// 47 | public sealed partial class GraphDef : pb::IMessage { 48 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GraphDef()); 49 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 50 | public static pb::MessageParser Parser { get { return _parser; } } 51 | 52 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 53 | public static pbr::MessageDescriptor Descriptor { 54 | get { return global::Tensorflow.GraphReflection.Descriptor.MessageTypes[0]; } 55 | } 56 | 57 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 58 | pbr::MessageDescriptor pb::IMessage.Descriptor { 59 | get { return Descriptor; } 60 | } 61 | 62 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 63 | public GraphDef() { 64 | OnConstruction(); 65 | } 66 | 67 | partial void OnConstruction(); 68 | 69 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 70 | public GraphDef(GraphDef other) : this() { 71 | node_ = other.node_.Clone(); 72 | Versions = other.versions_ != null ? other.Versions.Clone() : null; 73 | version_ = other.version_; 74 | Library = other.library_ != null ? other.Library.Clone() : null; 75 | } 76 | 77 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 78 | public GraphDef Clone() { 79 | return new GraphDef(this); 80 | } 81 | 82 | /// Field number for the "node" field. 83 | public const int NodeFieldNumber = 1; 84 | private static readonly pb::FieldCodec _repeated_node_codec 85 | = pb::FieldCodec.ForMessage(10, global::Tensorflow.NodeDef.Parser); 86 | private readonly pbc::RepeatedField node_ = new pbc::RepeatedField(); 87 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 88 | public pbc::RepeatedField Node { 89 | get { return node_; } 90 | } 91 | 92 | /// Field number for the "versions" field. 93 | public const int VersionsFieldNumber = 4; 94 | private global::Tensorflow.VersionDef versions_; 95 | /// 96 | /// Compatibility versions of the graph. See core/public/version.h for version 97 | /// history. The GraphDef version is distinct from the TensorFlow version, and 98 | /// each release of TensorFlow will support a range of GraphDef versions. 99 | /// 100 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 101 | public global::Tensorflow.VersionDef Versions { 102 | get { return versions_; } 103 | set { 104 | versions_ = value; 105 | } 106 | } 107 | 108 | /// Field number for the "version" field. 109 | public const int VersionFieldNumber = 3; 110 | private int version_; 111 | /// 112 | /// Deprecated single version field; use versions above instead. Since all 113 | /// GraphDef changes before "versions" was introduced were forward 114 | /// compatible, this field is entirely ignored. 115 | /// 116 | [global::System.ObsoleteAttribute] 117 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 118 | public int Version { 119 | get { return version_; } 120 | set { 121 | version_ = value; 122 | } 123 | } 124 | 125 | /// Field number for the "library" field. 126 | public const int LibraryFieldNumber = 2; 127 | private global::Tensorflow.FunctionDefLibrary library_; 128 | /// 129 | /// EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. 130 | /// 131 | /// "library" provides user-defined functions. 132 | /// 133 | /// Naming: 134 | /// * library.function.name are in a flat namespace. 135 | /// NOTE: We may need to change it to be hierarchical to support 136 | /// different orgs. E.g., 137 | /// { "/google/nn", { ... }}, 138 | /// { "/google/vision", { ... }} 139 | /// { "/org_foo/module_bar", { ... }} 140 | /// map<string, FunctionDefLib> named_lib; 141 | /// * If node[i].op is the name of one function in "library", 142 | /// node[i] is deemed as a function call. Otherwise, node[i].op 143 | /// must be a primitive operation supported by the runtime. 144 | /// 145 | /// Function call semantics: 146 | /// 147 | /// * The callee may start execution as soon as some of its inputs 148 | /// are ready. The caller may want to use Tuple() mechanism to 149 | /// ensure all inputs are ready in the same time. 150 | /// 151 | /// * The consumer of return values may start executing as soon as 152 | /// the return values the consumer depends on are ready. The 153 | /// consumer may want to use Tuple() mechanism to ensure the 154 | /// consumer does not start until all return values of the callee 155 | /// function are ready. 156 | /// 157 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 158 | public global::Tensorflow.FunctionDefLibrary Library { 159 | get { return library_; } 160 | set { 161 | library_ = value; 162 | } 163 | } 164 | 165 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 166 | public override bool Equals(object other) { 167 | return Equals(other as GraphDef); 168 | } 169 | 170 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 171 | public bool Equals(GraphDef other) { 172 | if (ReferenceEquals(other, null)) { 173 | return false; 174 | } 175 | if (ReferenceEquals(other, this)) { 176 | return true; 177 | } 178 | if(!node_.Equals(other.node_)) return false; 179 | if (!object.Equals(Versions, other.Versions)) return false; 180 | if (Version != other.Version) return false; 181 | if (!object.Equals(Library, other.Library)) return false; 182 | return true; 183 | } 184 | 185 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 186 | public override int GetHashCode() { 187 | int hash = 1; 188 | hash ^= node_.GetHashCode(); 189 | if (versions_ != null) hash ^= Versions.GetHashCode(); 190 | if (Version != 0) hash ^= Version.GetHashCode(); 191 | if (library_ != null) hash ^= Library.GetHashCode(); 192 | return hash; 193 | } 194 | 195 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 196 | public override string ToString() { 197 | return pb::JsonFormatter.ToDiagnosticString(this); 198 | } 199 | 200 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 201 | public void WriteTo(pb::CodedOutputStream output) { 202 | node_.WriteTo(output, _repeated_node_codec); 203 | if (library_ != null) { 204 | output.WriteRawTag(18); 205 | output.WriteMessage(Library); 206 | } 207 | if (Version != 0) { 208 | output.WriteRawTag(24); 209 | output.WriteInt32(Version); 210 | } 211 | if (versions_ != null) { 212 | output.WriteRawTag(34); 213 | output.WriteMessage(Versions); 214 | } 215 | } 216 | 217 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 218 | public int CalculateSize() { 219 | int size = 0; 220 | size += node_.CalculateSize(_repeated_node_codec); 221 | if (versions_ != null) { 222 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Versions); 223 | } 224 | if (Version != 0) { 225 | size += 1 + pb::CodedOutputStream.ComputeInt32Size(Version); 226 | } 227 | if (library_ != null) { 228 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Library); 229 | } 230 | return size; 231 | } 232 | 233 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 234 | public void MergeFrom(GraphDef other) { 235 | if (other == null) { 236 | return; 237 | } 238 | node_.Add(other.node_); 239 | if (other.versions_ != null) { 240 | if (versions_ == null) { 241 | versions_ = new global::Tensorflow.VersionDef(); 242 | } 243 | Versions.MergeFrom(other.Versions); 244 | } 245 | if (other.Version != 0) { 246 | Version = other.Version; 247 | } 248 | if (other.library_ != null) { 249 | if (library_ == null) { 250 | library_ = new global::Tensorflow.FunctionDefLibrary(); 251 | } 252 | Library.MergeFrom(other.Library); 253 | } 254 | } 255 | 256 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 257 | public void MergeFrom(pb::CodedInputStream input) { 258 | uint tag; 259 | while ((tag = input.ReadTag()) != 0) { 260 | switch(tag) { 261 | default: 262 | input.SkipLastField(); 263 | break; 264 | case 10: { 265 | node_.AddEntriesFrom(input, _repeated_node_codec); 266 | break; 267 | } 268 | case 18: { 269 | if (library_ == null) { 270 | library_ = new global::Tensorflow.FunctionDefLibrary(); 271 | } 272 | input.ReadMessage(library_); 273 | break; 274 | } 275 | case 24: { 276 | Version = input.ReadInt32(); 277 | break; 278 | } 279 | case 34: { 280 | if (versions_ == null) { 281 | versions_ = new global::Tensorflow.VersionDef(); 282 | } 283 | input.ReadMessage(versions_); 284 | break; 285 | } 286 | } 287 | } 288 | } 289 | 290 | } 291 | 292 | #endregion 293 | 294 | } 295 | 296 | #endregion Designer generated code 297 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Iterator.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/iterator.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/iterator.proto 13 | public static partial class IteratorReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/iterator.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static IteratorReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cih0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL2l0ZXJhdG9yLnByb3RvEgp0", 26 | "ZW5zb3JmbG93IjYKFUl0ZXJhdG9yU3RhdGVNZXRhZGF0YRIPCgd2ZXJzaW9u", 27 | "GAEgASgJEgwKBGtleXMYAiADKAlCKgoTb3JnLnRlbnNvcmZsb3cudXRpbEIO", 28 | "SXRlcmF0b3JQcm90b3NQAfgBAWIGcHJvdG8z")); 29 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 30 | new pbr::FileDescriptor[] { }, 31 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 32 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.IteratorStateMetadata), global::Tensorflow.IteratorStateMetadata.Parser, new[]{ "Version", "Keys" }, null, null, null) 33 | })); 34 | } 35 | #endregion 36 | 37 | } 38 | #region Messages 39 | /// 40 | /// Protocol buffer representing the metadata for an iterator's state stored 41 | /// as a Variant tensor. 42 | /// 43 | public sealed partial class IteratorStateMetadata : pb::IMessage { 44 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new IteratorStateMetadata()); 45 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 46 | public static pb::MessageParser Parser { get { return _parser; } } 47 | 48 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 49 | public static pbr::MessageDescriptor Descriptor { 50 | get { return global::Tensorflow.IteratorReflection.Descriptor.MessageTypes[0]; } 51 | } 52 | 53 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 54 | pbr::MessageDescriptor pb::IMessage.Descriptor { 55 | get { return Descriptor; } 56 | } 57 | 58 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 59 | public IteratorStateMetadata() { 60 | OnConstruction(); 61 | } 62 | 63 | partial void OnConstruction(); 64 | 65 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 66 | public IteratorStateMetadata(IteratorStateMetadata other) : this() { 67 | version_ = other.version_; 68 | keys_ = other.keys_.Clone(); 69 | } 70 | 71 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 72 | public IteratorStateMetadata Clone() { 73 | return new IteratorStateMetadata(this); 74 | } 75 | 76 | /// Field number for the "version" field. 77 | public const int VersionFieldNumber = 1; 78 | private string version_ = ""; 79 | /// 80 | /// A user-specified version string. 81 | /// 82 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 83 | public string Version { 84 | get { return version_; } 85 | set { 86 | version_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 87 | } 88 | } 89 | 90 | /// Field number for the "keys" field. 91 | public const int KeysFieldNumber = 2; 92 | private static readonly pb::FieldCodec _repeated_keys_codec 93 | = pb::FieldCodec.ForString(18); 94 | private readonly pbc::RepeatedField keys_ = new pbc::RepeatedField(); 95 | /// 96 | /// Keys for tensors in the VariantTensorDataProto. 97 | /// 98 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 99 | public pbc::RepeatedField Keys { 100 | get { return keys_; } 101 | } 102 | 103 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 104 | public override bool Equals(object other) { 105 | return Equals(other as IteratorStateMetadata); 106 | } 107 | 108 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 109 | public bool Equals(IteratorStateMetadata other) { 110 | if (ReferenceEquals(other, null)) { 111 | return false; 112 | } 113 | if (ReferenceEquals(other, this)) { 114 | return true; 115 | } 116 | if (Version != other.Version) return false; 117 | if(!keys_.Equals(other.keys_)) return false; 118 | return true; 119 | } 120 | 121 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 122 | public override int GetHashCode() { 123 | int hash = 1; 124 | if (Version.Length != 0) hash ^= Version.GetHashCode(); 125 | hash ^= keys_.GetHashCode(); 126 | return hash; 127 | } 128 | 129 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 130 | public override string ToString() { 131 | return pb::JsonFormatter.ToDiagnosticString(this); 132 | } 133 | 134 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 135 | public void WriteTo(pb::CodedOutputStream output) { 136 | if (Version.Length != 0) { 137 | output.WriteRawTag(10); 138 | output.WriteString(Version); 139 | } 140 | keys_.WriteTo(output, _repeated_keys_codec); 141 | } 142 | 143 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 144 | public int CalculateSize() { 145 | int size = 0; 146 | if (Version.Length != 0) { 147 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); 148 | } 149 | size += keys_.CalculateSize(_repeated_keys_codec); 150 | return size; 151 | } 152 | 153 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 154 | public void MergeFrom(IteratorStateMetadata other) { 155 | if (other == null) { 156 | return; 157 | } 158 | if (other.Version.Length != 0) { 159 | Version = other.Version; 160 | } 161 | keys_.Add(other.keys_); 162 | } 163 | 164 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 165 | public void MergeFrom(pb::CodedInputStream input) { 166 | uint tag; 167 | while ((tag = input.ReadTag()) != 0) { 168 | switch(tag) { 169 | default: 170 | input.SkipLastField(); 171 | break; 172 | case 10: { 173 | Version = input.ReadString(); 174 | break; 175 | } 176 | case 18: { 177 | keys_.AddEntriesFrom(input, _repeated_keys_codec); 178 | break; 179 | } 180 | } 181 | } 182 | } 183 | 184 | } 185 | 186 | #endregion 187 | 188 | } 189 | 190 | #endregion Designer generated code 191 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/MasterService.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/protobuf/master_service.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow.Grpc { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/protobuf/master_service.proto 13 | public static partial class MasterServiceReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/protobuf/master_service.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static MasterServiceReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Ci10ZW5zb3JmbG93L2NvcmUvcHJvdG9idWYvbWFzdGVyX3NlcnZpY2UucHJv", 26 | "dG8SD3RlbnNvcmZsb3cuZ3JwYxoldGVuc29yZmxvdy9jb3JlL3Byb3RvYnVm", 27 | "L21hc3Rlci5wcm90bzK8BAoNTWFzdGVyU2VydmljZRJUCg1DcmVhdGVTZXNz", 28 | "aW9uEiAudGVuc29yZmxvdy5DcmVhdGVTZXNzaW9uUmVxdWVzdBohLnRlbnNv", 29 | "cmZsb3cuQ3JlYXRlU2Vzc2lvblJlc3BvbnNlElQKDUV4dGVuZFNlc3Npb24S", 30 | "IC50ZW5zb3JmbG93LkV4dGVuZFNlc3Npb25SZXF1ZXN0GiEudGVuc29yZmxv", 31 | "dy5FeHRlbmRTZXNzaW9uUmVzcG9uc2USWgoPUGFydGlhbFJ1blNldHVwEiIu", 32 | "dGVuc29yZmxvdy5QYXJ0aWFsUnVuU2V0dXBSZXF1ZXN0GiMudGVuc29yZmxv", 33 | "dy5QYXJ0aWFsUnVuU2V0dXBSZXNwb25zZRJCCgdSdW5TdGVwEhoudGVuc29y", 34 | "Zmxvdy5SdW5TdGVwUmVxdWVzdBobLnRlbnNvcmZsb3cuUnVuU3RlcFJlc3Bv", 35 | "bnNlElEKDENsb3NlU2Vzc2lvbhIfLnRlbnNvcmZsb3cuQ2xvc2VTZXNzaW9u", 36 | "UmVxdWVzdBogLnRlbnNvcmZsb3cuQ2xvc2VTZXNzaW9uUmVzcG9uc2USTgoL", 37 | "TGlzdERldmljZXMSHi50ZW5zb3JmbG93Lkxpc3REZXZpY2VzUmVxdWVzdBof", 38 | "LnRlbnNvcmZsb3cuTGlzdERldmljZXNSZXNwb25zZRI8CgVSZXNldBIYLnRl", 39 | "bnNvcmZsb3cuUmVzZXRSZXF1ZXN0GhkudGVuc29yZmxvdy5SZXNldFJlc3Bv", 40 | "bnNlQjMKGm9yZy50ZW5zb3JmbG93LmRpc3RydW50aW1lQhNNYXN0ZXJTZXJ2", 41 | "aWNlUHJvdG9zUAFiBnByb3RvMw==")); 42 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 43 | new pbr::FileDescriptor[] { global::Tensorflow.MasterReflection.Descriptor, }, 44 | new pbr::GeneratedClrTypeInfo(null, null)); 45 | } 46 | #endregion 47 | 48 | } 49 | } 50 | 51 | #endregion Designer generated code 52 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Model.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: model.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow.Serving { 11 | 12 | /// Holder for reflection information generated from model.proto 13 | public static partial class ModelReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for model.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static ModelReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cgttb2RlbC5wcm90bxISdGVuc29yZmxvdy5zZXJ2aW5nGh5nb29nbGUvcHJv", 26 | "dG9idWYvd3JhcHBlcnMucHJvdG8iXwoJTW9kZWxTcGVjEgwKBG5hbWUYASAB", 27 | "KAkSLAoHdmVyc2lvbhgCIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZh", 28 | "bHVlEhYKDnNpZ25hdHVyZV9uYW1lGAMgASgJQgP4AQFiBnByb3RvMw==")); 29 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 30 | new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, 31 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 32 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.Serving.ModelSpec), global::Tensorflow.Serving.ModelSpec.Parser, new[]{ "Name", "Version", "SignatureName" }, null, null, null) 33 | })); 34 | } 35 | #endregion 36 | 37 | } 38 | #region Messages 39 | /// 40 | /// Metadata for an inference request such as the model name and version. 41 | /// 42 | public sealed partial class ModelSpec : pb::IMessage { 43 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ModelSpec()); 44 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 45 | public static pb::MessageParser Parser { get { return _parser; } } 46 | 47 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 48 | public static pbr::MessageDescriptor Descriptor { 49 | get { return global::Tensorflow.Serving.ModelReflection.Descriptor.MessageTypes[0]; } 50 | } 51 | 52 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 53 | pbr::MessageDescriptor pb::IMessage.Descriptor { 54 | get { return Descriptor; } 55 | } 56 | 57 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 58 | public ModelSpec() { 59 | OnConstruction(); 60 | } 61 | 62 | partial void OnConstruction(); 63 | 64 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 65 | public ModelSpec(ModelSpec other) : this() { 66 | name_ = other.name_; 67 | Version = other.Version; 68 | signatureName_ = other.signatureName_; 69 | } 70 | 71 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 72 | public ModelSpec Clone() { 73 | return new ModelSpec(this); 74 | } 75 | 76 | /// Field number for the "name" field. 77 | public const int NameFieldNumber = 1; 78 | private string name_ = ""; 79 | /// 80 | /// Required servable name. 81 | /// 82 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 83 | public string Name { 84 | get { return name_; } 85 | set { 86 | name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 87 | } 88 | } 89 | 90 | /// Field number for the "version" field. 91 | public const int VersionFieldNumber = 2; 92 | private static readonly pb::FieldCodec _single_version_codec = pb::FieldCodec.ForStructWrapper(18); 93 | private long? version_; 94 | /// 95 | /// Optional version. If unspecified, will use the latest (numerical) version. 96 | /// Typically not needed unless coordinating across multiple models that were 97 | /// co-trained and/or have inter-dependencies on the versions used at inference 98 | /// time. 99 | /// 100 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 101 | public long? Version { 102 | get { return version_; } 103 | set { 104 | version_ = value; 105 | } 106 | } 107 | 108 | /// Field number for the "signature_name" field. 109 | public const int SignatureNameFieldNumber = 3; 110 | private string signatureName_ = ""; 111 | /// 112 | /// A named signature to evaluate. If unspecified, the default signature will 113 | /// be used. 114 | /// 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public string SignatureName { 117 | get { return signatureName_; } 118 | set { 119 | signatureName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 120 | } 121 | } 122 | 123 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 124 | public override bool Equals(object other) { 125 | return Equals(other as ModelSpec); 126 | } 127 | 128 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 129 | public bool Equals(ModelSpec other) { 130 | if (ReferenceEquals(other, null)) { 131 | return false; 132 | } 133 | if (ReferenceEquals(other, this)) { 134 | return true; 135 | } 136 | if (Name != other.Name) return false; 137 | if (Version != other.Version) return false; 138 | if (SignatureName != other.SignatureName) return false; 139 | return true; 140 | } 141 | 142 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 143 | public override int GetHashCode() { 144 | int hash = 1; 145 | if (Name.Length != 0) hash ^= Name.GetHashCode(); 146 | if (version_ != null) hash ^= Version.GetHashCode(); 147 | if (SignatureName.Length != 0) hash ^= SignatureName.GetHashCode(); 148 | return hash; 149 | } 150 | 151 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 152 | public override string ToString() { 153 | return pb::JsonFormatter.ToDiagnosticString(this); 154 | } 155 | 156 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 157 | public void WriteTo(pb::CodedOutputStream output) { 158 | if (Name.Length != 0) { 159 | output.WriteRawTag(10); 160 | output.WriteString(Name); 161 | } 162 | if (version_ != null) { 163 | _single_version_codec.WriteTagAndValue(output, Version); 164 | } 165 | if (SignatureName.Length != 0) { 166 | output.WriteRawTag(26); 167 | output.WriteString(SignatureName); 168 | } 169 | } 170 | 171 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 172 | public int CalculateSize() { 173 | int size = 0; 174 | if (Name.Length != 0) { 175 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); 176 | } 177 | if (version_ != null) { 178 | size += _single_version_codec.CalculateSizeWithTag(Version); 179 | } 180 | if (SignatureName.Length != 0) { 181 | size += 1 + pb::CodedOutputStream.ComputeStringSize(SignatureName); 182 | } 183 | return size; 184 | } 185 | 186 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 187 | public void MergeFrom(ModelSpec other) { 188 | if (other == null) { 189 | return; 190 | } 191 | if (other.Name.Length != 0) { 192 | Name = other.Name; 193 | } 194 | if (other.version_ != null) { 195 | if (version_ == null || other.Version != 0L) { 196 | Version = other.Version; 197 | } 198 | } 199 | if (other.SignatureName.Length != 0) { 200 | SignatureName = other.SignatureName; 201 | } 202 | } 203 | 204 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 205 | public void MergeFrom(pb::CodedInputStream input) { 206 | uint tag; 207 | while ((tag = input.ReadTag()) != 0) { 208 | switch(tag) { 209 | default: 210 | input.SkipLastField(); 211 | break; 212 | case 10: { 213 | Name = input.ReadString(); 214 | break; 215 | } 216 | case 18: { 217 | long? value = _single_version_codec.Read(input); 218 | if (version_ == null || value != 0L) { 219 | Version = value; 220 | } 221 | break; 222 | } 223 | case 26: { 224 | SignatureName = input.ReadString(); 225 | break; 226 | } 227 | } 228 | } 229 | } 230 | 231 | } 232 | 233 | #endregion 234 | 235 | } 236 | 237 | #endregion Designer generated code 238 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/NamedTensor.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/protobuf/named_tensor.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/protobuf/named_tensor.proto 13 | public static partial class NamedTensorReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/protobuf/named_tensor.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static NamedTensorReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cit0ZW5zb3JmbG93L2NvcmUvcHJvdG9idWYvbmFtZWRfdGVuc29yLnByb3Rv", 26 | "Egp0ZW5zb3JmbG93GiZ0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3RlbnNv", 27 | "ci5wcm90byJJChBOYW1lZFRlbnNvclByb3RvEgwKBG5hbWUYASABKAkSJwoG", 28 | "dGVuc29yGAIgASgLMhcudGVuc29yZmxvdy5UZW5zb3JQcm90b0IyChhvcmcu", 29 | "dGVuc29yZmxvdy5mcmFtZXdvcmtCEU5hbWVkVGVuc29yUHJvdG9zUAH4AQFi", 30 | "BnByb3RvMw==")); 31 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 32 | new pbr::FileDescriptor[] { global::Tensorflow.TensorReflection.Descriptor, }, 33 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 34 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.NamedTensorProto), global::Tensorflow.NamedTensorProto.Parser, new[]{ "Name", "Tensor" }, null, null, null) 35 | })); 36 | } 37 | #endregion 38 | 39 | } 40 | #region Messages 41 | /// 42 | /// A pair of tensor name and tensor values. 43 | /// 44 | public sealed partial class NamedTensorProto : pb::IMessage { 45 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamedTensorProto()); 46 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 47 | public static pb::MessageParser Parser { get { return _parser; } } 48 | 49 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 50 | public static pbr::MessageDescriptor Descriptor { 51 | get { return global::Tensorflow.NamedTensorReflection.Descriptor.MessageTypes[0]; } 52 | } 53 | 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 55 | pbr::MessageDescriptor pb::IMessage.Descriptor { 56 | get { return Descriptor; } 57 | } 58 | 59 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 60 | public NamedTensorProto() { 61 | OnConstruction(); 62 | } 63 | 64 | partial void OnConstruction(); 65 | 66 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 67 | public NamedTensorProto(NamedTensorProto other) : this() { 68 | name_ = other.name_; 69 | Tensor = other.tensor_ != null ? other.Tensor.Clone() : null; 70 | } 71 | 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 73 | public NamedTensorProto Clone() { 74 | return new NamedTensorProto(this); 75 | } 76 | 77 | /// Field number for the "name" field. 78 | public const int NameFieldNumber = 1; 79 | private string name_ = ""; 80 | /// 81 | /// Name of the tensor. 82 | /// 83 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 84 | public string Name { 85 | get { return name_; } 86 | set { 87 | name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 88 | } 89 | } 90 | 91 | /// Field number for the "tensor" field. 92 | public const int TensorFieldNumber = 2; 93 | private global::Tensorflow.TensorProto tensor_; 94 | /// 95 | /// The client can populate a TensorProto using a tensorflow::Tensor`, or 96 | /// directly using the protobuf field accessors. 97 | /// 98 | /// The client specifies whether the returned tensor values should be 99 | /// filled tensor fields (float_val, int_val, etc.) or encoded in a 100 | /// compact form in tensor.tensor_content. 101 | /// 102 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 103 | public global::Tensorflow.TensorProto Tensor { 104 | get { return tensor_; } 105 | set { 106 | tensor_ = value; 107 | } 108 | } 109 | 110 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 111 | public override bool Equals(object other) { 112 | return Equals(other as NamedTensorProto); 113 | } 114 | 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public bool Equals(NamedTensorProto other) { 117 | if (ReferenceEquals(other, null)) { 118 | return false; 119 | } 120 | if (ReferenceEquals(other, this)) { 121 | return true; 122 | } 123 | if (Name != other.Name) return false; 124 | if (!object.Equals(Tensor, other.Tensor)) return false; 125 | return true; 126 | } 127 | 128 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 129 | public override int GetHashCode() { 130 | int hash = 1; 131 | if (Name.Length != 0) hash ^= Name.GetHashCode(); 132 | if (tensor_ != null) hash ^= Tensor.GetHashCode(); 133 | return hash; 134 | } 135 | 136 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 137 | public override string ToString() { 138 | return pb::JsonFormatter.ToDiagnosticString(this); 139 | } 140 | 141 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 142 | public void WriteTo(pb::CodedOutputStream output) { 143 | if (Name.Length != 0) { 144 | output.WriteRawTag(10); 145 | output.WriteString(Name); 146 | } 147 | if (tensor_ != null) { 148 | output.WriteRawTag(18); 149 | output.WriteMessage(Tensor); 150 | } 151 | } 152 | 153 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 154 | public int CalculateSize() { 155 | int size = 0; 156 | if (Name.Length != 0) { 157 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); 158 | } 159 | if (tensor_ != null) { 160 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Tensor); 161 | } 162 | return size; 163 | } 164 | 165 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 166 | public void MergeFrom(NamedTensorProto other) { 167 | if (other == null) { 168 | return; 169 | } 170 | if (other.Name.Length != 0) { 171 | Name = other.Name; 172 | } 173 | if (other.tensor_ != null) { 174 | if (tensor_ == null) { 175 | tensor_ = new global::Tensorflow.TensorProto(); 176 | } 177 | Tensor.MergeFrom(other.Tensor); 178 | } 179 | } 180 | 181 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 182 | public void MergeFrom(pb::CodedInputStream input) { 183 | uint tag; 184 | while ((tag = input.ReadTag()) != 0) { 185 | switch(tag) { 186 | default: 187 | input.SkipLastField(); 188 | break; 189 | case 10: { 190 | Name = input.ReadString(); 191 | break; 192 | } 193 | case 18: { 194 | if (tensor_ == null) { 195 | tensor_ = new global::Tensorflow.TensorProto(); 196 | } 197 | input.ReadMessage(tensor_); 198 | break; 199 | } 200 | } 201 | } 202 | } 203 | 204 | } 205 | 206 | #endregion 207 | 208 | } 209 | 210 | #endregion Designer generated code 211 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/PredictionService.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: prediction_service.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow.Serving { 11 | 12 | /// Holder for reflection information generated from prediction_service.proto 13 | public static partial class PredictionServiceReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for prediction_service.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static PredictionServiceReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "ChhwcmVkaWN0aW9uX3NlcnZpY2UucHJvdG8SEnRlbnNvcmZsb3cuc2Vydmlu", 26 | "ZxoUY2xhc3NpZmljYXRpb24ucHJvdG8aGGdldF9tb2RlbF9tZXRhZGF0YS5w", 27 | "cm90bxoPaW5mZXJlbmNlLnByb3RvGg1wcmVkaWN0LnByb3RvGhByZWdyZXNz", 28 | "aW9uLnByb3RvMvwDChFQcmVkaWN0aW9uU2VydmljZRJhCghDbGFzc2lmeRIp", 29 | "LnRlbnNvcmZsb3cuc2VydmluZy5DbGFzc2lmaWNhdGlvblJlcXVlc3QaKi50", 30 | "ZW5zb3JmbG93LnNlcnZpbmcuQ2xhc3NpZmljYXRpb25SZXNwb25zZRJYCgdS", 31 | "ZWdyZXNzEiUudGVuc29yZmxvdy5zZXJ2aW5nLlJlZ3Jlc3Npb25SZXF1ZXN0", 32 | "GiYudGVuc29yZmxvdy5zZXJ2aW5nLlJlZ3Jlc3Npb25SZXNwb25zZRJSCgdQ", 33 | "cmVkaWN0EiIudGVuc29yZmxvdy5zZXJ2aW5nLlByZWRpY3RSZXF1ZXN0GiMu", 34 | "dGVuc29yZmxvdy5zZXJ2aW5nLlByZWRpY3RSZXNwb25zZRJnCg5NdWx0aUlu", 35 | "ZmVyZW5jZRIpLnRlbnNvcmZsb3cuc2VydmluZy5NdWx0aUluZmVyZW5jZVJl", 36 | "cXVlc3QaKi50ZW5zb3JmbG93LnNlcnZpbmcuTXVsdGlJbmZlcmVuY2VSZXNw", 37 | "b25zZRJtChBHZXRNb2RlbE1ldGFkYXRhEisudGVuc29yZmxvdy5zZXJ2aW5n", 38 | "LkdldE1vZGVsTWV0YWRhdGFSZXF1ZXN0GiwudGVuc29yZmxvdy5zZXJ2aW5n", 39 | "LkdldE1vZGVsTWV0YWRhdGFSZXNwb25zZUID+AEBYgZwcm90bzM=")); 40 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 41 | new pbr::FileDescriptor[] { global::Tensorflow.Serving.ClassificationReflection.Descriptor, global::Tensorflow.Serving.GetModelMetadataReflection.Descriptor, global::Tensorflow.Serving.InferenceReflection.Descriptor, global::Tensorflow.Serving.PredictReflection.Descriptor, global::Tensorflow.Serving.RegressionReflection.Descriptor, }, 42 | new pbr::GeneratedClrTypeInfo(null, null)); 43 | } 44 | #endregion 45 | 46 | } 47 | } 48 | 49 | #endregion Designer generated code 50 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/ReaderBase.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/reader_base.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/reader_base.proto 13 | public static partial class ReaderBaseReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/reader_base.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static ReaderBaseReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cit0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3JlYWRlcl9iYXNlLnByb3Rv", 26 | "Egp0ZW5zb3JmbG93InIKD1JlYWRlckJhc2VTdGF0ZRIUCgx3b3JrX3N0YXJ0", 27 | "ZWQYASABKAMSFQoNd29ya19maW5pc2hlZBgCIAEoAxIcChRudW1fcmVjb3Jk", 28 | "c19wcm9kdWNlZBgDIAEoAxIUCgxjdXJyZW50X3dvcmsYBCABKAxCMQoYb3Jn", 29 | "LnRlbnNvcmZsb3cuZnJhbWV3b3JrQhBSZWFkZXJCYXNlUHJvdG9zUAH4AQFi", 30 | "BnByb3RvMw==")); 31 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 32 | new pbr::FileDescriptor[] { }, 33 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 34 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.ReaderBaseState), global::Tensorflow.ReaderBaseState.Parser, new[]{ "WorkStarted", "WorkFinished", "NumRecordsProduced", "CurrentWork" }, null, null, null) 35 | })); 36 | } 37 | #endregion 38 | 39 | } 40 | #region Messages 41 | /// 42 | /// For serializing and restoring the state of ReaderBase, see 43 | /// reader_base.h for details. 44 | /// 45 | public sealed partial class ReaderBaseState : pb::IMessage { 46 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReaderBaseState()); 47 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 48 | public static pb::MessageParser Parser { get { return _parser; } } 49 | 50 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 51 | public static pbr::MessageDescriptor Descriptor { 52 | get { return global::Tensorflow.ReaderBaseReflection.Descriptor.MessageTypes[0]; } 53 | } 54 | 55 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 56 | pbr::MessageDescriptor pb::IMessage.Descriptor { 57 | get { return Descriptor; } 58 | } 59 | 60 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 61 | public ReaderBaseState() { 62 | OnConstruction(); 63 | } 64 | 65 | partial void OnConstruction(); 66 | 67 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 68 | public ReaderBaseState(ReaderBaseState other) : this() { 69 | workStarted_ = other.workStarted_; 70 | workFinished_ = other.workFinished_; 71 | numRecordsProduced_ = other.numRecordsProduced_; 72 | currentWork_ = other.currentWork_; 73 | } 74 | 75 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 76 | public ReaderBaseState Clone() { 77 | return new ReaderBaseState(this); 78 | } 79 | 80 | /// Field number for the "work_started" field. 81 | public const int WorkStartedFieldNumber = 1; 82 | private long workStarted_; 83 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 84 | public long WorkStarted { 85 | get { return workStarted_; } 86 | set { 87 | workStarted_ = value; 88 | } 89 | } 90 | 91 | /// Field number for the "work_finished" field. 92 | public const int WorkFinishedFieldNumber = 2; 93 | private long workFinished_; 94 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 95 | public long WorkFinished { 96 | get { return workFinished_; } 97 | set { 98 | workFinished_ = value; 99 | } 100 | } 101 | 102 | /// Field number for the "num_records_produced" field. 103 | public const int NumRecordsProducedFieldNumber = 3; 104 | private long numRecordsProduced_; 105 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 106 | public long NumRecordsProduced { 107 | get { return numRecordsProduced_; } 108 | set { 109 | numRecordsProduced_ = value; 110 | } 111 | } 112 | 113 | /// Field number for the "current_work" field. 114 | public const int CurrentWorkFieldNumber = 4; 115 | private pb::ByteString currentWork_ = pb::ByteString.Empty; 116 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 117 | public pb::ByteString CurrentWork { 118 | get { return currentWork_; } 119 | set { 120 | currentWork_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 121 | } 122 | } 123 | 124 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 125 | public override bool Equals(object other) { 126 | return Equals(other as ReaderBaseState); 127 | } 128 | 129 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 130 | public bool Equals(ReaderBaseState other) { 131 | if (ReferenceEquals(other, null)) { 132 | return false; 133 | } 134 | if (ReferenceEquals(other, this)) { 135 | return true; 136 | } 137 | if (WorkStarted != other.WorkStarted) return false; 138 | if (WorkFinished != other.WorkFinished) return false; 139 | if (NumRecordsProduced != other.NumRecordsProduced) return false; 140 | if (CurrentWork != other.CurrentWork) return false; 141 | return true; 142 | } 143 | 144 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 145 | public override int GetHashCode() { 146 | int hash = 1; 147 | if (WorkStarted != 0L) hash ^= WorkStarted.GetHashCode(); 148 | if (WorkFinished != 0L) hash ^= WorkFinished.GetHashCode(); 149 | if (NumRecordsProduced != 0L) hash ^= NumRecordsProduced.GetHashCode(); 150 | if (CurrentWork.Length != 0) hash ^= CurrentWork.GetHashCode(); 151 | return hash; 152 | } 153 | 154 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 155 | public override string ToString() { 156 | return pb::JsonFormatter.ToDiagnosticString(this); 157 | } 158 | 159 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 160 | public void WriteTo(pb::CodedOutputStream output) { 161 | if (WorkStarted != 0L) { 162 | output.WriteRawTag(8); 163 | output.WriteInt64(WorkStarted); 164 | } 165 | if (WorkFinished != 0L) { 166 | output.WriteRawTag(16); 167 | output.WriteInt64(WorkFinished); 168 | } 169 | if (NumRecordsProduced != 0L) { 170 | output.WriteRawTag(24); 171 | output.WriteInt64(NumRecordsProduced); 172 | } 173 | if (CurrentWork.Length != 0) { 174 | output.WriteRawTag(34); 175 | output.WriteBytes(CurrentWork); 176 | } 177 | } 178 | 179 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 180 | public int CalculateSize() { 181 | int size = 0; 182 | if (WorkStarted != 0L) { 183 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(WorkStarted); 184 | } 185 | if (WorkFinished != 0L) { 186 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(WorkFinished); 187 | } 188 | if (NumRecordsProduced != 0L) { 189 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(NumRecordsProduced); 190 | } 191 | if (CurrentWork.Length != 0) { 192 | size += 1 + pb::CodedOutputStream.ComputeBytesSize(CurrentWork); 193 | } 194 | return size; 195 | } 196 | 197 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 198 | public void MergeFrom(ReaderBaseState other) { 199 | if (other == null) { 200 | return; 201 | } 202 | if (other.WorkStarted != 0L) { 203 | WorkStarted = other.WorkStarted; 204 | } 205 | if (other.WorkFinished != 0L) { 206 | WorkFinished = other.WorkFinished; 207 | } 208 | if (other.NumRecordsProduced != 0L) { 209 | NumRecordsProduced = other.NumRecordsProduced; 210 | } 211 | if (other.CurrentWork.Length != 0) { 212 | CurrentWork = other.CurrentWork; 213 | } 214 | } 215 | 216 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 217 | public void MergeFrom(pb::CodedInputStream input) { 218 | uint tag; 219 | while ((tag = input.ReadTag()) != 0) { 220 | switch(tag) { 221 | default: 222 | input.SkipLastField(); 223 | break; 224 | case 8: { 225 | WorkStarted = input.ReadInt64(); 226 | break; 227 | } 228 | case 16: { 229 | WorkFinished = input.ReadInt64(); 230 | break; 231 | } 232 | case 24: { 233 | NumRecordsProduced = input.ReadInt64(); 234 | break; 235 | } 236 | case 34: { 237 | CurrentWork = input.ReadBytes(); 238 | break; 239 | } 240 | } 241 | } 242 | } 243 | 244 | } 245 | 246 | #endregion 247 | 248 | } 249 | 250 | #endregion Designer generated code 251 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/ResourceHandle.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/resource_handle.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/resource_handle.proto 13 | public static partial class ResourceHandleReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/resource_handle.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static ResourceHandleReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Ci90ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3Jlc291cmNlX2hhbmRsZS5w", 26 | "cm90bxIKdGVuc29yZmxvdyJyChNSZXNvdXJjZUhhbmRsZVByb3RvEg4KBmRl", 27 | "dmljZRgBIAEoCRIRCgljb250YWluZXIYAiABKAkSDAoEbmFtZRgDIAEoCRIR", 28 | "CgloYXNoX2NvZGUYBCABKAQSFwoPbWF5YmVfdHlwZV9uYW1lGAUgASgJQi8K", 29 | "GG9yZy50ZW5zb3JmbG93LmZyYW1ld29ya0IOUmVzb3VyY2VIYW5kbGVQAfgB", 30 | "AWIGcHJvdG8z")); 31 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 32 | new pbr::FileDescriptor[] { }, 33 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 34 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.ResourceHandleProto), global::Tensorflow.ResourceHandleProto.Parser, new[]{ "Device", "Container", "Name", "HashCode", "MaybeTypeName" }, null, null, null) 35 | })); 36 | } 37 | #endregion 38 | 39 | } 40 | #region Messages 41 | /// 42 | /// Protocol buffer representing a handle to a tensorflow resource. Handles are 43 | /// not valid across executions, but can be serialized back and forth from within 44 | /// a single run. 45 | /// 46 | public sealed partial class ResourceHandleProto : pb::IMessage { 47 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResourceHandleProto()); 48 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 49 | public static pb::MessageParser Parser { get { return _parser; } } 50 | 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 52 | public static pbr::MessageDescriptor Descriptor { 53 | get { return global::Tensorflow.ResourceHandleReflection.Descriptor.MessageTypes[0]; } 54 | } 55 | 56 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 57 | pbr::MessageDescriptor pb::IMessage.Descriptor { 58 | get { return Descriptor; } 59 | } 60 | 61 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 62 | public ResourceHandleProto() { 63 | OnConstruction(); 64 | } 65 | 66 | partial void OnConstruction(); 67 | 68 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 69 | public ResourceHandleProto(ResourceHandleProto other) : this() { 70 | device_ = other.device_; 71 | container_ = other.container_; 72 | name_ = other.name_; 73 | hashCode_ = other.hashCode_; 74 | maybeTypeName_ = other.maybeTypeName_; 75 | } 76 | 77 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 78 | public ResourceHandleProto Clone() { 79 | return new ResourceHandleProto(this); 80 | } 81 | 82 | /// Field number for the "device" field. 83 | public const int DeviceFieldNumber = 1; 84 | private string device_ = ""; 85 | /// 86 | /// Unique name for the device containing the resource. 87 | /// 88 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 89 | public string Device { 90 | get { return device_; } 91 | set { 92 | device_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 93 | } 94 | } 95 | 96 | /// Field number for the "container" field. 97 | public const int ContainerFieldNumber = 2; 98 | private string container_ = ""; 99 | /// 100 | /// Container in which this resource is placed. 101 | /// 102 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 103 | public string Container { 104 | get { return container_; } 105 | set { 106 | container_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 107 | } 108 | } 109 | 110 | /// Field number for the "name" field. 111 | public const int NameFieldNumber = 3; 112 | private string name_ = ""; 113 | /// 114 | /// Unique name of this resource. 115 | /// 116 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 117 | public string Name { 118 | get { return name_; } 119 | set { 120 | name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 121 | } 122 | } 123 | 124 | /// Field number for the "hash_code" field. 125 | public const int HashCodeFieldNumber = 4; 126 | private ulong hashCode_; 127 | /// 128 | /// Hash code for the type of the resource. Is only valid in the same device 129 | /// and in the same execution. 130 | /// 131 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 132 | public ulong HashCode { 133 | get { return hashCode_; } 134 | set { 135 | hashCode_ = value; 136 | } 137 | } 138 | 139 | /// Field number for the "maybe_type_name" field. 140 | public const int MaybeTypeNameFieldNumber = 5; 141 | private string maybeTypeName_ = ""; 142 | /// 143 | /// For debug-only, the name of the type pointed to by this handle, if 144 | /// available. 145 | /// 146 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 147 | public string MaybeTypeName { 148 | get { return maybeTypeName_; } 149 | set { 150 | maybeTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 151 | } 152 | } 153 | 154 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 155 | public override bool Equals(object other) { 156 | return Equals(other as ResourceHandleProto); 157 | } 158 | 159 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 160 | public bool Equals(ResourceHandleProto other) { 161 | if (ReferenceEquals(other, null)) { 162 | return false; 163 | } 164 | if (ReferenceEquals(other, this)) { 165 | return true; 166 | } 167 | if (Device != other.Device) return false; 168 | if (Container != other.Container) return false; 169 | if (Name != other.Name) return false; 170 | if (HashCode != other.HashCode) return false; 171 | if (MaybeTypeName != other.MaybeTypeName) return false; 172 | return true; 173 | } 174 | 175 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 176 | public override int GetHashCode() { 177 | int hash = 1; 178 | if (Device.Length != 0) hash ^= Device.GetHashCode(); 179 | if (Container.Length != 0) hash ^= Container.GetHashCode(); 180 | if (Name.Length != 0) hash ^= Name.GetHashCode(); 181 | if (HashCode != 0UL) hash ^= HashCode.GetHashCode(); 182 | if (MaybeTypeName.Length != 0) hash ^= MaybeTypeName.GetHashCode(); 183 | return hash; 184 | } 185 | 186 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 187 | public override string ToString() { 188 | return pb::JsonFormatter.ToDiagnosticString(this); 189 | } 190 | 191 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 192 | public void WriteTo(pb::CodedOutputStream output) { 193 | if (Device.Length != 0) { 194 | output.WriteRawTag(10); 195 | output.WriteString(Device); 196 | } 197 | if (Container.Length != 0) { 198 | output.WriteRawTag(18); 199 | output.WriteString(Container); 200 | } 201 | if (Name.Length != 0) { 202 | output.WriteRawTag(26); 203 | output.WriteString(Name); 204 | } 205 | if (HashCode != 0UL) { 206 | output.WriteRawTag(32); 207 | output.WriteUInt64(HashCode); 208 | } 209 | if (MaybeTypeName.Length != 0) { 210 | output.WriteRawTag(42); 211 | output.WriteString(MaybeTypeName); 212 | } 213 | } 214 | 215 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 216 | public int CalculateSize() { 217 | int size = 0; 218 | if (Device.Length != 0) { 219 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Device); 220 | } 221 | if (Container.Length != 0) { 222 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Container); 223 | } 224 | if (Name.Length != 0) { 225 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); 226 | } 227 | if (HashCode != 0UL) { 228 | size += 1 + pb::CodedOutputStream.ComputeUInt64Size(HashCode); 229 | } 230 | if (MaybeTypeName.Length != 0) { 231 | size += 1 + pb::CodedOutputStream.ComputeStringSize(MaybeTypeName); 232 | } 233 | return size; 234 | } 235 | 236 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 237 | public void MergeFrom(ResourceHandleProto other) { 238 | if (other == null) { 239 | return; 240 | } 241 | if (other.Device.Length != 0) { 242 | Device = other.Device; 243 | } 244 | if (other.Container.Length != 0) { 245 | Container = other.Container; 246 | } 247 | if (other.Name.Length != 0) { 248 | Name = other.Name; 249 | } 250 | if (other.HashCode != 0UL) { 251 | HashCode = other.HashCode; 252 | } 253 | if (other.MaybeTypeName.Length != 0) { 254 | MaybeTypeName = other.MaybeTypeName; 255 | } 256 | } 257 | 258 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 259 | public void MergeFrom(pb::CodedInputStream input) { 260 | uint tag; 261 | while ((tag = input.ReadTag()) != 0) { 262 | switch(tag) { 263 | default: 264 | input.SkipLastField(); 265 | break; 266 | case 10: { 267 | Device = input.ReadString(); 268 | break; 269 | } 270 | case 18: { 271 | Container = input.ReadString(); 272 | break; 273 | } 274 | case 26: { 275 | Name = input.ReadString(); 276 | break; 277 | } 278 | case 32: { 279 | HashCode = input.ReadUInt64(); 280 | break; 281 | } 282 | case 42: { 283 | MaybeTypeName = input.ReadString(); 284 | break; 285 | } 286 | } 287 | } 288 | } 289 | 290 | } 291 | 292 | #endregion 293 | 294 | } 295 | 296 | #endregion Designer generated code 297 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/SavedModel.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/protobuf/saved_model.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/protobuf/saved_model.proto 13 | public static partial class SavedModelReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/protobuf/saved_model.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static SavedModelReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cip0ZW5zb3JmbG93L2NvcmUvcHJvdG9idWYvc2F2ZWRfbW9kZWwucHJvdG8S", 26 | "CnRlbnNvcmZsb3caKXRlbnNvcmZsb3cvY29yZS9wcm90b2J1Zi9tZXRhX2dy", 27 | "YXBoLnByb3RvIl8KClNhdmVkTW9kZWwSIgoac2F2ZWRfbW9kZWxfc2NoZW1h", 28 | "X3ZlcnNpb24YASABKAMSLQoLbWV0YV9ncmFwaHMYAiADKAsyGC50ZW5zb3Jm", 29 | "bG93Lk1ldGFHcmFwaERlZkIxChhvcmcudGVuc29yZmxvdy5mcmFtZXdvcmtC", 30 | "EFNhdmVkTW9kZWxQcm90b3NQAfgBAWIGcHJvdG8z")); 31 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 32 | new pbr::FileDescriptor[] { global::Tensorflow.MetaGraphReflection.Descriptor, }, 33 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 34 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.SavedModel), global::Tensorflow.SavedModel.Parser, new[]{ "SavedModelSchemaVersion", "MetaGraphs" }, null, null, null) 35 | })); 36 | } 37 | #endregion 38 | 39 | } 40 | #region Messages 41 | /// 42 | /// SavedModel is the high level serialization format for TensorFlow Models. 43 | /// See [todo: doc links, similar to session_bundle] for more information. 44 | /// 45 | public sealed partial class SavedModel : pb::IMessage { 46 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SavedModel()); 47 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 48 | public static pb::MessageParser Parser { get { return _parser; } } 49 | 50 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 51 | public static pbr::MessageDescriptor Descriptor { 52 | get { return global::Tensorflow.SavedModelReflection.Descriptor.MessageTypes[0]; } 53 | } 54 | 55 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 56 | pbr::MessageDescriptor pb::IMessage.Descriptor { 57 | get { return Descriptor; } 58 | } 59 | 60 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 61 | public SavedModel() { 62 | OnConstruction(); 63 | } 64 | 65 | partial void OnConstruction(); 66 | 67 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 68 | public SavedModel(SavedModel other) : this() { 69 | savedModelSchemaVersion_ = other.savedModelSchemaVersion_; 70 | metaGraphs_ = other.metaGraphs_.Clone(); 71 | } 72 | 73 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 74 | public SavedModel Clone() { 75 | return new SavedModel(this); 76 | } 77 | 78 | /// Field number for the "saved_model_schema_version" field. 79 | public const int SavedModelSchemaVersionFieldNumber = 1; 80 | private long savedModelSchemaVersion_; 81 | /// 82 | /// The schema version of the SavedModel instance. Used for versioning when 83 | /// making future changes to the specification/implementation. Initial value 84 | /// at release will be 1. 85 | /// 86 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 87 | public long SavedModelSchemaVersion { 88 | get { return savedModelSchemaVersion_; } 89 | set { 90 | savedModelSchemaVersion_ = value; 91 | } 92 | } 93 | 94 | /// Field number for the "meta_graphs" field. 95 | public const int MetaGraphsFieldNumber = 2; 96 | private static readonly pb::FieldCodec _repeated_metaGraphs_codec 97 | = pb::FieldCodec.ForMessage(18, global::Tensorflow.MetaGraphDef.Parser); 98 | private readonly pbc::RepeatedField metaGraphs_ = new pbc::RepeatedField(); 99 | /// 100 | /// One or more MetaGraphs. 101 | /// 102 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 103 | public pbc::RepeatedField MetaGraphs { 104 | get { return metaGraphs_; } 105 | } 106 | 107 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 108 | public override bool Equals(object other) { 109 | return Equals(other as SavedModel); 110 | } 111 | 112 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 113 | public bool Equals(SavedModel other) { 114 | if (ReferenceEquals(other, null)) { 115 | return false; 116 | } 117 | if (ReferenceEquals(other, this)) { 118 | return true; 119 | } 120 | if (SavedModelSchemaVersion != other.SavedModelSchemaVersion) return false; 121 | if(!metaGraphs_.Equals(other.metaGraphs_)) return false; 122 | return true; 123 | } 124 | 125 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 126 | public override int GetHashCode() { 127 | int hash = 1; 128 | if (SavedModelSchemaVersion != 0L) hash ^= SavedModelSchemaVersion.GetHashCode(); 129 | hash ^= metaGraphs_.GetHashCode(); 130 | return hash; 131 | } 132 | 133 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 134 | public override string ToString() { 135 | return pb::JsonFormatter.ToDiagnosticString(this); 136 | } 137 | 138 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 139 | public void WriteTo(pb::CodedOutputStream output) { 140 | if (SavedModelSchemaVersion != 0L) { 141 | output.WriteRawTag(8); 142 | output.WriteInt64(SavedModelSchemaVersion); 143 | } 144 | metaGraphs_.WriteTo(output, _repeated_metaGraphs_codec); 145 | } 146 | 147 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 148 | public int CalculateSize() { 149 | int size = 0; 150 | if (SavedModelSchemaVersion != 0L) { 151 | size += 1 + pb::CodedOutputStream.ComputeInt64Size(SavedModelSchemaVersion); 152 | } 153 | size += metaGraphs_.CalculateSize(_repeated_metaGraphs_codec); 154 | return size; 155 | } 156 | 157 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 158 | public void MergeFrom(SavedModel other) { 159 | if (other == null) { 160 | return; 161 | } 162 | if (other.SavedModelSchemaVersion != 0L) { 163 | SavedModelSchemaVersion = other.SavedModelSchemaVersion; 164 | } 165 | metaGraphs_.Add(other.metaGraphs_); 166 | } 167 | 168 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 169 | public void MergeFrom(pb::CodedInputStream input) { 170 | uint tag; 171 | while ((tag = input.ReadTag()) != 0) { 172 | switch(tag) { 173 | default: 174 | input.SkipLastField(); 175 | break; 176 | case 8: { 177 | SavedModelSchemaVersion = input.ReadInt64(); 178 | break; 179 | } 180 | case 18: { 181 | metaGraphs_.AddEntriesFrom(input, _repeated_metaGraphs_codec); 182 | break; 183 | } 184 | } 185 | } 186 | } 187 | 188 | } 189 | 190 | #endregion 191 | 192 | } 193 | 194 | #endregion Designer generated code 195 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/TensorDescription.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/tensor_description.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/tensor_description.proto 13 | public static partial class TensorDescriptionReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/tensor_description.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static TensorDescriptionReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CjJ0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3RlbnNvcl9kZXNjcmlwdGlv", 26 | "bi5wcm90bxIKdGVuc29yZmxvdxoldGVuc29yZmxvdy9jb3JlL2ZyYW1ld29y", 27 | "ay90eXBlcy5wcm90bxosdGVuc29yZmxvdy9jb3JlL2ZyYW1ld29yay90ZW5z", 28 | "b3Jfc2hhcGUucHJvdG8aNnRlbnNvcmZsb3cvY29yZS9mcmFtZXdvcmsvYWxs", 29 | "b2NhdGlvbl9kZXNjcmlwdGlvbi5wcm90byKoAQoRVGVuc29yRGVzY3JpcHRp", 30 | "b24SIwoFZHR5cGUYASABKA4yFC50ZW5zb3JmbG93LkRhdGFUeXBlEisKBXNo", 31 | "YXBlGAIgASgLMhwudGVuc29yZmxvdy5UZW5zb3JTaGFwZVByb3RvEkEKFmFs", 32 | "bG9jYXRpb25fZGVzY3JpcHRpb24YBCABKAsyIS50ZW5zb3JmbG93LkFsbG9j", 33 | "YXRpb25EZXNjcmlwdGlvbkI4ChhvcmcudGVuc29yZmxvdy5mcmFtZXdvcmtC", 34 | "F1RlbnNvckRlc2NyaXB0aW9uUHJvdG9zUAH4AQFiBnByb3RvMw==")); 35 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 36 | new pbr::FileDescriptor[] { global::Tensorflow.TypesReflection.Descriptor, global::Tensorflow.TensorShapeReflection.Descriptor, global::Tensorflow.AllocationDescriptionReflection.Descriptor, }, 37 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 38 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.TensorDescription), global::Tensorflow.TensorDescription.Parser, new[]{ "Dtype", "Shape", "AllocationDescription" }, null, null, null) 39 | })); 40 | } 41 | #endregion 42 | 43 | } 44 | #region Messages 45 | public sealed partial class TensorDescription : pb::IMessage { 46 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TensorDescription()); 47 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 48 | public static pb::MessageParser Parser { get { return _parser; } } 49 | 50 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 51 | public static pbr::MessageDescriptor Descriptor { 52 | get { return global::Tensorflow.TensorDescriptionReflection.Descriptor.MessageTypes[0]; } 53 | } 54 | 55 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 56 | pbr::MessageDescriptor pb::IMessage.Descriptor { 57 | get { return Descriptor; } 58 | } 59 | 60 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 61 | public TensorDescription() { 62 | OnConstruction(); 63 | } 64 | 65 | partial void OnConstruction(); 66 | 67 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 68 | public TensorDescription(TensorDescription other) : this() { 69 | dtype_ = other.dtype_; 70 | Shape = other.shape_ != null ? other.Shape.Clone() : null; 71 | AllocationDescription = other.allocationDescription_ != null ? other.AllocationDescription.Clone() : null; 72 | } 73 | 74 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 75 | public TensorDescription Clone() { 76 | return new TensorDescription(this); 77 | } 78 | 79 | /// Field number for the "dtype" field. 80 | public const int DtypeFieldNumber = 1; 81 | private global::Tensorflow.DataType dtype_ = 0; 82 | /// 83 | /// Data type of tensor elements 84 | /// 85 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 86 | public global::Tensorflow.DataType Dtype { 87 | get { return dtype_; } 88 | set { 89 | dtype_ = value; 90 | } 91 | } 92 | 93 | /// Field number for the "shape" field. 94 | public const int ShapeFieldNumber = 2; 95 | private global::Tensorflow.TensorShapeProto shape_; 96 | /// 97 | /// Shape of the tensor. 98 | /// 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 100 | public global::Tensorflow.TensorShapeProto Shape { 101 | get { return shape_; } 102 | set { 103 | shape_ = value; 104 | } 105 | } 106 | 107 | /// Field number for the "allocation_description" field. 108 | public const int AllocationDescriptionFieldNumber = 4; 109 | private global::Tensorflow.AllocationDescription allocationDescription_; 110 | /// 111 | /// Information about the size and allocator used for the data 112 | /// 113 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 114 | public global::Tensorflow.AllocationDescription AllocationDescription { 115 | get { return allocationDescription_; } 116 | set { 117 | allocationDescription_ = value; 118 | } 119 | } 120 | 121 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 122 | public override bool Equals(object other) { 123 | return Equals(other as TensorDescription); 124 | } 125 | 126 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 127 | public bool Equals(TensorDescription other) { 128 | if (ReferenceEquals(other, null)) { 129 | return false; 130 | } 131 | if (ReferenceEquals(other, this)) { 132 | return true; 133 | } 134 | if (Dtype != other.Dtype) return false; 135 | if (!object.Equals(Shape, other.Shape)) return false; 136 | if (!object.Equals(AllocationDescription, other.AllocationDescription)) return false; 137 | return true; 138 | } 139 | 140 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 141 | public override int GetHashCode() { 142 | int hash = 1; 143 | if (Dtype != 0) hash ^= Dtype.GetHashCode(); 144 | if (shape_ != null) hash ^= Shape.GetHashCode(); 145 | if (allocationDescription_ != null) hash ^= AllocationDescription.GetHashCode(); 146 | return hash; 147 | } 148 | 149 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 150 | public override string ToString() { 151 | return pb::JsonFormatter.ToDiagnosticString(this); 152 | } 153 | 154 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 155 | public void WriteTo(pb::CodedOutputStream output) { 156 | if (Dtype != 0) { 157 | output.WriteRawTag(8); 158 | output.WriteEnum((int) Dtype); 159 | } 160 | if (shape_ != null) { 161 | output.WriteRawTag(18); 162 | output.WriteMessage(Shape); 163 | } 164 | if (allocationDescription_ != null) { 165 | output.WriteRawTag(34); 166 | output.WriteMessage(AllocationDescription); 167 | } 168 | } 169 | 170 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 171 | public int CalculateSize() { 172 | int size = 0; 173 | if (Dtype != 0) { 174 | size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Dtype); 175 | } 176 | if (shape_ != null) { 177 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(Shape); 178 | } 179 | if (allocationDescription_ != null) { 180 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(AllocationDescription); 181 | } 182 | return size; 183 | } 184 | 185 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 186 | public void MergeFrom(TensorDescription other) { 187 | if (other == null) { 188 | return; 189 | } 190 | if (other.Dtype != 0) { 191 | Dtype = other.Dtype; 192 | } 193 | if (other.shape_ != null) { 194 | if (shape_ == null) { 195 | shape_ = new global::Tensorflow.TensorShapeProto(); 196 | } 197 | Shape.MergeFrom(other.Shape); 198 | } 199 | if (other.allocationDescription_ != null) { 200 | if (allocationDescription_ == null) { 201 | allocationDescription_ = new global::Tensorflow.AllocationDescription(); 202 | } 203 | AllocationDescription.MergeFrom(other.AllocationDescription); 204 | } 205 | } 206 | 207 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 208 | public void MergeFrom(pb::CodedInputStream input) { 209 | uint tag; 210 | while ((tag = input.ReadTag()) != 0) { 211 | switch(tag) { 212 | default: 213 | input.SkipLastField(); 214 | break; 215 | case 8: { 216 | dtype_ = (global::Tensorflow.DataType) input.ReadEnum(); 217 | break; 218 | } 219 | case 18: { 220 | if (shape_ == null) { 221 | shape_ = new global::Tensorflow.TensorShapeProto(); 222 | } 223 | input.ReadMessage(shape_); 224 | break; 225 | } 226 | case 34: { 227 | if (allocationDescription_ == null) { 228 | allocationDescription_ = new global::Tensorflow.AllocationDescription(); 229 | } 230 | input.ReadMessage(allocationDescription_); 231 | break; 232 | } 233 | } 234 | } 235 | } 236 | 237 | } 238 | 239 | #endregion 240 | 241 | } 242 | 243 | #endregion Designer generated code 244 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Types.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/types.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/types.proto 13 | public static partial class TypesReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/types.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static TypesReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "CiV0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3R5cGVzLnByb3RvEgp0ZW5z", 26 | "b3JmbG93KqoGCghEYXRhVHlwZRIOCgpEVF9JTlZBTElEEAASDAoIRFRfRkxP", 27 | "QVQQARINCglEVF9ET1VCTEUQAhIMCghEVF9JTlQzMhADEgwKCERUX1VJTlQ4", 28 | "EAQSDAoIRFRfSU5UMTYQBRILCgdEVF9JTlQ4EAYSDQoJRFRfU1RSSU5HEAcS", 29 | "EAoMRFRfQ09NUExFWDY0EAgSDAoIRFRfSU5UNjQQCRILCgdEVF9CT09MEAoS", 30 | "DAoIRFRfUUlOVDgQCxINCglEVF9RVUlOVDgQDBINCglEVF9RSU5UMzIQDRIP", 31 | "CgtEVF9CRkxPQVQxNhAOEg0KCURUX1FJTlQxNhAPEg4KCkRUX1FVSU5UMTYQ", 32 | "EBINCglEVF9VSU5UMTYQERIRCg1EVF9DT01QTEVYMTI4EBISCwoHRFRfSEFM", 33 | "RhATEg8KC0RUX1JFU09VUkNFEBQSDgoKRFRfVkFSSUFOVBAVEg0KCURUX1VJ", 34 | "TlQzMhAWEg0KCURUX1VJTlQ2NBAXEhAKDERUX0ZMT0FUX1JFRhBlEhEKDURU", 35 | "X0RPVUJMRV9SRUYQZhIQCgxEVF9JTlQzMl9SRUYQZxIQCgxEVF9VSU5UOF9S", 36 | "RUYQaBIQCgxEVF9JTlQxNl9SRUYQaRIPCgtEVF9JTlQ4X1JFRhBqEhEKDURU", 37 | "X1NUUklOR19SRUYQaxIUChBEVF9DT01QTEVYNjRfUkVGEGwSEAoMRFRfSU5U", 38 | "NjRfUkVGEG0SDwoLRFRfQk9PTF9SRUYQbhIQCgxEVF9RSU5UOF9SRUYQbxIR", 39 | "Cg1EVF9RVUlOVDhfUkVGEHASEQoNRFRfUUlOVDMyX1JFRhBxEhMKD0RUX0JG", 40 | "TE9BVDE2X1JFRhByEhEKDURUX1FJTlQxNl9SRUYQcxISCg5EVF9RVUlOVDE2", 41 | "X1JFRhB0EhEKDURUX1VJTlQxNl9SRUYQdRIVChFEVF9DT01QTEVYMTI4X1JF", 42 | "RhB2Eg8KC0RUX0hBTEZfUkVGEHcSEwoPRFRfUkVTT1VSQ0VfUkVGEHgSEgoO", 43 | "RFRfVkFSSUFOVF9SRUYQeRIRCg1EVF9VSU5UMzJfUkVGEHoSEQoNRFRfVUlO", 44 | "VDY0X1JFRhB7QiwKGG9yZy50ZW5zb3JmbG93LmZyYW1ld29ya0ILVHlwZXNQ", 45 | "cm90b3NQAfgBAWIGcHJvdG8z")); 46 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 47 | new pbr::FileDescriptor[] { }, 48 | new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tensorflow.DataType), }, null)); 49 | } 50 | #endregion 51 | 52 | } 53 | #region Enums 54 | /// 55 | /// LINT.IfChange 56 | /// 57 | public enum DataType { 58 | /// 59 | /// Not a legal value for DataType. Used to indicate a DataType field 60 | /// has not been set. 61 | /// 62 | [pbr::OriginalName("DT_INVALID")] DtInvalid = 0, 63 | /// 64 | /// Data types that all computation devices are expected to be 65 | /// capable to support. 66 | /// 67 | [pbr::OriginalName("DT_FLOAT")] DtFloat = 1, 68 | [pbr::OriginalName("DT_DOUBLE")] DtDouble = 2, 69 | [pbr::OriginalName("DT_INT32")] DtInt32 = 3, 70 | [pbr::OriginalName("DT_UINT8")] DtUint8 = 4, 71 | [pbr::OriginalName("DT_INT16")] DtInt16 = 5, 72 | [pbr::OriginalName("DT_INT8")] DtInt8 = 6, 73 | [pbr::OriginalName("DT_STRING")] DtString = 7, 74 | /// 75 | /// Single-precision complex 76 | /// 77 | [pbr::OriginalName("DT_COMPLEX64")] DtComplex64 = 8, 78 | [pbr::OriginalName("DT_INT64")] DtInt64 = 9, 79 | [pbr::OriginalName("DT_BOOL")] DtBool = 10, 80 | /// 81 | /// Quantized int8 82 | /// 83 | [pbr::OriginalName("DT_QINT8")] DtQint8 = 11, 84 | /// 85 | /// Quantized uint8 86 | /// 87 | [pbr::OriginalName("DT_QUINT8")] DtQuint8 = 12, 88 | /// 89 | /// Quantized int32 90 | /// 91 | [pbr::OriginalName("DT_QINT32")] DtQint32 = 13, 92 | /// 93 | /// Float32 truncated to 16 bits. Only for cast ops. 94 | /// 95 | [pbr::OriginalName("DT_BFLOAT16")] DtBfloat16 = 14, 96 | /// 97 | /// Quantized int16 98 | /// 99 | [pbr::OriginalName("DT_QINT16")] DtQint16 = 15, 100 | /// 101 | /// Quantized uint16 102 | /// 103 | [pbr::OriginalName("DT_QUINT16")] DtQuint16 = 16, 104 | [pbr::OriginalName("DT_UINT16")] DtUint16 = 17, 105 | /// 106 | /// Double-precision complex 107 | /// 108 | [pbr::OriginalName("DT_COMPLEX128")] DtComplex128 = 18, 109 | [pbr::OriginalName("DT_HALF")] DtHalf = 19, 110 | [pbr::OriginalName("DT_RESOURCE")] DtResource = 20, 111 | /// 112 | /// Arbitrary C++ data types 113 | /// 114 | [pbr::OriginalName("DT_VARIANT")] DtVariant = 21, 115 | [pbr::OriginalName("DT_UINT32")] DtUint32 = 22, 116 | [pbr::OriginalName("DT_UINT64")] DtUint64 = 23, 117 | /// 118 | /// Do not use! These are only for parameters. Every enum above 119 | /// should have a corresponding value below (verified by types_test). 120 | /// 121 | [pbr::OriginalName("DT_FLOAT_REF")] DtFloatRef = 101, 122 | [pbr::OriginalName("DT_DOUBLE_REF")] DtDoubleRef = 102, 123 | [pbr::OriginalName("DT_INT32_REF")] DtInt32Ref = 103, 124 | [pbr::OriginalName("DT_UINT8_REF")] DtUint8Ref = 104, 125 | [pbr::OriginalName("DT_INT16_REF")] DtInt16Ref = 105, 126 | [pbr::OriginalName("DT_INT8_REF")] DtInt8Ref = 106, 127 | [pbr::OriginalName("DT_STRING_REF")] DtStringRef = 107, 128 | [pbr::OriginalName("DT_COMPLEX64_REF")] DtComplex64Ref = 108, 129 | [pbr::OriginalName("DT_INT64_REF")] DtInt64Ref = 109, 130 | [pbr::OriginalName("DT_BOOL_REF")] DtBoolRef = 110, 131 | [pbr::OriginalName("DT_QINT8_REF")] DtQint8Ref = 111, 132 | [pbr::OriginalName("DT_QUINT8_REF")] DtQuint8Ref = 112, 133 | [pbr::OriginalName("DT_QINT32_REF")] DtQint32Ref = 113, 134 | [pbr::OriginalName("DT_BFLOAT16_REF")] DtBfloat16Ref = 114, 135 | [pbr::OriginalName("DT_QINT16_REF")] DtQint16Ref = 115, 136 | [pbr::OriginalName("DT_QUINT16_REF")] DtQuint16Ref = 116, 137 | [pbr::OriginalName("DT_UINT16_REF")] DtUint16Ref = 117, 138 | [pbr::OriginalName("DT_COMPLEX128_REF")] DtComplex128Ref = 118, 139 | [pbr::OriginalName("DT_HALF_REF")] DtHalfRef = 119, 140 | [pbr::OriginalName("DT_RESOURCE_REF")] DtResourceRef = 120, 141 | [pbr::OriginalName("DT_VARIANT_REF")] DtVariantRef = 121, 142 | [pbr::OriginalName("DT_UINT32_REF")] DtUint32Ref = 122, 143 | [pbr::OriginalName("DT_UINT64_REF")] DtUint64Ref = 123, 144 | } 145 | 146 | #endregion 147 | 148 | } 149 | 150 | #endregion Designer generated code 151 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/Versions.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/framework/versions.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/framework/versions.proto 13 | public static partial class VersionsReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/framework/versions.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static VersionsReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cih0ZW5zb3JmbG93L2NvcmUvZnJhbWV3b3JrL3ZlcnNpb25zLnByb3RvEgp0", 26 | "ZW5zb3JmbG93IksKClZlcnNpb25EZWYSEAoIcHJvZHVjZXIYASABKAUSFAoM", 27 | "bWluX2NvbnN1bWVyGAIgASgFEhUKDWJhZF9jb25zdW1lcnMYAyADKAVCLwoY", 28 | "b3JnLnRlbnNvcmZsb3cuZnJhbWV3b3JrQg5WZXJzaW9uc1Byb3Rvc1AB+AEB", 29 | "YgZwcm90bzM=")); 30 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 31 | new pbr::FileDescriptor[] { }, 32 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 33 | new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.VersionDef), global::Tensorflow.VersionDef.Parser, new[]{ "Producer", "MinConsumer", "BadConsumers" }, null, null, null) 34 | })); 35 | } 36 | #endregion 37 | 38 | } 39 | #region Messages 40 | /// 41 | /// Version information for a piece of serialized data 42 | /// 43 | /// There are different types of versions for each type of data 44 | /// (GraphDef, etc.), but they all have the same common shape 45 | /// described here. 46 | /// 47 | /// Each consumer has "consumer" and "min_producer" versions (specified 48 | /// elsewhere). A consumer is allowed to consume this data if 49 | /// 50 | /// producer >= min_producer 51 | /// consumer >= min_consumer 52 | /// consumer not in bad_consumers 53 | /// 54 | public sealed partial class VersionDef : pb::IMessage { 55 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new VersionDef()); 56 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 57 | public static pb::MessageParser Parser { get { return _parser; } } 58 | 59 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 60 | public static pbr::MessageDescriptor Descriptor { 61 | get { return global::Tensorflow.VersionsReflection.Descriptor.MessageTypes[0]; } 62 | } 63 | 64 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 65 | pbr::MessageDescriptor pb::IMessage.Descriptor { 66 | get { return Descriptor; } 67 | } 68 | 69 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 70 | public VersionDef() { 71 | OnConstruction(); 72 | } 73 | 74 | partial void OnConstruction(); 75 | 76 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 77 | public VersionDef(VersionDef other) : this() { 78 | producer_ = other.producer_; 79 | minConsumer_ = other.minConsumer_; 80 | badConsumers_ = other.badConsumers_.Clone(); 81 | } 82 | 83 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 84 | public VersionDef Clone() { 85 | return new VersionDef(this); 86 | } 87 | 88 | /// Field number for the "producer" field. 89 | public const int ProducerFieldNumber = 1; 90 | private int producer_; 91 | /// 92 | /// The version of the code that produced this data. 93 | /// 94 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 95 | public int Producer { 96 | get { return producer_; } 97 | set { 98 | producer_ = value; 99 | } 100 | } 101 | 102 | /// Field number for the "min_consumer" field. 103 | public const int MinConsumerFieldNumber = 2; 104 | private int minConsumer_; 105 | /// 106 | /// Any consumer below this version is not allowed to consume this data. 107 | /// 108 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 109 | public int MinConsumer { 110 | get { return minConsumer_; } 111 | set { 112 | minConsumer_ = value; 113 | } 114 | } 115 | 116 | /// Field number for the "bad_consumers" field. 117 | public const int BadConsumersFieldNumber = 3; 118 | private static readonly pb::FieldCodec _repeated_badConsumers_codec 119 | = pb::FieldCodec.ForInt32(26); 120 | private readonly pbc::RepeatedField badConsumers_ = new pbc::RepeatedField(); 121 | /// 122 | /// Specific consumer versions which are disallowed (e.g. due to bugs). 123 | /// 124 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 125 | public pbc::RepeatedField BadConsumers { 126 | get { return badConsumers_; } 127 | } 128 | 129 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 130 | public override bool Equals(object other) { 131 | return Equals(other as VersionDef); 132 | } 133 | 134 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 135 | public bool Equals(VersionDef other) { 136 | if (ReferenceEquals(other, null)) { 137 | return false; 138 | } 139 | if (ReferenceEquals(other, this)) { 140 | return true; 141 | } 142 | if (Producer != other.Producer) return false; 143 | if (MinConsumer != other.MinConsumer) return false; 144 | if(!badConsumers_.Equals(other.badConsumers_)) return false; 145 | return true; 146 | } 147 | 148 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 149 | public override int GetHashCode() { 150 | int hash = 1; 151 | if (Producer != 0) hash ^= Producer.GetHashCode(); 152 | if (MinConsumer != 0) hash ^= MinConsumer.GetHashCode(); 153 | hash ^= badConsumers_.GetHashCode(); 154 | return hash; 155 | } 156 | 157 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 158 | public override string ToString() { 159 | return pb::JsonFormatter.ToDiagnosticString(this); 160 | } 161 | 162 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 163 | public void WriteTo(pb::CodedOutputStream output) { 164 | if (Producer != 0) { 165 | output.WriteRawTag(8); 166 | output.WriteInt32(Producer); 167 | } 168 | if (MinConsumer != 0) { 169 | output.WriteRawTag(16); 170 | output.WriteInt32(MinConsumer); 171 | } 172 | badConsumers_.WriteTo(output, _repeated_badConsumers_codec); 173 | } 174 | 175 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 176 | public int CalculateSize() { 177 | int size = 0; 178 | if (Producer != 0) { 179 | size += 1 + pb::CodedOutputStream.ComputeInt32Size(Producer); 180 | } 181 | if (MinConsumer != 0) { 182 | size += 1 + pb::CodedOutputStream.ComputeInt32Size(MinConsumer); 183 | } 184 | size += badConsumers_.CalculateSize(_repeated_badConsumers_codec); 185 | return size; 186 | } 187 | 188 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 189 | public void MergeFrom(VersionDef other) { 190 | if (other == null) { 191 | return; 192 | } 193 | if (other.Producer != 0) { 194 | Producer = other.Producer; 195 | } 196 | if (other.MinConsumer != 0) { 197 | MinConsumer = other.MinConsumer; 198 | } 199 | badConsumers_.Add(other.badConsumers_); 200 | } 201 | 202 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 203 | public void MergeFrom(pb::CodedInputStream input) { 204 | uint tag; 205 | while ((tag = input.ReadTag()) != 0) { 206 | switch(tag) { 207 | default: 208 | input.SkipLastField(); 209 | break; 210 | case 8: { 211 | Producer = input.ReadInt32(); 212 | break; 213 | } 214 | case 16: { 215 | MinConsumer = input.ReadInt32(); 216 | break; 217 | } 218 | case 26: 219 | case 24: { 220 | badConsumers_.AddEntriesFrom(input, _repeated_badConsumers_codec); 221 | break; 222 | } 223 | } 224 | } 225 | } 226 | 227 | } 228 | 229 | #endregion 230 | 231 | } 232 | 233 | #endregion Designer generated code 234 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Service/WorkerService.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: tensorflow/core/protobuf/worker_service.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace Tensorflow.Grpc { 11 | 12 | /// Holder for reflection information generated from tensorflow/core/protobuf/worker_service.proto 13 | public static partial class WorkerServiceReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for tensorflow/core/protobuf/worker_service.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static WorkerServiceReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Ci10ZW5zb3JmbG93L2NvcmUvcHJvdG9idWYvd29ya2VyX3NlcnZpY2UucHJv", 26 | "dG8SD3RlbnNvcmZsb3cuZ3JwYxoldGVuc29yZmxvdy9jb3JlL3Byb3RvYnVm", 27 | "L3dvcmtlci5wcm90bzKZBwoNV29ya2VyU2VydmljZRJICglHZXRTdGF0dXMS", 28 | "HC50ZW5zb3JmbG93LkdldFN0YXR1c1JlcXVlc3QaHS50ZW5zb3JmbG93Lkdl", 29 | "dFN0YXR1c1Jlc3BvbnNlEmYKE0NyZWF0ZVdvcmtlclNlc3Npb24SJi50ZW5z", 30 | "b3JmbG93LkNyZWF0ZVdvcmtlclNlc3Npb25SZXF1ZXN0GicudGVuc29yZmxv", 31 | "dy5DcmVhdGVXb3JrZXJTZXNzaW9uUmVzcG9uc2USZgoTRGVsZXRlV29ya2Vy", 32 | "U2Vzc2lvbhImLnRlbnNvcmZsb3cuRGVsZXRlV29ya2VyU2Vzc2lvblJlcXVl", 33 | "c3QaJy50ZW5zb3JmbG93LkRlbGV0ZVdvcmtlclNlc3Npb25SZXNwb25zZRJU", 34 | "Cg1SZWdpc3RlckdyYXBoEiAudGVuc29yZmxvdy5SZWdpc3RlckdyYXBoUmVx", 35 | "dWVzdBohLnRlbnNvcmZsb3cuUmVnaXN0ZXJHcmFwaFJlc3BvbnNlEloKD0Rl", 36 | "cmVnaXN0ZXJHcmFwaBIiLnRlbnNvcmZsb3cuRGVyZWdpc3RlckdyYXBoUmVx", 37 | "dWVzdBojLnRlbnNvcmZsb3cuRGVyZWdpc3RlckdyYXBoUmVzcG9uc2USRQoI", 38 | "UnVuR3JhcGgSGy50ZW5zb3JmbG93LlJ1bkdyYXBoUmVxdWVzdBocLnRlbnNv", 39 | "cmZsb3cuUnVuR3JhcGhSZXNwb25zZRJRCgxDbGVhbnVwR3JhcGgSHy50ZW5z", 40 | "b3JmbG93LkNsZWFudXBHcmFwaFJlcXVlc3QaIC50ZW5zb3JmbG93LkNsZWFu", 41 | "dXBHcmFwaFJlc3BvbnNlEksKCkNsZWFudXBBbGwSHS50ZW5zb3JmbG93LkNs", 42 | "ZWFudXBBbGxSZXF1ZXN0Gh4udGVuc29yZmxvdy5DbGVhbnVwQWxsUmVzcG9u", 43 | "c2USTQoKUmVjdlRlbnNvchIdLnRlbnNvcmZsb3cuUmVjdlRlbnNvclJlcXVl", 44 | "c3QaHi50ZW5zb3JmbG93LlJlY3ZUZW5zb3JSZXNwb25zZSIAEkIKB0xvZ2dp", 45 | "bmcSGi50ZW5zb3JmbG93LkxvZ2dpbmdSZXF1ZXN0GhsudGVuc29yZmxvdy5M", 46 | "b2dnaW5nUmVzcG9uc2USQgoHVHJhY2luZxIaLnRlbnNvcmZsb3cuVHJhY2lu", 47 | "Z1JlcXVlc3QaGy50ZW5zb3JmbG93LlRyYWNpbmdSZXNwb25zZUIzChpvcmcu", 48 | "dGVuc29yZmxvdy5kaXN0cnVudGltZUITV29ya2VyU2VydmljZVByb3Rvc1AB", 49 | "YgZwcm90bzM=")); 50 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 51 | new pbr::FileDescriptor[] { global::Tensorflow.WorkerReflection.Descriptor, }, 52 | new pbr::GeneratedClrTypeInfo(null, null)); 53 | } 54 | #endregion 55 | 56 | } 57 | } 58 | 59 | #endregion Designer generated code 60 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/TensorFlowServingClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {73169028-08E0-45D3-8673-241B7164163A} 8 | Library 9 | Properties 10 | TensorFlowServingClient 11 | TensorFlowServingClient 12 | v4.6.1 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll 37 | True 38 | 39 | 40 | ..\..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll 41 | True 42 | 43 | 44 | 45 | 46 | 47 | ..\..\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll 48 | True 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 135 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Utils/ImageUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Drawing.Drawing2D; 3 | using System.Drawing.Imaging; 4 | using System.IO; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace TensorFlowServingClient.Utils 8 | { 9 | public class ImageUtils 10 | { 11 | 12 | public static int[][] ConvertImageStreamToDimArrays(Bitmap bitmap) 13 | { 14 | var bitmapArray = BitmapToByteArray(bitmap); 15 | using (var memoryStream = new MemoryStream(bitmapArray)) 16 | { 17 | memoryStream.Position = 0; 18 | return ConvertImageDataToDimArrays(bitmap.Height, bitmap.Width, memoryStream); 19 | } 20 | } 21 | 22 | public static int[][] ConvertImageStreamToDimArrays(Stream stream) 23 | { 24 | using (var bitmap = new Bitmap(stream)) 25 | { 26 | var bitmapArray = BitmapToByteArray(bitmap); 27 | using (var memoryStream = new MemoryStream(bitmapArray)) 28 | { 29 | memoryStream.Position = 0; 30 | return ConvertImageDataToDimArrays(bitmap.Height, bitmap.Width, memoryStream); 31 | } 32 | } 33 | } 34 | 35 | private static int[][] ConvertImageDataToDimArrays(int numRows, int numCols, MemoryStream stream) 36 | { 37 | var imageMatrix = new int[numRows][]; 38 | for (int row = 0; row < numRows; row++) 39 | { 40 | imageMatrix[row] = new int[numCols]; 41 | for (int col = 0; col < numCols; ++col) 42 | { 43 | imageMatrix[row][col] = stream.ReadByte(); 44 | } 45 | } 46 | return imageMatrix; 47 | } 48 | 49 | private static byte[] BitmapToByteArray(Bitmap bitmap) 50 | { 51 | BitmapData bmpdata = null; 52 | 53 | try 54 | { 55 | bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); 56 | int numbytes = bmpdata.Stride * bitmap.Height; 57 | var bytedata = new byte[numbytes]; 58 | var ptr = bmpdata.Scan0; 59 | Marshal.Copy(ptr, bytedata, 0, numbytes); 60 | 61 | if(bitmap.PixelFormat == PixelFormat.Format24bppRgb) 62 | { 63 | var byteData8BFormat = new byte[bytedata.Length / 3]; 64 | 65 | for(int i = 0; i < byteData8BFormat.Length; i++) 66 | { 67 | byteData8BFormat[i] = (byte)((bytedata[i * 3] + bytedata[i * 3 + 1] + bytedata[i * 3 + 2]) / 3); 68 | } 69 | 70 | return byteData8BFormat; 71 | } 72 | else if(bitmap.PixelFormat == PixelFormat.Format32bppArgb) 73 | { 74 | var byteData8BFormat = new byte[bytedata.Length / 4]; 75 | 76 | for (int i = 0; i < byteData8BFormat.Length; i++) 77 | { 78 | byteData8BFormat[i] = (byte)((bytedata[i * 4 + 1] + bytedata[i * 4 + 2] + bytedata[i * 4 + 3]) / 3); 79 | } 80 | 81 | return byteData8BFormat; 82 | } 83 | 84 | 85 | return bytedata; 86 | } 87 | finally 88 | { 89 | if (bmpdata != null) 90 | bitmap.UnlockBits(bmpdata); 91 | } 92 | } 93 | 94 | public static Bitmap ResizeImage(Image image, int width, int height, int src_width, int src_height) 95 | { 96 | var destRect = new Rectangle(0, 0, width, height); 97 | var destImage = new Bitmap(width, height, PixelFormat.Format24bppRgb); 98 | 99 | destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); 100 | 101 | using (var graphics = Graphics.FromImage(destImage)) 102 | { 103 | graphics.FillRectangle(new SolidBrush(Color.Black), destRect); 104 | graphics.CompositingMode = CompositingMode.SourceOver; 105 | graphics.CompositingQuality = CompositingQuality.HighQuality; 106 | graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; 107 | graphics.SmoothingMode = SmoothingMode.HighQuality; 108 | graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; 109 | 110 | using (var wrapMode = new ImageAttributes()) 111 | { 112 | wrapMode.SetWrapMode(WrapMode.TileFlipXY); 113 | graphics.DrawImage(image, destRect, 0, 0, src_width, src_height, GraphicsUnit.Pixel, wrapMode); 114 | } 115 | } 116 | 117 | return destImage; 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Utils/ModelMethodClasses.cs: -------------------------------------------------------------------------------- 1 | namespace TensorFlowServingClient.Utils 2 | { 3 | public class ModelMethodClasses 4 | { 5 | public const string PredictImages = "predict_images"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Utils/TensorBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.IO; 3 | using Tensorflow; 4 | 5 | namespace TensorFlowServingClient.Utils 6 | { 7 | public class TensorBuilder 8 | { 9 | public static TensorProto CreateTensor(float value) 10 | { 11 | var tensor = new TensorProto(); 12 | tensor.FloatVal.Add(value); 13 | tensor.TensorShape = new TensorShapeProto(); 14 | tensor.Dtype = DataType.DtFloat; 15 | var dim = new TensorShapeProto.Types.Dim(); 16 | dim.Size = 1; 17 | tensor.TensorShape.Dim.Add(dim); 18 | 19 | return tensor; 20 | } 21 | 22 | public static TensorProto CreateTensorFromImage(Bitmap image, float revertsBits = 1.0f) 23 | { 24 | var imageData = ImageUtils.ConvertImageStreamToDimArrays(image); 25 | return CreateTensorFromImage(imageData, revertsBits); 26 | } 27 | 28 | public static TensorProto CreateTensorFromImage(Stream stream, float revertsBits = 1.0f) 29 | { 30 | var imageData = ImageUtils.ConvertImageStreamToDimArrays(stream); 31 | return CreateTensorFromImage(imageData, revertsBits); 32 | } 33 | 34 | public static TensorProto CreateTensorFromImage(int[][] imageData, float revertsBits) 35 | { 36 | var imageFeatureShape = new TensorShapeProto(); 37 | 38 | imageFeatureShape.Dim.Add(new TensorShapeProto.Types.Dim() { Size = 1 }); 39 | imageFeatureShape.Dim.Add(new TensorShapeProto.Types.Dim() { Size = imageData.Length * imageData.Length }); 40 | 41 | var imageTensorBuilder = new TensorProto(); 42 | imageTensorBuilder.Dtype = DataType.DtFloat; 43 | imageTensorBuilder.TensorShape = imageFeatureShape; 44 | 45 | for (int i = 0; i < imageData.Length; ++i) 46 | { 47 | for (int j = 0; j < imageData.Length; ++j) 48 | { 49 | imageTensorBuilder.FloatVal.Add(imageData[i][j] / revertsBits); 50 | } 51 | } 52 | 53 | return imageTensorBuilder; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/Utils/TextUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace TensorFlowServingClient.Utils 4 | { 5 | public class TextUtils 6 | { 7 | public static string RenderImageData(int[][] image) 8 | { 9 | var sb = new StringBuilder(); 10 | 11 | for (int row = 0; row < image.Length; row++) 12 | { 13 | sb.Append("|"); 14 | for (int col = 0; col < image[row].Length; col++) 15 | { 16 | int pixelVal = image[row][col]; 17 | if (pixelVal == 0) 18 | sb.Append(" "); 19 | else if (pixelVal < 256 / 3) 20 | sb.Append("."); 21 | else if (pixelVal < 2 * (256 / 3)) 22 | sb.Append("x"); 23 | else 24 | sb.Append("X"); 25 | } 26 | sb.Append("|\n"); 27 | } 28 | 29 | return sb.ToString(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/build_proto.bat: -------------------------------------------------------------------------------- 1 | FOR %%i IN (%~dp0protos/*.proto) DO %~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/protoc.exe --proto_path="%~dp0protos" --csharp_out="%~dp0Service" %~dp0protos/%%~ni.proto 2 | FOR %%i IN (%~dp0protos/tensorflow/core/example/*.proto) DO %~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/protoc.exe --proto_path="%~dp0protos" --csharp_out="%~dp0Service" %~dp0protos/tensorflow/core/example/%%~ni.proto 3 | FOR %%i IN (%~dp0protos/tensorflow/core/protobuf/*.proto) DO %~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/protoc.exe --proto_path="%~dp0protos" --csharp_out="%~dp0Service" %~dp0protos/tensorflow/core/protobuf/%%~ni.proto 4 | FOR %%i IN (%~dp0protos/tensorflow/core/framework/*.proto) DO %~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/protoc.exe --proto_path="%~dp0protos" --csharp_out="%~dp0Service" %~dp0protos/tensorflow/core/framework/%%~ni.proto 5 | 6 | %~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/protoc.exe -I "%~dp0protos" --csharp_out "%~dp0Service" --grpc_out "%~dp0Service" "%~dp0protos/prediction_service.proto" --plugin=protoc-gen-grpc="%~dp0../../packages/Grpc.Tools.1.8.0/tools/windows_x86/grpc_csharp_plugin.exe" -------------------------------------------------------------------------------- /src/BaseLibs/TensorFlowServingClient/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/ConsoleTensorFlowServingClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870} 8 | Exe 9 | Properties 10 | ConsoleTensorFlowServingClient 11 | ConsoleTensorFlowServingClient 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll 40 | True 41 | 42 | 43 | ..\..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll 44 | True 45 | 46 | 47 | 48 | 49 | 50 | 51 | ..\..\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll 52 | True 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | {73169028-08e0-45d3-8673-241b7164163a} 72 | TensorFlowServingClient 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 97 | -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/0.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/0.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/1.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/2.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/3.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/4.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/5.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/6.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/7.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/8.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Examples/9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/ConsoleTensorFlowServingClient/Examples/9.bmp -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.IO; 4 | using System.Linq; 5 | using Grpc.Core; 6 | using Tensorflow.Serving; 7 | using TensorFlowServingClient.Utils; 8 | 9 | namespace ConsoleTensorFlowServingClient 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | //Create gRPC Channel 16 | var channel = new Channel(ConfigurationManager.AppSettings["ServerHost"], ChannelCredentials.Insecure); 17 | var client = new PredictionService.PredictionServiceClient(channel); 18 | 19 | //Check available MNIST model 20 | var responce = client.GetModelMetadata(new GetModelMetadataRequest() 21 | { 22 | ModelSpec = new ModelSpec() { Name = "mnist" }, 23 | MetadataField = { "signature_def" } 24 | }); 25 | 26 | Console.WriteLine($"Model Available: {responce.ModelSpec.Name} Ver.{responce.ModelSpec.Version}"); 27 | 28 | var imagesFolder = ConfigurationManager.AppSettings["ImagesFolder"]; 29 | 30 | //Process images prediction from 0 to 9 fromexample folder 31 | for (int number = 0; number < 10; number++) 32 | { 33 | 34 | //Create prediction request 35 | var request = new PredictRequest() 36 | { 37 | ModelSpec = new ModelSpec() {Name = "mnist", SignatureName = ModelMethodClasses.PredictImages} 38 | }; 39 | 40 | //Add image tensor [1 - 784] 41 | using (Stream stream = new FileStream($"{AppDomain.CurrentDomain.BaseDirectory}/{imagesFolder}/{number}.bmp", FileMode.Open)) 42 | { 43 | request.Inputs.Add("images", TensorBuilder.CreateTensorFromImage(stream, 255.0f)); 44 | } 45 | 46 | //Add keep_prob tensor [1 - 1] 47 | request.Inputs.Add("keep_prob", TensorBuilder.CreateTensor(0.5f)); 48 | 49 | var predictResponse = client.Predict(request); 50 | 51 | //Compute Max value from prediction array 52 | var maxValue = predictResponse.Outputs["scores"].FloatVal.Max(); 53 | //Get index of predicted value 54 | var predictedValue = predictResponse.Outputs["scores"].FloatVal.IndexOf(maxValue); 55 | 56 | Console.WriteLine($"Predict: {number} {(number == predictedValue ? "Y" : "N")}"); 57 | Console.WriteLine($"Result value: {predictedValue}, probability: {maxValue}"); 58 | Console.WriteLine($"All values: {predictResponse.Outputs["scores"].FloatVal}"); 59 | Console.WriteLine(""); 60 | } 61 | 62 | channel.ShutdownAsync().Wait(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ConsoleTFServingClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConsoleTFServingClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("fc26fd2a-fe41-4684-a95a-471cdedbb870")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Clients/ConsoleTensorFlowServingClient/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/.gitignore: -------------------------------------------------------------------------------- 1 | /Properties/launchSettings.json 2 | 3 | ## Ignore Visual Studio temporary files, build results, and 4 | ## files generated by popular Visual Studio add-ons. 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | build/ 23 | bld/ 24 | bin/ 25 | Bin/ 26 | obj/ 27 | Obj/ 28 | 29 | # Visual Studio 2015 cache/options directory 30 | .vs/ 31 | /wwwroot/dist/ 32 | /ClientApp/dist/ 33 | 34 | /yarn.lock 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | *_i.c 50 | *_p.c 51 | *_i.h 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.tmp_proj 66 | *.log 67 | *.vspscc 68 | *.vssscc 69 | .builds 70 | *.pidb 71 | *.svclog 72 | *.scc 73 | 74 | # Chutzpah Test files 75 | _Chutzpah* 76 | 77 | # Visual C++ cache files 78 | ipch/ 79 | *.aps 80 | *.ncb 81 | *.opendb 82 | *.opensdf 83 | *.sdf 84 | *.cachefile 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # NuGet Packages 149 | *.nupkg 150 | # The packages folder can be ignored because of Package Restore 151 | **/packages/* 152 | # except build/, which is used as an MSBuild target. 153 | !**/packages/build/ 154 | # Uncomment if necessary however generally it will be regenerated when needed 155 | #!**/packages/repositories.config 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | orleans.codegen.cs 187 | 188 | /node_modules 189 | 190 | # RIA/Silverlight projects 191 | Generated_Code/ 192 | 193 | # Backup & report files from converting an old project file 194 | # to a newer Visual Studio version. Backup files are not needed, 195 | # because we have git ;-) 196 | _UpgradeReport_Files/ 197 | Backup*/ 198 | UpgradeLog*.XML 199 | UpgradeLog*.htm 200 | 201 | # SQL Server files 202 | *.mdf 203 | *.ldf 204 | 205 | # Business Intelligence projects 206 | *.rdl.data 207 | *.bim.layout 208 | *.bim_*.settings 209 | 210 | # Microsoft Fakes 211 | FakesAssemblies/ 212 | 213 | # GhostDoc plugin setting file 214 | *.GhostDoc.xml 215 | 216 | # Node.js Tools for Visual Studio 217 | .ntvs_analysis.dat 218 | 219 | # Visual Studio 6 build log 220 | *.plg 221 | 222 | # Visual Studio 6 workspace options file 223 | *.opt 224 | 225 | # Visual Studio LightSwitch build output 226 | **/*.HTMLClient/GeneratedArtifacts 227 | **/*.DesktopClient/GeneratedArtifacts 228 | **/*.DesktopClient/ModelManifest.xml 229 | **/*.Server/GeneratedArtifacts 230 | **/*.Server/ModelManifest.xml 231 | _Pvt_Extensions 232 | 233 | # Paket dependency manager 234 | .paket/paket.exe 235 | 236 | # FAKE - F# Make 237 | .fake/ 238 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/boot-client.tsx: -------------------------------------------------------------------------------- 1 | import './css/site.css'; 2 | import 'bootstrap'; 3 | import * as React from 'react'; 4 | import * as ReactDOM from 'react-dom'; 5 | import { AppContainer } from 'react-hot-loader'; 6 | import { Provider } from 'react-redux'; 7 | import { ConnectedRouter } from 'react-router-redux'; 8 | import { createBrowserHistory } from 'history'; 9 | import configureStore from './configureStore'; 10 | import { ApplicationState } from './store'; 11 | import * as RoutesModule from './routes'; 12 | let routes = RoutesModule.routes; 13 | 14 | // Create browser history to use in the Redux store 15 | const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!; 16 | const history = createBrowserHistory({ basename: baseUrl }); 17 | 18 | // Get the application-wide store instance, prepopulating with state from the server where available. 19 | const initialState = (window as any).initialReduxState as ApplicationState; 20 | const store = configureStore(history, initialState); 21 | 22 | function renderApp() { 23 | // This code starts up the React app when it runs in a browser. It sets up the routing configuration 24 | // and injects the app into a DOM element. 25 | ReactDOM.render( 26 | 27 | 28 | 29 | 30 | , 31 | document.getElementById('react-app') 32 | ); 33 | } 34 | 35 | renderApp(); 36 | 37 | // Allow Hot Module Replacement 38 | if (module.hot) { 39 | module.hot.accept('./routes', () => { 40 | routes = require('./routes').routes; 41 | renderApp(); 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/boot-server.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Provider } from 'react-redux'; 3 | import { renderToString } from 'react-dom/server'; 4 | import { StaticRouter } from 'react-router-dom'; 5 | import { replace } from 'react-router-redux'; 6 | import { createMemoryHistory } from 'history'; 7 | import { createServerRenderer, RenderResult } from 'aspnet-prerendering'; 8 | import { routes } from './routes'; 9 | import configureStore from './configureStore'; 10 | 11 | export default createServerRenderer(params => { 12 | return new Promise((resolve, reject) => { 13 | // Prepare Redux store with in-memory history, and dispatch a navigation event 14 | // corresponding to the incoming URL 15 | const basename = params.baseUrl.substring(0, params.baseUrl.length - 1); // Remove trailing slash 16 | const urlAfterBasename = params.url.substring(basename.length); 17 | const store = configureStore(createMemoryHistory()); 18 | store.dispatch(replace(urlAfterBasename)); 19 | 20 | // Prepare an instance of the application and perform an inital render that will 21 | // cause any async tasks (e.g., data access) to begin 22 | const routerContext: any = {}; 23 | const app = ( 24 | 25 | 26 | 27 | ); 28 | renderToString(app); 29 | 30 | // If there's a redirection, just send this information back to the host application 31 | if (routerContext.url) { 32 | resolve({ redirectUrl: routerContext.url }); 33 | return; 34 | } 35 | 36 | // Once any async tasks are done, we can perform the final render 37 | // We also send the redux store state, so the client can continue execution where the server left off 38 | params.domainTasks.then(() => { 39 | resolve({ 40 | html: renderToString(app), 41 | globals: { initialReduxState: store.getState() } 42 | }); 43 | }, reject); // Also propagate any errors back into the host application 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/components/BarChart.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as BarChart from 'react-chartjs'; 3 | 4 | type BarChartProps = { 5 | results: number[]; 6 | } 7 | 8 | export class BarChartComponent extends React.Component { 9 | public render() { 10 | 11 | return 28 | } 29 | } -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/components/DrawComponent.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactPaint from 'react-paint'; 3 | 4 | const props = { 5 | style: { 6 | background: '#000000', 7 | }, 8 | brushCol: '#ffffff', 9 | lineWidth: 10, 10 | className: 'react-paint', 11 | height: 380, 12 | width: 280 13 | }; 14 | 15 | 16 | export class DrawComponent extends React.Component { 17 | 18 | constructor(props: any) { 19 | super(props); 20 | this.clear = this.clear.bind(this); 21 | } 22 | 23 | public getImageData() { 24 | let clearing = this.state ? this.state.clearing : false; 25 | 26 | let image = (this.refs["paint_region"] as any).canvas.toDataURL("image/png"); 27 | return image.replace('data:image/png;base64,', ''); 28 | } 29 | 30 | public clear() { 31 | this.setState({ clearing: this.state != null ? !this.state.clearing : false }); 32 | setTimeout(() => { this.setState({ clearing: this.state != null ? !this.state.clearing : false }) }, 200); 33 | } 34 | 35 | public render() { 36 | let clearValue = this.state != null ? this.state.clearing : true; 37 | 38 | if (!clearValue) { 39 | return ( 40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
); 48 | } 49 | 50 | return ( 51 |
52 | 53 |
54 |
55 |
56 |
); 57 | } 58 | } -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/components/Layout.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { NavMenu } from './NavMenu'; 3 | 4 | export class Layout extends React.Component<{}, {}> { 5 | public render() { 6 | return
7 |
8 |
9 | 10 |
11 |
12 | { this.props.children } 13 |
14 |
15 |
; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/components/NavMenu.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { NavLink, Link } from 'react-router-dom'; 3 | 4 | export class NavMenu extends React.Component<{}, {}> { 5 | public render() { 6 | return
7 |
8 |
9 | 15 | TensorFlow Serving Client 16 |
17 |
18 |
19 |
    20 |
  • 21 | 22 | MNIST Deep Prediction 23 | 24 |
  • 25 |
26 |
27 |
28 |
; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/components/NumberPredictComponent.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Link, RouteComponentProps } from 'react-router-dom'; 3 | import { connect } from 'react-redux'; 4 | import { ApplicationState } from '../store'; 5 | import * as NumberPredictStore from '../store/NumberPredict'; 6 | import { BarChartComponent } from './BarChart'; 7 | import { DrawComponent } from './DrawComponent'; 8 | 9 | type NumberPredictProps = 10 | NumberPredictStore.NumberPredictState 11 | & typeof NumberPredictStore.actionCreators 12 | & RouteComponentProps; 13 | 14 | class NumberPredictComponent extends React.Component { 15 | 16 | public render() { 17 | 18 | return
19 |

MNIST Deep: number prediction

20 |

Please draw number and click "Predict" button.

21 |
22 |
23 | 24 |
25 | 28 | 29 | 32 |
33 |
34 |
35 | { 36 | this.props.loading ? 37 |

Loading ...

38 | : this.props.loaded ? 39 | (this.props.predictResult ? 40 |
41 |

It is: {this.props.numberPredicted}

42 | 43 |
{this.props.debugText}
44 |
45 | :

46 | Error processing prediction: 47 |
{this.props.errorMessage} 48 |

) 49 | : null 50 | } 51 |
52 |
53 |
; 54 | } 55 | } 56 | 57 | export default connect( 58 | (state: ApplicationState) => state.numberPredict, 59 | NumberPredictStore.actionCreators 60 | )(NumberPredictComponent) as typeof NumberPredictComponent; -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/configureStore.ts: -------------------------------------------------------------------------------- 1 | import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer, Store, StoreEnhancerStoreCreator, ReducersMapObject } from 'redux'; 2 | import thunk from 'redux-thunk'; 3 | import { routerReducer, routerMiddleware } from 'react-router-redux'; 4 | import * as StoreModule from './store'; 5 | import { ApplicationState, reducers } from './store'; 6 | import { History } from 'history'; 7 | 8 | export default function configureStore(history: History, initialState?: ApplicationState) { 9 | // Build middleware. These are functions that can process the actions before they reach the store. 10 | const windowIfDefined = typeof window === 'undefined' ? null : window as any; 11 | // If devTools is installed, connect to it 12 | const devToolsExtension = windowIfDefined && windowIfDefined.__REDUX_DEVTOOLS_EXTENSION__ as () => GenericStoreEnhancer; 13 | const createStoreWithMiddleware = compose( 14 | applyMiddleware(thunk, routerMiddleware(history)), 15 | devToolsExtension ? devToolsExtension() : (next: StoreEnhancerStoreCreator) => next 16 | )(createStore); 17 | 18 | // Combine all reducers and instantiate the app-wide store instance 19 | const allReducers = buildRootReducer(reducers); 20 | const store = createStoreWithMiddleware(allReducers, initialState) as Store; 21 | 22 | // Enable Webpack hot module replacement for reducers 23 | if (module.hot) { 24 | module.hot.accept('./store', () => { 25 | const nextRootReducer = require('./store'); 26 | store.replaceReducer(buildRootReducer(nextRootReducer.reducers)); 27 | }); 28 | } 29 | 30 | return store; 31 | } 32 | 33 | function buildRootReducer(allReducers: ReducersMapObject) { 34 | return combineReducers(Object.assign({}, allReducers, { routing: routerReducer })); 35 | } 36 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/css/site.css: -------------------------------------------------------------------------------- 1 | .main-nav li .glyphicon { 2 | margin-right: 10px; 3 | } 4 | 5 | /* Highlighting rules for nav menu items */ 6 | .main-nav li a.active, 7 | .main-nav li a.active:hover, 8 | .main-nav li a.active:focus { 9 | background-color: #4189C7; 10 | color: white; 11 | } 12 | 13 | /* Keep the nav menu independent of scrolling and on top of other items */ 14 | .main-nav { 15 | position: fixed; 16 | top: 0; 17 | left: 0; 18 | right: 0; 19 | z-index: 1; 20 | } 21 | 22 | .m-b-10 { 23 | margin-bottom: 10px; 24 | } 25 | 26 | 27 | .m-r-10 { 28 | margin-right: 10px; 29 | } 30 | 31 | .debug-region { 32 | background: #ffffff; 33 | border: none; 34 | font-size: 10px; 35 | line-height: 1.1; 36 | letter-spacing: 4px; 37 | } 38 | 39 | .paint_region_hack { 40 | background: #ffffff; 41 | height: 100px; 42 | bottom: 0px; 43 | left: 0px; 44 | position: absolute; 45 | width: 100%; 46 | } 47 | 48 | .paint_region_clear{ 49 | width: 280px; 50 | background: #000000; 51 | height: 380px; 52 | } 53 | 54 | .paint_region_container { 55 | position: relative; 56 | } 57 | 58 | @media (max-width: 767px) { 59 | /* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */ 60 | body { 61 | padding-top: 50px; 62 | } 63 | } 64 | 65 | @media (min-width: 768px) { 66 | /* On small screens, convert the nav menu to a vertical sidebar */ 67 | .main-nav { 68 | height: 100%; 69 | width: calc(25% - 20px); 70 | } 71 | .main-nav .navbar { 72 | border-radius: 0px; 73 | border-width: 0px; 74 | height: 100%; 75 | } 76 | .main-nav .navbar-header { 77 | float: none; 78 | } 79 | .main-nav .navbar-collapse { 80 | border-top: 1px solid #444; 81 | padding: 0px; 82 | } 83 | .main-nav .navbar ul { 84 | float: none; 85 | } 86 | .main-nav .navbar li { 87 | float: none; 88 | font-size: 15px; 89 | margin: 6px; 90 | } 91 | .main-nav .navbar li a { 92 | padding: 10px 16px; 93 | border-radius: 4px; 94 | } 95 | .main-nav .navbar a { 96 | /* If a menu item's text is too long, truncate it */ 97 | width: 100%; 98 | white-space: nowrap; 99 | overflow: hidden; 100 | text-overflow: ellipsis; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/routes.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Route } from 'react-router-dom'; 3 | import NumberPredictComponent from './components/NumberPredictComponent'; 4 | import { Layout } from './components/Layout'; 5 | 6 | export const routes = 7 | 8 | 9 | ; 10 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/store/NumberPredict.ts: -------------------------------------------------------------------------------- 1 | import { fetch, addTask } from 'domain-task'; 2 | import { Action, Reducer, ActionCreator } from 'redux'; 3 | import { AppThunkAction } from './'; 4 | 5 | 6 | export interface PredictionResult { 7 | results: number[]; 8 | predictedNumber: number; 9 | success: boolean; 10 | errorMessage: string; 11 | debugText: string; 12 | } 13 | 14 | export interface NumberPredictState { 15 | loading: boolean; 16 | loaded: boolean; 17 | results: number[]; 18 | numberPredicted: number; 19 | predictResult: boolean; 20 | errorMessage: string; 21 | debugText: string; 22 | } 23 | 24 | interface PredictImageNumberActionLoading { type: 'PREDICT_IMAGE_LOADING' } 25 | 26 | interface PredictImageNumberActionLoaded { 27 | type: 'PREDICT_IMAGE_LOADED'; 28 | results: number[]; 29 | numberPredicted: number; 30 | predictResult: boolean; 31 | errorMessage: string; 32 | debugText: string; 33 | } 34 | 35 | type KnownAction = PredictImageNumberActionLoading | PredictImageNumberActionLoaded; 36 | 37 | 38 | export const actionCreators = { 39 | tryPredictNumber: (imageData: any): AppThunkAction => (dispatch, getState) => { 40 | 41 | let fetchTask = fetch('api/MnistDeep/PredictNumber', { 42 | method: 'POST', 43 | headers: { 44 | 'Accept': 'application/json', 45 | 'Content-Type': 'application/json' 46 | }, 47 | body: '{ "imageData": "' + imageData + '" }' 48 | }) 49 | .then(response => response.json() as Promise) 50 | .then(data => { 51 | dispatch({ type: 'PREDICT_IMAGE_LOADED', results: data.results, numberPredicted: data.predictedNumber, predictResult: data.success, errorMessage: data.errorMessage, debugText: data.debugText }); 52 | }); 53 | 54 | addTask(fetchTask); // Ensure server-side prerendering waits for this to complete 55 | dispatch({ type: 'PREDICT_IMAGE_LOADING' }); 56 | } 57 | }; 58 | 59 | export const reducer: Reducer = (state: NumberPredictState, action: KnownAction) => { 60 | switch (action.type) { 61 | case 'PREDICT_IMAGE_LOADING': 62 | return { loading: true, loaded: false } as NumberPredictState; 63 | case 'PREDICT_IMAGE_LOADED': 64 | return { loaded: true, loading: false, numberPredicted: action.numberPredicted, results: action.results, predictResult: action.predictResult, errorMessage: action.errorMessage, debugText: action.debugText } as NumberPredictState; 65 | } 66 | 67 | return state || { loading: false, loaded: false } as NumberPredictState; 68 | }; 69 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/ClientApp/store/index.ts: -------------------------------------------------------------------------------- 1 | import * as NumberPredict from './NumberPredict'; 2 | 3 | 4 | // The top-level state object 5 | export interface ApplicationState { 6 | numberPredict: NumberPredict.NumberPredictState; 7 | } 8 | 9 | // Whenever an action is dispatched, Redux will update each top-level application state property using 10 | // the reducer with the matching name. It's important that the names match exactly, and that the reducer 11 | // acts on the corresponding ApplicationState property type. 12 | export const reducers = { 13 | numberPredict: NumberPredict.reducer 14 | }; 15 | 16 | // This type can be used as a hint on action creators so that its 'dispatch' and 'getState' params are 17 | // correctly typed to match your store. 18 | export interface AppThunkAction { 19 | (dispatch: (action: TAction) => void, getState: () => ApplicationState): void; 20 | } 21 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace WebTensorFlowServingClient.Controllers 9 | { 10 | public class HomeController : Controller 11 | { 12 | public IActionResult Index() 13 | { 14 | return View(); 15 | } 16 | 17 | public IActionResult Error() 18 | { 19 | ViewData["RequestId"] = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 20 | return View(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Controllers/MnistDeepController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Linq; 5 | using Grpc.Core; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Configuration; 8 | using Tensorflow.Serving; 9 | using TensorFlowServingClient.Utils; 10 | using WebTensorFlowServingClient.Models; 11 | 12 | namespace WebTensorFlowServingClient.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | public class MnistDeepController : Controller 16 | { 17 | private IConfiguration _configuration; 18 | 19 | public MnistDeepController(IConfiguration Configuration) 20 | { 21 | _configuration = Configuration; 22 | } 23 | 24 | [HttpPost("[action]")] 25 | public PredictionResult PredictNumber([FromBody]PredictionRequest model) 26 | { 27 | try 28 | { 29 | //Load Bitmap from input base64 30 | Bitmap convertedImage = null; 31 | 32 | using (var str = new MemoryStream(Convert.FromBase64String(model.ImageData))) 33 | { 34 | str.Position = 0; 35 | using (var bmp = Image.FromStream(str)) 36 | { 37 | //Resize image and convert to rgb24 38 | convertedImage = ImageUtils.ResizeImage(bmp, 28, 28, 280, 280); 39 | } 40 | } 41 | 42 | //Create channel 43 | var channel = new Channel(_configuration.GetSection("TfServer")["ServerUrl"], ChannelCredentials.Insecure); 44 | var client = new PredictionService.PredictionServiceClient(channel); 45 | 46 | //Init predict request 47 | var request = new PredictRequest() 48 | { 49 | ModelSpec = new ModelSpec() { Name = "mnist", SignatureName = ModelMethodClasses.PredictImages } 50 | }; 51 | 52 | //Convert image to 28x28 8bit per pixel image data array 53 | var imageData = ImageUtils.ConvertImageStreamToDimArrays(convertedImage); 54 | 55 | var textDebug = TextUtils.RenderImageData(imageData); 56 | 57 | //add image tensor 58 | request.Inputs.Add("images", TensorBuilder.CreateTensorFromImage(imageData, 255.0f)); 59 | //add keep_prob tensor 60 | request.Inputs.Add("keep_prob", TensorBuilder.CreateTensor(1.0f)); 61 | 62 | var predictResponse = client.Predict(request); 63 | 64 | var maxValue = predictResponse.Outputs["scores"].FloatVal.Max(); 65 | var predictedValue = predictResponse.Outputs["scores"].FloatVal.IndexOf(maxValue); 66 | 67 | return new PredictionResult() 68 | { 69 | Success = true, 70 | Results = predictResponse.Outputs["scores"].FloatVal.Select(x => x).ToList(), 71 | PredictedNumber = predictedValue, 72 | DebugText = textDebug 73 | }; 74 | 75 | } 76 | catch(Exception ex) 77 | { 78 | return new PredictionResult() 79 | { 80 | Success = false, 81 | ErrorMessage = ex.ToString() 82 | }; 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Models/PredictionRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebTensorFlowServingClient.Models 7 | { 8 | public class PredictionRequest 9 | { 10 | public string ImageData { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Models/PredictionResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebTensorFlowServingClient.Models 7 | { 8 | public class PredictionResult 9 | { 10 | public List Results { get; set; } 11 | 12 | public bool Success { get; set; } 13 | 14 | public string ErrorMessage { get; set; } 15 | 16 | public int PredictedNumber { get; set; } 17 | 18 | public string DebugText { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace WebTensorFlowServingClient 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | BuildWebHost(args).Run(); 18 | } 19 | 20 | public static IWebHost BuildWebHost(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup() 23 | .Build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.SpaServices.Webpack; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace WebTensorFlowServingClient 12 | { 13 | public class Startup 14 | { 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public IConfiguration Configuration { get; } 21 | 22 | // This method gets called by the runtime. Use this method to add services to the container. 23 | public void ConfigureServices(IServiceCollection services) 24 | { 25 | services.AddMvc(); 26 | services.AddSingleton(Configuration); 27 | } 28 | 29 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 30 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 31 | { 32 | if (env.IsDevelopment()) 33 | { 34 | app.UseDeveloperExceptionPage(); 35 | app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions 36 | { 37 | HotModuleReplacement = true, 38 | ReactHotModuleReplacement = true 39 | }); 40 | } 41 | else 42 | { 43 | app.UseExceptionHandler("/Home/Error"); 44 | } 45 | 46 | app.UseStaticFiles(); 47 | 48 | app.UseMvc(routes => 49 | { 50 | routes.MapRoute( 51 | name: "default", 52 | template: "{controller=Home}/{action=Index}/{id?}"); 53 | 54 | routes.MapSpaFallbackRoute( 55 | name: "spa-fallback", 56 | defaults: new { controller = "Home", action = "Index" }); 57 | }); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
Loading...
6 | 7 | @section scripts { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 | @if (!string.IsNullOrEmpty((string)ViewData["RequestId"])) 9 | { 10 |

11 | Request ID: @ViewData["RequestId"] 12 |

13 | } 14 | 15 |

Development Mode

16 |

17 | Swapping to Development environment will display more detailed information about the error that occurred. 18 |

19 |

20 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 21 |

22 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Web Tensor Flow Serving ReactJS Client 7 | 8 | 9 | 10 | 11 | 12 | 13 | @RenderBody() 14 | 15 | 16 | @RenderSection("scripts", required: false) 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WebTensorFlowServingClient 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | @addTagHelper *, Microsoft.AspNetCore.SpaServices 4 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/WebTensorFlowServingClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net471 5 | true 6 | Latest 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | %(DistFiles.Identity) 58 | PreserveNewest 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | }, 9 | "TfServer": { 10 | "ServerUrl": "192.168.1.38:9000" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "TfServer": { 8 | "ServerUrl": "192.168.1.38:9000" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WebTensorFlowServingClient", 3 | "private": true, 4 | "version": "0.0.0", 5 | "devDependencies": { 6 | "@types/history": "4.6.0", 7 | "@types/react": "15.0.35", 8 | "@types/react-dom": "15.5.1", 9 | "@types/react-hot-loader": "3.0.3", 10 | "@types/react-redux": "4.4.45", 11 | "@types/react-router": "4.0.12", 12 | "@types/react-router-dom": "4.0.5", 13 | "@types/react-router-redux": "5.0.3", 14 | "@types/webpack": "2.2.15", 15 | "@types/webpack-env": "1.13.0", 16 | "aspnet-prerendering": "^3.0.1", 17 | "aspnet-webpack": "^2.0.1", 18 | "aspnet-webpack-react": "^3.0.0", 19 | "awesome-typescript-loader": "3.2.1", 20 | "bootstrap": "3.3.7", 21 | "css-loader": "0.28.4", 22 | "chart.js": "^1.1.1", 23 | "domain-task": "^3.0.3", 24 | "event-source-polyfill": "0.0.9", 25 | "extract-text-webpack-plugin": "2.1.2", 26 | "file-loader": "0.11.2", 27 | "history": "4.6.3", 28 | "jquery": "3.2.1", 29 | "node-noop": "1.0.0", 30 | "react": "15.6.1", 31 | "react-dom": "15.6.1", 32 | "react-hot-loader": "3.0.0-beta.7", 33 | "react-redux": "5.0.5", 34 | "react-router-dom": "4.1.1", 35 | "react-router-redux": "5.0.0-alpha.6", 36 | "react-infinite-scroller": "^1.1.2", 37 | "react-paint": "^1.0.1", 38 | "react-chartjs": "https://registry.npmjs.org/react-chartjs/-/react-chartjs-0.8.0.tgz", 39 | "redux": "3.7.1", 40 | "redux-thunk": "2.2.0", 41 | "style-loader": "0.18.2", 42 | "typescript": "2.4.1", 43 | "url-loader": "0.5.9", 44 | "webpack": "2.5.1", 45 | "webpack-hot-middleware": "2.18.2", 46 | "webpack-merge": "4.1.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "module": "es2015", 5 | "moduleResolution": "node", 6 | "target": "es5", 7 | "jsx": "react", 8 | "experimentalDecorators": true, 9 | "sourceMap": true, 10 | "skipDefaultLibCheck": true, 11 | "noImplicitAny": false, 12 | "strict": true, 13 | "lib": [ "es6", "dom" ], 14 | "types": [ "webpack-env" ] 15 | }, 16 | "exclude": [ 17 | "bin", 18 | "node_modules" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); 4 | const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin; 5 | const merge = require('webpack-merge'); 6 | 7 | module.exports = (env) => { 8 | const isDevBuild = !(env && env.prod); 9 | 10 | // Configuration in common to both client-side and server-side bundles 11 | const sharedConfig = () => ({ 12 | stats: { modules: false }, 13 | resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'] }, 14 | output: { 15 | filename: '[name].js', 16 | publicPath: 'dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix 17 | }, 18 | module: { 19 | rules: [ 20 | { test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' }, 21 | { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' } 22 | ] 23 | }, 24 | plugins: [new CheckerPlugin()] 25 | }); 26 | 27 | // Configuration for client-side bundle suitable for running in browsers 28 | const clientBundleOutputDir = './wwwroot/dist'; 29 | const clientBundleConfig = merge(sharedConfig(), { 30 | entry: { 'main-client': './ClientApp/boot-client.tsx' }, 31 | module: { 32 | rules: [ 33 | { test: /\.css$/, use: ExtractTextPlugin.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) } 34 | ] 35 | }, 36 | output: { path: path.join(__dirname, clientBundleOutputDir) }, 37 | plugins: [ 38 | new ExtractTextPlugin('site.css'), 39 | new webpack.DllReferencePlugin({ 40 | context: __dirname, 41 | manifest: require('./wwwroot/dist/vendor-manifest.json') 42 | }) 43 | ].concat(isDevBuild ? [ 44 | // Plugins that apply in development builds only 45 | new webpack.SourceMapDevToolPlugin({ 46 | filename: '[file].map', // Remove this line if you prefer inline source maps 47 | moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk 48 | }) 49 | ] : [ 50 | // Plugins that apply in production builds only 51 | new webpack.optimize.UglifyJsPlugin() 52 | ]) 53 | }); 54 | 55 | // Configuration for server-side (prerendering) bundle suitable for running in Node 56 | const serverBundleConfig = merge(sharedConfig(), { 57 | resolve: { mainFields: ['main'] }, 58 | entry: { 'main-server': './ClientApp/boot-server.tsx' }, 59 | plugins: [ 60 | new webpack.DllReferencePlugin({ 61 | context: __dirname, 62 | manifest: require('./ClientApp/dist/vendor-manifest.json'), 63 | sourceType: 'commonjs2', 64 | name: './vendor' 65 | }) 66 | ], 67 | output: { 68 | libraryTarget: 'commonjs', 69 | path: path.join(__dirname, './ClientApp/dist') 70 | }, 71 | target: 'node', 72 | devtool: 'inline-source-map' 73 | }); 74 | 75 | return [clientBundleConfig, serverBundleConfig]; 76 | }; -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/webpack.config.vendor.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); 4 | const merge = require('webpack-merge'); 5 | 6 | module.exports = (env) => { 7 | const isDevBuild = !(env && env.prod); 8 | const extractCSS = new ExtractTextPlugin('vendor.css'); 9 | 10 | const sharedConfig = { 11 | stats: { modules: false }, 12 | resolve: { extensions: [ '.js' ] }, 13 | module: { 14 | rules: [ 15 | { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' } 16 | ] 17 | }, 18 | entry: { 19 | vendor: [ 20 | 'bootstrap', 21 | 'bootstrap/dist/css/bootstrap.css', 22 | 'domain-task', 23 | 'event-source-polyfill', 24 | 'history', 25 | 'react', 26 | 'react-dom', 27 | 'react-router-dom', 28 | 'react-redux', 29 | 'redux', 30 | 'redux-thunk', 31 | 'react-router-redux', 32 | 'jquery' 33 | ], 34 | }, 35 | output: { 36 | publicPath: 'dist/', 37 | filename: '[name].js', 38 | library: '[name]_[hash]', 39 | }, 40 | plugins: [ 41 | new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) 42 | new webpack.NormalModuleReplacementPlugin(/\/iconv-loader$/, require.resolve('node-noop')), // Workaround for https://github.com/andris9/encoding/issues/16 43 | new webpack.DefinePlugin({ 44 | 'process.env.NODE_ENV': isDevBuild ? '"development"' : '"production"' 45 | }) 46 | ] 47 | }; 48 | 49 | const clientBundleConfig = merge(sharedConfig, { 50 | output: { path: path.join(__dirname, 'wwwroot', 'dist') }, 51 | module: { 52 | rules: [ 53 | { test: /\.css(\?|$)/, use: extractCSS.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) } 54 | ] 55 | }, 56 | plugins: [ 57 | extractCSS, 58 | new webpack.DllPlugin({ 59 | path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), 60 | name: '[name]_[hash]' 61 | }) 62 | ].concat(isDevBuild ? [] : [ 63 | new webpack.optimize.UglifyJsPlugin() 64 | ]) 65 | }); 66 | 67 | const serverBundleConfig = merge(sharedConfig, { 68 | target: 'node', 69 | resolve: { mainFields: ['main'] }, 70 | output: { 71 | path: path.join(__dirname, 'ClientApp', 'dist'), 72 | libraryTarget: 'commonjs2', 73 | }, 74 | module: { 75 | rules: [ { test: /\.css(\?|$)/, use: isDevBuild ? 'css-loader' : 'css-loader?minimize' } ] 76 | }, 77 | entry: { vendor: ['aspnet-prerendering', 'react-dom/server'] }, 78 | plugins: [ 79 | new webpack.DllPlugin({ 80 | path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'), 81 | name: '[name]_[hash]' 82 | }) 83 | ] 84 | }); 85 | 86 | return [clientBundleConfig, serverBundleConfig]; 87 | }; 88 | -------------------------------------------------------------------------------- /src/Clients/WebTensorFlowServingClient/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/Clients/WebTensorFlowServingClient/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/TensorFlowServingCSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BaseLib", "BaseLib", "{4480A568-1DF5-4368-A2DF-51C48F02C86D}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{ECA6F719-753D-42A0-8CD4-4EB67DBFA9D9}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C05E44F8-5883-447B-A8C3-970D8B3C2A73}" 11 | ProjectSection(SolutionItems) = preProject 12 | Clients\WebTensorFlowServiingClient\global.json = Clients\WebTensorFlowServiingClient\global.json 13 | EndProjectSection 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowServingClient", "BaseLibs\TensorFlowServingClient\TensorFlowServingClient.csproj", "{73169028-08E0-45D3-8673-241B7164163A}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTensorFlowServingClient", "Clients\ConsoleTensorFlowServingClient\ConsoleTensorFlowServingClient.csproj", "{FC26FD2A-FE41-4684-A95A-471CDEDBB870}" 18 | EndProject 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTensorFlowServingClient", "Clients\WebTensorFlowServingClient\WebTensorFlowServingClient.csproj", "{86E888D3-3156-42F9-968B-0E0ECAD41CF5}" 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Debug|Any CPU = Debug|Any CPU 24 | Release|Any CPU = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {73169028-08E0-45D3-8673-241B7164163A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {73169028-08E0-45D3-8673-241B7164163A}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {73169028-08E0-45D3-8673-241B7164163A}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {73169028-08E0-45D3-8673-241B7164163A}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {86E888D3-3156-42F9-968B-0E0ECAD41CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {86E888D3-3156-42F9-968B-0E0ECAD41CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {86E888D3-3156-42F9-968B-0E0ECAD41CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {86E888D3-3156-42F9-968B-0E0ECAD41CF5}.Release|Any CPU.Build.0 = Release|Any CPU 39 | EndGlobalSection 40 | GlobalSection(SolutionProperties) = preSolution 41 | HideSolutionNode = FALSE 42 | EndGlobalSection 43 | GlobalSection(NestedProjects) = preSolution 44 | {73169028-08E0-45D3-8673-241B7164163A} = {4480A568-1DF5-4368-A2DF-51C48F02C86D} 45 | {FC26FD2A-FE41-4684-A95A-471CDEDBB870} = {ECA6F719-753D-42A0-8CD4-4EB67DBFA9D9} 46 | {86E888D3-3156-42F9-968B-0E0ECAD41CF5} = {ECA6F719-753D-42A0-8CD4-4EB67DBFA9D9} 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {879A68B2-303A-4ABD-8A56-1214B27FDACA} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /src/content/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iminakov/TensorFlowServingCSharpClient/55ee33a3ddd5e5a303936baee35666a3d72c6d7a/src/content/preview.png --------------------------------------------------------------------------------