Hi @<1523701205467926528:profile|AgitatedDove14> , thanks for your answer I will check if I get that working!
Hi @<1523701205467926528:profile|AgitatedDove14> , I serialized a sklearn MinMaxScaler object which I created on the training data using pickle. So when serving the model I would like to load that pickle file in the preprocess script such that I can perform the same normalization as done during training. Unless there is a better practice applying the same normalization during training and serving time.
Hi @<1523701205467926528:profile|AgitatedDove14> thanks for your answer! 🙂 I think my case is a bit different. I do not want to load a custom model but I want to load a custom object used for preprocessing. So I think the load method would not fit, as the local_file_name
parameter I get in the load function would lead to the model file. And as far as I can see there is no mechanism installed to load other objects than the model file inside the Preprocess class, right?
Hi @<1523701205467926528:profile|AgitatedDove14> , that is an interesting idea! But wouldn't it be better to load the model in the load()
function, so that the model doesn't have to be loaded again with every request? Or is there kind of internal link that when the load()
method is implemented it is expected that there was a custom model loaded and applied in the process()
function?
Hi @<1526371965655322624:profile|NuttyCamel41>
. I do that because I do not know how to get the pickle file into the docker container
What would the pickle file do?
and load the MinMaxScaler within the script, as the sklearn dependency is missing
what do you mean by that? are you getting an error when loading your model ?
And as far as I can see there is no mechanism installed to load other objects than the model file inside the Preprocess class, right?
Well actually this is possible, let's assume you have another Model that is part of the preprocessing, then you could have:
something like that should work
def preprocess(...)
if not getattr(self, "_preprocess_model):
self._preprocess_model = joblib.load(Model(model_id).get_weights())
Yes! I checked it should work (it checks if you have load(...) function on the preprocess class and if you do it will use it:
None
def load(local_file)
self._model = joblib.load(local_file_name)
self._preprocess_model = joblib.load(Model(hard_coded_model_id).get_weights())