Coder Social home page Coder Social logo

ideas2it / mlflow-torchserve Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mlflow/mlflow-torchserve

1.0 1.0 1.0 3.25 MB

Plugin for deploying MLflow models to TorchServe

License: Apache License 2.0

Python 40.18% Shell 0.28% HTML 1.27% CSS 0.85% TypeScript 57.42%

mlflow-torchserve's Introduction

Mlflow-TorchServe

A plugin that integrates TorchServe with MLflow pipeline. mlflow_torchserve enables mlflow users to deploy the mlflow pipeline models into TorchServe . Command line APIs of the plugin (also accessible through mlflow's python package) makes the deployment process seamless.

Prerequisites

Following are the list of packages which needs to be installed before running the TorchServe deployment plugin

  1. torch-model-archiver
  2. torchserve
  3. mlflow

Installation

Plugin package which is available in pypi and can be installed using

pip install mlflow-torchserve

##Installation from Source

Plugin package could also be installed from source using the following commands

python setup.py build
python setup.py install

###MLFlow Torchserve UI To use MLFlow torchserve UI do the following steps

  • Start API server
cd app
python app.py
  • Start UI
cd frontend
npm install
npm start

What does it do

Installing this package uses python's entrypoint mechanism to register the plugin into MLflow's plugin registry. This registry will be invoked each time you launch MLflow script or command line argument.

Create deployment

The create command line argument and create_deployment python APIs does the deployment of a model built with MLflow to TorchServe.

CLI
mlflow deployments create -t torchserve -m <model uri> --name DEPLOYMENT_NAME -C 'MODEL_FILE=<model file path>' -C 'HANDLER=<handler file path>'
Python API
from mlflow.deployments import get_deploy_client
target_uri = 'torchserve'
plugin = get_deploy_client(target_uri)
plugin.create_deployment(name=<deployment name>, model_uri=<model uri>, config={"MODEL_FILE": <model file path>, "HANDLER": <handler file path>})
UI

Create Model

Update deployment

Update API can used to modify the configuration parameters such as number of workers, version etc., of an already deployed model. TorchServe will make sure the user experience is seamless while changing the model in a live environment.

CLI
mlflow deployments update -t torchserve --name <deployment name> -C "min-worker=<number of workers>"
Python API
plugin.update_deployment(name=<deployment name>, config={'min-worker': <number of workers>})
UI

Update deployment

Delete deployment

Delete an existing deployment. Excepton will be raised if the model is not already deployed.

CLI
mlflow deployments delete -t torchserve --name <deployment name / version number>
Python API
plugin.delete_deployment(name=<deployment name / version number>)

List all deployments

Lists the names of all the models deployed on the configured TorchServe.

CLI
mlflow deployments list -t torchserve
Python API
plugin.list_deployments()
UI

List models

Get deployment details

Get API fetches the details of the deployed model. By default, Get API fetches all the versions of the deployed model.

CLI
mlflow deployments get -t torchserve --name <deployment name>
Python API
plugin.get_deployment(name=<deployment name>)
UI

Model Details

Run Prediction on deployed model

Predict API enables to run prediction on the deployed model.

For the prediction inputs, DataFrame, Tensor and Json formats are supported. The python API supports all of these three formats. When invoked via command line, one needs to pass the json file path that contains the inputs.

CLI
mlflow deployments predict -t torchserve --name <deployment name> --input-path <input file path> --output-path <output file path>

output-path is an optional parameter. Without output path parameter result will be printed in console.

Python API
plugin.predict(name=<deployment name>, df=<prediction input>)
UI

Predict Predict Results

Run Explain on deployed model

Explain API enables to get explanation on the deployed model.

CLI
mlflow deployments explain -t torchserve --name <deployment name> --input-path <input file path> --output-path <output file path>

output-path is an optional parameter. Without output path parameter result will be printed in console.

UI

Explain

Plugin help

Run the following command to get the plugin help string.

CLI
mlflow deployments help -t torchserve

mlflow-torchserve's People

Contributors

shrinath-suresh avatar chauhang avatar arvind-ideas2it avatar harupy avatar karthik-77 avatar kasirajana avatar ankan94 avatar hamidshojanazeri avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Forkers

nithishnj23

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.