Custom Metadata in SignatureDef
ndeepesh opened this issue · comments
Feature Request
If this is a feature request, please fill out the following form in full:
Describe the problem the feature is intended to solve
Is there a way to specify custom metadata to SignatureDef after training. We dont need this metadata for actual TF Serving but need it to create requests to TF Serving.
Also will TF Serving fail if we add this custom metadata to SignatureDef?
Describe the solution
Ideally if there is a way to add custom metadata that will let us serve our models with all info contained at one place
Describe alternatives you've considered
No alternatives yet
Additional context
No additional context
tf.keras.Model automatically specify serving signatures, but you can explicitly declare a serving signature for your custom modules. If you're looking for a way of enforcing an input signature for a specific function, see the input_signature argument to tf.function.
To export multiple signatures, pass a dictionary of signature keys to ConcreteFunctions. Each signature key corresponds to one ConcreteFunction. For example, please refer Specifying signatures during export.
For custom metadata, please use the signature constants defined here that will be supported in TensorFlow Serving. In addition, SavedModel provides a util to help build a signature-def. Please refer Sample structures for examples of the specific SignatureDefs that TensorFlow Serving supports for each API.
Hope this helps. Thank you!
Hi @singhniraj08
Thanks for your response. Can you please point me to an example that adds any custom metadata to SavedModel? Ideally I was looking for something like below
After Training
signature_def= SignatureDef(..)
signature_def["custom_key"] = "custom_value"
In Serving Pipeline but before sending inference request to TF Serving
value = signature_def["custom_key"]
--> send predict request to TF Serving
You can follow this tutorial to serve model with custom signatures.
Unfortunately adding logic to allow serving metadata other than signaturedefs is not on the roadmap right now. To support custom metadata in Serving, there is a similar feature request #1248 in works . I would suggest you to +1 that issue and follow the issue for updates.
Thank you!
Thanks for your help @singhniraj08