Uploading a trained model

This guide describes how to upload a trained machine learning (ML) model on AI Hub.

About uploading and sharing assets on AI Hub

You must sign in with a user account that is associated with a Cloud Identity or G Suite domain to upload and share assets on AI Hub. Assets that you upload to AI Hub are not shared by default. You can share these assets with individuals, groups, or your entire organization.

You are responsible for the assets that you upload on AI Hub. Follow your organization's guidelines and policies when uploading and sharing assets on AI Hub. Do not store credentials on AI Hub.

Prepare your trained model for publication

Before you can upload a model on AI Hub, you must export your trained model for predictions and compress it as a zip file.

Follow these steps to prepare your model for publication:

TensorFlow

  1. Follow the AI Platform guide to deploying models to learn how to prepare and export your model for predictions.
  2. Compress the exported version of your model files as a zip file.

scikit-learn

  1. Export your model with the pickle or joblib library. Your saved model file must be named either model.pkl or model.joblib, depending on which library you used.

    Library used to export model Correct model name
    pickle model.pkl
    joblib model.joblib
  2. Compress the exported version of your model files as a zip file.

XGBoost

  1. Export your model with the xgboost.Booster, pickle, or joblib library. Your saved model file must be named model.pkl, model.joblib, or model.bst, depending on which library you used.

    Library used to export model Correct model name
    xgboost.Booster model.bst
    pickle model.pkl
    joblib model.joblib
  2. Compress the exported version of your model files as a zip file.

Upload a trained model on AI Hub

Follow these steps to upload your trained model on AI Hub:

  1. Go to AI Hub. Click Sign in in the upper-right corner of the window and follow the prompts to sign in with an account that is associated with your organization.
  2. Click Upload and select Trained Model from the list. A form opens, prompting you for information about the model that you want to upload.
  3. Supply the following information in the Metadata section:

    • Model name: A short description that helps you identify your model on AI Hub.
    • Input data type: Select the types of data that your model processes. This metadata is useful for people who search AI Hub for models that work for their type of data.
    • ML Workflow: (Optional.) Select the steps in the ML workflow that characterize your model. This metadata is useful for people who search AI Hub for assets that implement a specific ML workflow step. For example, a model that converts a string to word vectors could be used for data preparation or predictions, in that case select the Data preparation and Deploying workflow steps.
    • Technique: (Optional.) Select the ML methodologies that were used to implement this model. This metadata is useful for people who search AI Hub for assets that implement a specific ML technique.
    • Use case: (Optional.) Select the scenarios that characterize your model. This metadata is useful for people who search AI Hub for assets that fulfill a specific use case.
    • Labels: (Optional.) Enter key terms that characterize your model. This metadata is useful for people who search AI Hub for assets with a specific label.
    • Summary: A description of the functionality that your model implements.
  4. Click Next.

  5. Supply the following information in the Version section:

    • Version: This field offers a way for you to name and manage the versions of your model. A good first version number is: 1.
    • Model .zip file: Click Upload and follow the prompts to upload the model.zip file which you created in an earlier step of this guide.
    • Python version: Select the version of Python that was used to create this model.
    • ML Framework: Select the ML framework that was used to create this model.
    • ML Framework version: Select the version of the ML framework that was used to create this model.
  6. Click Next.

  7. In the Documentation section, follow the instructions in the documentation template to describe your model. You can use Markdown to format your documentation.

  8. Click the Preview Changes tab to see the documentation rendered as HTML.

  9. Click Next.

  10. Check the information in the Review and finish section. If you need to change something, click one of the other sections and update the information, then return to the Review and finish section.

  11. Click Publish to upload the trained model to your private assets on AI Hub.

Change a model's metadata

Follow this process to update a trained model's metadata, or to add a new version of a trained model:

  1. Go to AI Hub.
  2. Click My assets. A page opens, listing the assets that you have uploaded.
  3. Find the model that you would like to update, then click the model's name. A form opens, prompting you for information about the model.
  4. Update the information in the Metadata section:

    • Model name: A short description that helps you identify your model on AI Hub.
    • Input data type: Select the types of data that your model processes. This metadata is useful for people who search AI Hub for assets that work for their type of data.
    • ML Workflow: (Optional.) Select the steps in the ML workflow that characterize your model. This metadata is useful for people who search AI Hub for assets that implement a specific ML workflow step. For example, a model that converts a string to word vectors could be used for data preparation or predictions, in that case select the Data preparation and Deploying workflow steps.
    • Technique: (Optional.) Select the ML methodologies that were used to implement this model. This metadata is useful for people who search AI Hub for assets that implement a specific ML technique.
    • Use case: (Optional.) Select the scenarios that characterize your model. This metadata is useful for people who search AI Hub for assets that fulfill a specific use case.
    • Labels: (Optional.) Enter key terms that characterize your model. Use commas to separate terms. This metadata is useful for people who search AI Hub for assets with a specific label.
    • Summary: A description of the functionality that your model implements.
  5. Click Next. The Version section lists the published versions of this model.

  6. To add a new version of this model, click Add New Version and supply the following information:

    • Version: This field offers a way for you to name and manage the versions of your model. This field is preset to your model's next version number.
    • Model .zip file: Click Upload and follow the prompts to upload your model's new model.zip file, which you created in an earlier step of this guide.
    • Python version: Select the version of Python that was used to create this model.
    • ML Framework: Select the ML framework that was used to create this model.
    • ML Framework version: Select the version of the ML framework that was used to create this model.
  7. Click Next.

  8. Review and update the Documentation for your model. You can use Markdown to format your documentation.

  9. Click the Preview Changes tab to see the documentation rendered as HTML.

  10. Click Next.

  11. Check the information in the Review and finish section. If you need to change something, click one of the other sections and update the information, then return to the Review and finish section.

  12. Click Publish to save your changes.

What's next