@@ -119,6 +119,7 @@ class ServingClient {
119
119
120
120
tensorflow::string callPredict (const tensorflow::string& model_name,
121
121
const tensorflow::string& model_signature_name,
122
+ const tensorflow::string& input_name,
122
123
const tensorflow::string& file_path) {
123
124
PredictRequest predictRequest;
124
125
PredictResponse response;
@@ -140,7 +141,7 @@ class ServingClient {
140
141
return " execution failed" ;
141
142
}
142
143
143
- inputs[" input_1 " ] = proto;
144
+ inputs[input_name ] = proto;
144
145
145
146
Status status = stub_->Predict (&context, predictRequest, &response);
146
147
@@ -182,13 +183,15 @@ int main(int argc, char** argv) {
182
183
tensorflow::string image_file = " " ;
183
184
tensorflow::string model_name = " resnet" ;
184
185
tensorflow::string model_signature_name = " serving_default" ;
186
+ tensorflow::string input_name = " input_1" ;
185
187
std::vector<tensorflow::Flag> flag_list = {
186
188
tensorflow::Flag (" server_port" , &server_port,
187
189
" the IP and port of the server" ),
188
190
tensorflow::Flag (" image_file" , &image_file, " the path to the image" ),
189
191
tensorflow::Flag (" model_name" , &model_name, " name of model" ),
190
192
tensorflow::Flag (" model_signature_name" , &model_signature_name,
191
- " name of model signature" )};
193
+ " name of model signature" ),
194
+ tensorflow::Flag (" input_name" , &input_name, " name of input tensor" )};
192
195
193
196
tensorflow::string usage = tensorflow::Flags::Usage (argv[0 ], flag_list);
194
197
const bool parse_result = tensorflow::Flags::Parse (&argc, argv, flag_list);
@@ -201,7 +204,8 @@ int main(int argc, char** argv) {
201
204
grpc::CreateChannel (server_port, grpc::InsecureChannelCredentials ()));
202
205
std::cout << " calling predict using file: " << image_file << " ..."
203
206
<< std::endl;
204
- std::cout << guide.callPredict (model_name, model_signature_name, image_file)
207
+ std::cout << guide.callPredict (model_name, model_signature_name, input_name,
208
+ image_file)
205
209
<< std::endl;
206
210
return 0 ;
207
211
}
0 commit comments