nt of CPU and memory to be allocated to the model.serviceAccount The name of the Service Account applied to the deployment.

For more information and a full list of configurable attributes of the Seldon Core Model Deployer, check out the SDK Docs .

Custom Code Deployment

ZenML enables you to deploy your pre- and post-processing code into the deployment environment together with the model by defining a custom predict function that will be wrapped in a Docker container and executed on the model deployment server, e.g.:

def custom_predict(

model: Any,

request: Array_Like,

) -> Array_Like:

"""Custom Prediction function.

The custom predict function is the core of the custom deployment, the

function is called by the custom deployment class defined for the serving

tool. The current implementation requires the function to get the model

loaded in the memory and a request with the data to predict.

Args:

model: The model to use for prediction.

request: The prediction response of the model is an array-like format.

Returns:

The prediction in an array-like format.

"""

inputs = []

for instance in request:

input = np.array(instance)

if not isinstance(input, np.ndarray):

raise Exception("The request must be a NumPy array")

processed_input = pre_process(input)

prediction = model.predict(processed_input)

postprocessed_prediction = post_process(prediction)

inputs.append(postprocessed_prediction)

return inputs

def pre_process(input: np.ndarray) -> np.ndarray:

"""Pre process the data to be used for prediction."""

input = input / 255.0

return input[None, :, :]

def post_process(prediction: np.ndarray) -> str:

"""Pre process the data"""

classes = [str(i) for i in range(10)]

prediction = tf.nn.softmax(prediction, axis=-1)

maxindex = np.argmax(prediction.numpy())

return classes[maxindex]