Traditional way of saving machine learning models in file system having some challenges, especially moving to different environment. Machine learning binary models saving in git also not advisable. It's not a best practice either.
pip install mongodb-ml-models
[mongodb.model]
host=0.0.0.0 # Replace with the host IP if the mongo server was on different machine
port=6273
model_type=type # A collection name for your model
[class_name] # Replace with your class name, this name is used for accessing the models in the code
db_name=model_db # Replace with the db name you want
version=V1 # Version number here, update with every new model else replace the existing model in the db
from handle_mongodb_models import ManageModel
Then you can upload your binary model by
ManageModel.upload_model(binary_model, model_class)
binary_model = ManageModel.get_model(model_class)
This will load the model if it was not available in the local machine
Comments