3. Make your ModelVersion Deployable

3. Make your ModelVersion Deployable

On this page, we will show you how to deploy a ModelVersion on the Picsellia Serving Engine. This is particularly relevant if the model has been imported to Picsellia through its Model files, as detailed on the previous page.

Please note that the guidance and policies to follow when deploying aModelVersion depend on the Framework used by the ModelVersion.

❓

Can I deploy the ModelVersion on my own infrastructure, but leverage Picsellia monitoring?

If you do not want to use Picsellia Serving Engine for your ModelVersion and just enable its monitoring, follow the documentation here.

1. Make a TensorFlow ModelVersion Deployable

  1. Train your model with Tensorflow.
  2. Export your model to a folder (here is the Tensorflow documentation on model export). Your folder should resemble the one shown below:
  1. Zip this folder (here, the folder is named saved_model). Note that the model folder must be zipped before being uploaded it to Picsellia.
  2. Upload the Model files in the ModelVersion with the script below:
from picsellia import Client
from picsellia.types.enums import InferenceType

client = Client(api_token=api_token, organization_name=organization_name)

model_name = "efficientdet_d0_coco17_tpu-32"

my_model = client.get_model(
  name=model_name,
)

my_model_version = my_model.get_version(
  name='v1',
)

my_model_version.store("model-latest", "path/to/saved_model.zip")

That's it! Your TensorFlow ModelVersion is now ready to be deployed, you should see a Deploy button appearing on your _ModelVersion overview _page:

2. Make a PyTorch ModelVersion Deployable

Deploying a PyTorch model with Picsellia requires an ONNX ModelVersion.

  1. (Optional) If you don't have one, create an ONNX ModelVersion:
from picsellia import Client
from picsellia.types.enums import InferenceType

client = Client(api_token=api_token, organization_name=organization_name)

model_name = "pytorch-model"

my_model = client.create_model(
  name=model_name,
)

## Define the model version Inference type
inference_type = InferenceType.OBJECT_DETECTION

## Define the model version LabelMap
labelmap = {
  '0': 'avocado',
  '1': 'not avocado'
}

##Define the model version Framework
framework = Framework.ONNX

my_model_version = my_model.create_version(
  name='v1',
  labels=labelmap,
  type=inference_type,
  framework=framework
)
  1. Train your model with PyTorch.
  2. Export your model PyTorch model into an ONNX model to a folder (here is the PyTorch documentation on ONNX model export).
  3. Upload the Model files in the ModelVersion with the script below:
from picsellia import Client
from picsellia.types.enums import InferenceType

client = Client(api_token=api_token, organization_name=organization_name)

model_name = "pytorch-model"

my_model = client.get_model(
  name=model_name,
)

my_model_version = my_model.get_version(
  name='v1',
)

my_model_version.store("model-latest", "path/to/model.onnx")

That's it! Your PyTorch ModelVersion is now ready to be deployed through ONNX, you should see a Deploy button appearing on your ModelVersion overview page:

3. Make an ONNX ModelVersion Deployable

  1. Train your model with ONNX.
  2. Export your model to a folder.
  3. Upload the Model files in the ModelVersion with the script below:
from picsellia import Client
from picsellia.types.enums import InferenceType

client = Client(api_token=api_token, organization_name=organization_name)

model_name = "efficientdet_d0_coco17_tpu-32"

my_model = client.get_model(
  name=model_name,
)

my_model_version = my_model.get_version(
  name='v1',
)

my_model_version.store("model-latest", "path/to/model.onnx")

That's it! Your ONNX ModelVersion is now ready to be deployed, you should see a Deploy button appearing on your ModelVersion overview page:

4. Monitoring

Your model is now fully uploaded to Picsellia as a ModelVersion. It has been deployed on the Picsellia Serving Engine and is ready to make inferences, as described in this recipe:

Once predictions have been made, you can use the Picsellia Monitoring Dashboard to monitor the ModelVersion's performance.

If the ModelVersion performance starts to decay due to data drift, the best way to anticipate and fix this common issue is to retrain the ModelVersion with a DatasetVersion enriched with Prediction from the production ground, reviewed by a human. The implementation of this process is well detailed in our Quick Start Guide.