How to build RESTful predict request when savedModel use tf.Example as input?
I have a savedModel exported using estimator.export_saved_model
and indicate how to parse the input using a function like below:
def serving_example_input_receiver_fn():
serialized_tf_example = tf.placeholder(dtype=tf.string)
receiver_tensors = {'examples': serialized_tf_example}
features = tf.parse_example(serialized_tf_example, FEATURE_SCHEMA)
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
I serve this model using tensorflow_model_server
with docker. I can get right predict result through gRpc request, but when I use RESTful API, I can't assemble the right request. I got error below every time:
{ "error": "Could not parse example input, value:
\'b\'\n\xb5\x02\n\x14\n\x0bisorderdish\x12\x05\x1a\x03\n\x01\x00\n\x12\n\tisnewuser\x12\x05\x1a\x03\n\x01\x00\n\x13\n\ncitylevel1\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x08isiphone\x12\x05\x1a\x03\n\x01\x01\n\x17\n\x0eistakeawayshop\x12\x05\x1a\x03\n\x01\x00\n\x0f\n\x06cityid\x12\x05\x1a\x03\n\x01\x01\n\x0f\n\x06iswifi\x12\x05\x1a\x03\n\x01\x00\n\x14\n\x0bgoodreviews\x12\x05\x1a\x03\n\x01\x06\n\x13\n\nbadreviews\x12\x05\x1a\x03\n\x01\x03\n\x12\n\tistopshop\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x06shopid\x12\x07\x1a\x05\n\x03\xb3\xfe3\n\x13\n\nisdealshop\x12\x05\x1a\x03\n\x01\x00\n\x14\n\nshopregion\x12\x06\x1a\x04\n\x02\xca\x06\n\x11\n\x08shopcat0\x12\x05\x1a\x03\n\x01\n\n\x16\n\risbookingshop\x12\x05\x1a\x03\n\x01\x00\'\'nt
[[{{node ParseExample/ParseExample}} = ParseExample[Ndense=0,
Nsparse=15, Tdense=, _output_shapes=[[?,2], [?,2], [?,2], [?,2],
[?,2], ..., [2], [2], [2], [2], [2]], dense_shapes=,
sparse_types=[DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64, ...,
DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64],
_device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_example_tensor_0_0,
ParseExample/ParseExample/names,
ParseExample/ParseExample/sparse_keys_0,
ParseExample/ParseExample/sparse_keys_1,
ParseExample/ParseExample/sparse_keys_2,
ParseExample/ParseExample/sparse_keys_3,
ParseExample/ParseExample/sparse_keys_4,
ParseExample/ParseExample/sparse_keys_5,
ParseExample/ParseExample/sparse_keys_6,
ParseExample/ParseExample/sparse_keys_7,
ParseExample/ParseExample/sparse_keys_8,
ParseExample/ParseExample/sparse_keys_9,
ParseExample/ParseExample/sparse_keys_10,
ParseExample/ParseExample/sparse_keys_11,
ParseExample/ParseExample/sparse_keys_12,
ParseExample/ParseExample/sparse_keys_13,
ParseExample/ParseExample/sparse_keys_14)]]" }'
The Rest API predict request format is like below:
{
"signature_name": "predict_method_signature",
"instances": [
{
"examples": str(my_tf_example1.SerializeToString()) //python code to produce the serialized string
},
{
"examples": str(my_tf_example2.SerializeToString())
}
]
}
I cant find useful document or examples in this case. Please help.
tensorflow tensorflow-serving
add a comment |
I have a savedModel exported using estimator.export_saved_model
and indicate how to parse the input using a function like below:
def serving_example_input_receiver_fn():
serialized_tf_example = tf.placeholder(dtype=tf.string)
receiver_tensors = {'examples': serialized_tf_example}
features = tf.parse_example(serialized_tf_example, FEATURE_SCHEMA)
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
I serve this model using tensorflow_model_server
with docker. I can get right predict result through gRpc request, but when I use RESTful API, I can't assemble the right request. I got error below every time:
{ "error": "Could not parse example input, value:
\'b\'\n\xb5\x02\n\x14\n\x0bisorderdish\x12\x05\x1a\x03\n\x01\x00\n\x12\n\tisnewuser\x12\x05\x1a\x03\n\x01\x00\n\x13\n\ncitylevel1\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x08isiphone\x12\x05\x1a\x03\n\x01\x01\n\x17\n\x0eistakeawayshop\x12\x05\x1a\x03\n\x01\x00\n\x0f\n\x06cityid\x12\x05\x1a\x03\n\x01\x01\n\x0f\n\x06iswifi\x12\x05\x1a\x03\n\x01\x00\n\x14\n\x0bgoodreviews\x12\x05\x1a\x03\n\x01\x06\n\x13\n\nbadreviews\x12\x05\x1a\x03\n\x01\x03\n\x12\n\tistopshop\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x06shopid\x12\x07\x1a\x05\n\x03\xb3\xfe3\n\x13\n\nisdealshop\x12\x05\x1a\x03\n\x01\x00\n\x14\n\nshopregion\x12\x06\x1a\x04\n\x02\xca\x06\n\x11\n\x08shopcat0\x12\x05\x1a\x03\n\x01\n\n\x16\n\risbookingshop\x12\x05\x1a\x03\n\x01\x00\'\'nt
[[{{node ParseExample/ParseExample}} = ParseExample[Ndense=0,
Nsparse=15, Tdense=, _output_shapes=[[?,2], [?,2], [?,2], [?,2],
[?,2], ..., [2], [2], [2], [2], [2]], dense_shapes=,
sparse_types=[DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64, ...,
DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64],
_device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_example_tensor_0_0,
ParseExample/ParseExample/names,
ParseExample/ParseExample/sparse_keys_0,
ParseExample/ParseExample/sparse_keys_1,
ParseExample/ParseExample/sparse_keys_2,
ParseExample/ParseExample/sparse_keys_3,
ParseExample/ParseExample/sparse_keys_4,
ParseExample/ParseExample/sparse_keys_5,
ParseExample/ParseExample/sparse_keys_6,
ParseExample/ParseExample/sparse_keys_7,
ParseExample/ParseExample/sparse_keys_8,
ParseExample/ParseExample/sparse_keys_9,
ParseExample/ParseExample/sparse_keys_10,
ParseExample/ParseExample/sparse_keys_11,
ParseExample/ParseExample/sparse_keys_12,
ParseExample/ParseExample/sparse_keys_13,
ParseExample/ParseExample/sparse_keys_14)]]" }'
The Rest API predict request format is like below:
{
"signature_name": "predict_method_signature",
"instances": [
{
"examples": str(my_tf_example1.SerializeToString()) //python code to produce the serialized string
},
{
"examples": str(my_tf_example2.SerializeToString())
}
]
}
I cant find useful document or examples in this case. Please help.
tensorflow tensorflow-serving
add a comment |
I have a savedModel exported using estimator.export_saved_model
and indicate how to parse the input using a function like below:
def serving_example_input_receiver_fn():
serialized_tf_example = tf.placeholder(dtype=tf.string)
receiver_tensors = {'examples': serialized_tf_example}
features = tf.parse_example(serialized_tf_example, FEATURE_SCHEMA)
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
I serve this model using tensorflow_model_server
with docker. I can get right predict result through gRpc request, but when I use RESTful API, I can't assemble the right request. I got error below every time:
{ "error": "Could not parse example input, value:
\'b\'\n\xb5\x02\n\x14\n\x0bisorderdish\x12\x05\x1a\x03\n\x01\x00\n\x12\n\tisnewuser\x12\x05\x1a\x03\n\x01\x00\n\x13\n\ncitylevel1\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x08isiphone\x12\x05\x1a\x03\n\x01\x01\n\x17\n\x0eistakeawayshop\x12\x05\x1a\x03\n\x01\x00\n\x0f\n\x06cityid\x12\x05\x1a\x03\n\x01\x01\n\x0f\n\x06iswifi\x12\x05\x1a\x03\n\x01\x00\n\x14\n\x0bgoodreviews\x12\x05\x1a\x03\n\x01\x06\n\x13\n\nbadreviews\x12\x05\x1a\x03\n\x01\x03\n\x12\n\tistopshop\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x06shopid\x12\x07\x1a\x05\n\x03\xb3\xfe3\n\x13\n\nisdealshop\x12\x05\x1a\x03\n\x01\x00\n\x14\n\nshopregion\x12\x06\x1a\x04\n\x02\xca\x06\n\x11\n\x08shopcat0\x12\x05\x1a\x03\n\x01\n\n\x16\n\risbookingshop\x12\x05\x1a\x03\n\x01\x00\'\'nt
[[{{node ParseExample/ParseExample}} = ParseExample[Ndense=0,
Nsparse=15, Tdense=, _output_shapes=[[?,2], [?,2], [?,2], [?,2],
[?,2], ..., [2], [2], [2], [2], [2]], dense_shapes=,
sparse_types=[DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64, ...,
DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64],
_device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_example_tensor_0_0,
ParseExample/ParseExample/names,
ParseExample/ParseExample/sparse_keys_0,
ParseExample/ParseExample/sparse_keys_1,
ParseExample/ParseExample/sparse_keys_2,
ParseExample/ParseExample/sparse_keys_3,
ParseExample/ParseExample/sparse_keys_4,
ParseExample/ParseExample/sparse_keys_5,
ParseExample/ParseExample/sparse_keys_6,
ParseExample/ParseExample/sparse_keys_7,
ParseExample/ParseExample/sparse_keys_8,
ParseExample/ParseExample/sparse_keys_9,
ParseExample/ParseExample/sparse_keys_10,
ParseExample/ParseExample/sparse_keys_11,
ParseExample/ParseExample/sparse_keys_12,
ParseExample/ParseExample/sparse_keys_13,
ParseExample/ParseExample/sparse_keys_14)]]" }'
The Rest API predict request format is like below:
{
"signature_name": "predict_method_signature",
"instances": [
{
"examples": str(my_tf_example1.SerializeToString()) //python code to produce the serialized string
},
{
"examples": str(my_tf_example2.SerializeToString())
}
]
}
I cant find useful document or examples in this case. Please help.
tensorflow tensorflow-serving
I have a savedModel exported using estimator.export_saved_model
and indicate how to parse the input using a function like below:
def serving_example_input_receiver_fn():
serialized_tf_example = tf.placeholder(dtype=tf.string)
receiver_tensors = {'examples': serialized_tf_example}
features = tf.parse_example(serialized_tf_example, FEATURE_SCHEMA)
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
I serve this model using tensorflow_model_server
with docker. I can get right predict result through gRpc request, but when I use RESTful API, I can't assemble the right request. I got error below every time:
{ "error": "Could not parse example input, value:
\'b\'\n\xb5\x02\n\x14\n\x0bisorderdish\x12\x05\x1a\x03\n\x01\x00\n\x12\n\tisnewuser\x12\x05\x1a\x03\n\x01\x00\n\x13\n\ncitylevel1\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x08isiphone\x12\x05\x1a\x03\n\x01\x01\n\x17\n\x0eistakeawayshop\x12\x05\x1a\x03\n\x01\x00\n\x0f\n\x06cityid\x12\x05\x1a\x03\n\x01\x01\n\x0f\n\x06iswifi\x12\x05\x1a\x03\n\x01\x00\n\x14\n\x0bgoodreviews\x12\x05\x1a\x03\n\x01\x06\n\x13\n\nbadreviews\x12\x05\x1a\x03\n\x01\x03\n\x12\n\tistopshop\x12\x05\x1a\x03\n\x01\x01\n\x11\n\x06shopid\x12\x07\x1a\x05\n\x03\xb3\xfe3\n\x13\n\nisdealshop\x12\x05\x1a\x03\n\x01\x00\n\x14\n\nshopregion\x12\x06\x1a\x04\n\x02\xca\x06\n\x11\n\x08shopcat0\x12\x05\x1a\x03\n\x01\n\n\x16\n\risbookingshop\x12\x05\x1a\x03\n\x01\x00\'\'nt
[[{{node ParseExample/ParseExample}} = ParseExample[Ndense=0,
Nsparse=15, Tdense=, _output_shapes=[[?,2], [?,2], [?,2], [?,2],
[?,2], ..., [2], [2], [2], [2], [2]], dense_shapes=,
sparse_types=[DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64, ...,
DT_INT64, DT_INT64, DT_INT64, DT_INT64, DT_INT64],
_device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_example_tensor_0_0,
ParseExample/ParseExample/names,
ParseExample/ParseExample/sparse_keys_0,
ParseExample/ParseExample/sparse_keys_1,
ParseExample/ParseExample/sparse_keys_2,
ParseExample/ParseExample/sparse_keys_3,
ParseExample/ParseExample/sparse_keys_4,
ParseExample/ParseExample/sparse_keys_5,
ParseExample/ParseExample/sparse_keys_6,
ParseExample/ParseExample/sparse_keys_7,
ParseExample/ParseExample/sparse_keys_8,
ParseExample/ParseExample/sparse_keys_9,
ParseExample/ParseExample/sparse_keys_10,
ParseExample/ParseExample/sparse_keys_11,
ParseExample/ParseExample/sparse_keys_12,
ParseExample/ParseExample/sparse_keys_13,
ParseExample/ParseExample/sparse_keys_14)]]" }'
The Rest API predict request format is like below:
{
"signature_name": "predict_method_signature",
"instances": [
{
"examples": str(my_tf_example1.SerializeToString()) //python code to produce the serialized string
},
{
"examples": str(my_tf_example2.SerializeToString())
}
]
}
I cant find useful document or examples in this case. Please help.
tensorflow tensorflow-serving
tensorflow tensorflow-serving
asked Dec 28 '18 at 11:04
hakunamihakunami
1,09941841
1,09941841
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53957512%2fhow-to-build-restful-predict-request-when-savedmodel-use-tf-example-as-input%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53957512%2fhow-to-build-restful-predict-request-when-savedmodel-use-tf-example-as-input%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown