TensorFlow Models
Interface
class Handler:
def __init__(self, config, tensorflow_client, metrics_client):
"""(Required) Called once before the API becomes available. Performs
setup such as downloading/initializing a vocabulary.
Args:
config (required): Dictionary passed from API configuration (if
specified).
tensorflow_client (required): TensorFlow client which is used to
make predictions. This should be saved for use in handle_async().
metrics_client (optional): The cortex metrics client, which allows
you to push custom metrics in order to build custom dashboards
in grafana.
"""
self.client = tensorflow_client
# Additional initialization may be done here
def handle_async(self, payload, request_id):
"""(Required) Called once per request. Preprocesses the request payload
(if necessary), runs inference (e.g. by calling
self.client.predict(model_input)), and postprocesses the inference
output (if necessary).
Args:
payload (optional): The request payload (see below for the possible
payload types).
request_id (optional): The request id string that identifies a workload
Returns:
Prediction or a batch of predictions.
"""
passpredict method
predict methodSpecifying models
API spec
Single model
Multiple models
Structure
On CPU/GPU
On Inferentia
Last updated