Suppose you would like to upload a model artifact for a TensorFlow (HDF5) model.
Following is an example of what the package.py script may look like.
import picklefrom pathlib import Pathimport pandas as pdimport tensorflow as tfPACKAGE_PATH =Path(__file__).parentOUTPUT_COLUMN = ['probability_over_50k']classMyModel:def__init__(self):# Load the model self.model = tf.keras.models.load_model(PACKAGE_PATH /'model.h5')defpredict(self,input_df):# Store predictions in a DataFramereturn pd.DataFrame(self.model.predict(input_df), columns=OUTPUT_COLUMN)defget_model():returnMyModel()