MLflow is an open source platform to manage the ML lifecycle, including experimentation, reproducibility, deployment, and a central model registry.
MLflow lets you train, reuse, and deploy models with any library and package them into reproducible steps that other data scientists can use as a “black box,” without even having to know which library you are using.
<aside> 💡 We use mlflow autolog method to enables automatic logging from TensorFlow to MLflow.
</aside>
Framework:
Add sample MLFlow autolog code to log our parameters, metrics and models automatically.
import mlflow
mlflow.set_experiment("<Experiment-Name>")
mlflow.<framework>.autolog(log_models=True)
# framework = tensorflow/keras/pytorch/Scikit-learn/xgboost/lightgbm/...
# framework list: <https://mlflow.org/docs/latest/tracking.html#automatic-logging>
After we finish running the code, we will get the record in MLFlow platform.
We have a training model code in kaggle:
Notebook images:
TensorFlow 2.4.1 (Python 3.7)
[infuseai/docker-stacks:tensorflow-notebook-v2-4-1-dbdcead1]
Step 1: Download data and upload to jupyterlab.
Step 2: Unzip dataset.
Step 3: Download code, upload to jupyterlab and modify data path.
Step 4: We only need to create a cell at the begin of notebook and add the following code into cell.
# Code Meaning:
# Import MLFlow package and set the new experiment call "mask-detection".
# Then, use MLFlow "autolog" method to record the Parameters, Metrics and Artifacts.
# When we run this code, we do not get any log or information.
# However, after we finish training model, you can see the job in MLFLow platform.
import mlflow
mlflow.set_experiment("mask-detection")
mlflow.tensorflow.autolog(log_models=True)
Step 5: We can train the model and get results from MLFlow to register the model.