I am trying to export my TensorFlow image-classifying model such that it accepts base64 strings as input.
I have tried to implement the solution that is provided on this question, however I am getting the following error:
"InvalidArgumentError: Shape must be rank 0 but is rank 1 for 'DecodeJpeg_1' (op: 'DecodeJpeg') with input shapes: [?]."
The error appears as a result of the code on line 4.
export_dir = '~/models/1'
builder = saved_model_builder.SavedModelBuilder(export_dir)
image = tf.placeholder(dtype=tf.string, shape=[None], name='source')
decoded = tf.image.decode_jpeg(image)
scores = build_model(decoded)
signature = predict_signature_def(inputs={'image_bytes': image},
outputs={'output': scores})
with K.get_session() as sess:
builder.add_meta_graph_and_variables(sess=sess,
tags=[tag_constants.SERVING],
signature_def_map={'predict': signature})
builder.save()
sess.close()
Also,
I see that on line 5, "scores" provides the output of the model based on the build_model
function. However, I can't find in the original question's answers or in the TensorFlow documentation where this function comes from.