tobegit3hub / simple_tensorflow_serving

Generic and easy-to-use serving service for machine learning models
https://stfs.readthedocs.io
Apache License 2.0
757 stars 195 forks source link

Postprocessing function in tensorflow models #74

Closed jnclt closed 4 years ago

jnclt commented 4 years ago

How can I export a tensorflow model with preprocessing_function.marshal? While other frameworks (e.g. xgboost) expect files with pre- & postprocessing code next to the models, tensorflow_inference_service.py expects them to be included in metagraph.collection_def. How can this be achieved? (I want to add standard scaling) Jan

tobegit3hub commented 4 years ago

Thanks @jnclt for reporting.

We should add more documents about integrating preprocessing methods. Here is the example code to export the TensorFlow SavedModel with preprocessing function in graph.

Here is the basic way to do that.

preprocess_function_string = marshal.dumps(preprocess.func_code)
tf.add_to_collection("preprocess_function", preprocess_function_string)

postprocess_function_string = marshal.dumps(postprocess.func_code)
tf.add_to_collection("postprocess_function", postprocess_function_string)
jnclt commented 4 years ago

That helped, got it working. Thanks a lot!