Shortcuts

modelzoo.tensorflow

modelzoo.tensorflow.deploy(model: tensorflow.python.keras.engine.training.Model, model_name: Optional[str] = None, resources_config: Optional[modelzoo.resources_config.ResourcesConfig] = None, api_key: Optional[str] = None, wait_until_healthy: bool = True) → None

Deploy a TensorFlow model to your zoo.

Note

This function will serialize a model to a temporary directory on the filesystem before uploading it to Model Zoo.

Parameters
  • model – A tf.keras.models.Model to deploy.

  • model_name – Optional string name of the model. If not provided, a random name will be generated. Model name must be unique across all of a user’s models.

  • resources_config – An optional modelzoo.ResourcesConfig that specifies the resources (e.g. memory, CPU) to use for the model. Defaults to modelzoo.ResourcesConfig().

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

  • wait_until_healthy – If True (default), this function will refrain from returning until the model has reached a HEALTHY state.

Returns

The name of the created model.

modelzoo.tensorflow.predict(model_name: str, payload: Any, *args, **kwargs) → Dict[str, Any]

Send a prediction to a TensorFlow model. Wraps the interface described in https://www.tensorflow.org/tfx/serving/api_rest#predict_api, using a columnar format.

Parameters
Returns

The output prediction

modelzoo.tensorflow.predict_image(model_name: str, filename: str, target_size=(224, 224), *args, **kwargs) → Dict[str, Any]

Send a prediction to a TensorFlow model that expects images as input. This function does not do any image preprocessing – for more control manipulating the input data, use modelzoo.predict() or modelzoo.tensorflow.predict().

Parameters
  • model_name – String name of the model.

  • filename – The path to an image that exists on the filesystem.

  • target_size – The size to convert the image into before sending it prediction. Default is (224, 224).

  • api_key – Will override the environment api key, if present.

Returns

The output prediction