Thanks to visit codestin.com
Credit goes to github.com

Skip to content

motebus/ai-market

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Hello AI Marketplace

Get started with AI Marketplace!

GitBook Handbook: http://203.145.214.235:4000/

Model Training Example (中文): Link

What is AI Marketplace

AI Marketplace is an online platform for training, purchasing, and using AI models on the TWCC cloud.

Customers can easily find, buy, and deploy AI models in moments.

Developers have a one-stop workspace where they can train and deploy ML models online using TWCC cloud resources, then sell their models in the Marketplace.


Sign in to AI Marketplace

To complete this tutorial, you need an iService account and have a project wallet with credits.

  • If you don't already have an iService account, go to iservice.nchc.org.tw and select Registration to create a new one.

  • Please ensure that you are part of the AI Market project and have available credits. Have a project admin add you to the AI Market project.

TWCC Documentation

Login

  • Go to ai-mkt.nchc.org.tw (ai-labs.nchc.org.tw) and click the icon on the top-right corner to sign in.

ML Training (The Developer's Guide)

Prepare MLflow

Your personal MLflow tracking server and UI will be created automatically the first time you login to AI Marketplace.

It may take some time to get ready for you to start logging model training runs, so give it a minute to finish setting up.

Go to the [MLflow] page to check its status. Once you can successfully load the MLflow UI page, you can start your ML training.

Begin your Jupyter Notebook instance

  1. Go to the [Jupyter] page on AI-Marketplace and create a new TWCC container. This is where your Jupyter Notebook will run.

  1. Name the container (preferably with your name), select the container image (either Tensorflow or Pytorch), and select the container specs. For the purposes of this tutorial, select 1 GPU, 4 cores, 90 GB memory.

  1. Click 'Create' to confirm.

  2. It will take some time for your container to be created. Once [Progress] has reached 100, you can click [Run] to open Jupyter Notebook.

  • Sample Jupyter Notebook:

  • JupyterLab is also available on this server. Simply change the last component of the url address /tree to lab.

Model training with Jupyter Notebook

  1. Upload your ML source code. Here are some examples you can use:
  1. Edit MLflow APIs in the python ML source code. MLflow API functions include:
  • save model
  • save artifact (ML training output) to [file path location]
  • register model under "registered_model_name"
  • describe input/output
  • provide input examples

Example:

With the ML training source code examples provided above, you will only need to edit the "registered_model_name" in the code line mlflow.<model_flavor>.log_model(

e.g.

# Log the sklearn model and register as version 1
mlflow.sklearn.log_model(
    sk_model=sk_learn_rfr,
    artifact_path="sklearn-model",
    registered_model_name="sk-learn-random-forest-reg-model"
)
  1. Open a terminal (or use notebook cells) to install packages. Use the following commands:

    pip install mlflow
    pip install boto3
    

    And install packages for particular model types

    pip install sklearn(for wine-quality) pip install keras (for mnist)

  2. Execute model training

    • Use the following command (in terminal):
    python train-wine-quality.py
    

Once the run finishes, you should be able to view your training results in MLflow and see your training result on the My Models list.

The list on the [My Models] page corresponds to [Registered Models] in the MLflow UI.

  1. Remember to shutdown all running files and logout, then delete your container to terminate your instance.

:::warning You will continue to be billed for a running container if you don't delete your container. :::

MLflow UI

Go to the MLflow UI page to view your training logs, artifacts, and registered models.


Here you can compare different runs with MLflow in-built functions.


Publish your model

  1. On your Model List, find the model you wish to publish and click 'Test'.

  1. Confirm publish/test in the popup window. The container for Swagger will be created.

  2. The Status of the Swagger container will be 'Initializing' until it is ready for use. Click 'Cancel' for now. (Clicking 'Finish' will delete the container).

  3. Go to the "Tested Models" Model List to find the model you want to publish. Click 'Preview', then click 'Go Model'.

  1. On the Swagger page, click 'Try it out' to change the input parameters and run an ML inference test.

  1. Once you are done, return to the "Tested Models" Model List and click 'Delete' to delete the container running Swagger.

  2. Go to the "Models" Model List and click 'Publish' to fill out details about your model and confirm publish.

  1. Once your publish request has been reviewed by admin, it will be officially published and visible on the public model list, available for other users to subscribe to and deploy.

Subscribe to and deploy models

To deploy an AI model from the AI Marketplace store....


Training ENV API Keys

Cloud Object Storage (S3) API Keys and MLflow UI

:::success These environment paramaters are now set by default. The steps in this section can be skipped. :::

When training your AI model, you need to set your artifact and training log output location.

  export MLFLOW_S3_ENDPOINT_URL=https://cos.twcc.ai
  
  export AWS_ACCESS_KEY_ID=
  
  export AWS_SECRET_ACCESS_KEY=
  
  export MLFLOW_TRACKING_URI=
  • To obtain your s3 (TWCC COS) access key and secret key, login to https://www.twcc.ai with your iService account and go to Cloud Object Storage > Private COS

  • To obtain your MLflow tracking URI, make sure you are signed in to your account on AI Market, and go to the MLflow page. Right-click on the MLflow logo to copy the link address.

CKAN API Key

The NCHC Data Market provides a free, public database of datasets that can be used for your ML training.

  • To access your NCHC Data Market API Key, go to https://scidm.nchc.org.tw/ and sign-in with your iService account. Select your profile in the top-right to view your personal account details.

Your details are in the bar on the left. Scroll to the bottom to find your API key.

If you wish to create a new CKAN API key, go Manage/Edit Settings, scroll to the end of the page and click Regenerate API Key.

TWCC API Key

  • To obtain your TWCC project API key, sign in to twcc.ai, and click on the Account & Project Information button in the top-right corner, displayed as [:bust_in_silhouette: NAME].


From the dropdown list select API Key to go your API Key Management Page. Here you can copy, delete and create API keys.


What is MLflow

(copied from databricks AWS docs)

MLflow is an open source platform for managing the end-to-end machine learning lifecycle. It has the following primary components:

  • Tracking:

Allows you to track experiments to record and compare parameters and results.

  • Models:

Allow you to manage and deploy models from a variety of ML libraries to a variety of model serving and inference platforms.

  • Projects:

Allow you to package ML code in a reusable, reproducible form to share with other data scientists or transfer to production.

  • Model Registry:

Allows you to centralize a model store for managing models’ full lifecycle stage transitions: from staging to production, with capabilities for versioning and annotating.

  • Model Serving:

Allows you to host MLflow Models as REST endpoints.

MLflow supports Java, Python, R, and REST APIs.

https://docs.databricks.com/applications/mlflow/tracking.html

  • NCHC AI Marketplace manages a fully managed and hosted version of MLflow. MLflow is the main tool for tracking ML training experiments and managing model registry, and is also used to serve models as REST endpoints running on TWCC resources.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •