首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >用于将机器学习模型部署为生产Web服务的开源平台:Cortex

用于将机器学习模型部署为生产Web服务的开源平台:Cortex

作者头像
代码医生工作室
发布2020-01-02 11:55:40
发布2020-01-02 11:55:40
4.4K0
举报
文章被收录于专栏:相约机器人相约机器人

如果正在寻找一种将机器学习模型部署为生产Web服务的工具,那么 “ Cortex” 可能是一个不错的选择。这个开源平台是使用AWS SageMaker服务模型或通过AWS服务(例如Elastic Container Service(ECS),Elastic Kubernetes Service(EKS)和Elastic Compute Cloud(EC2)甚至是开放式)创建自己的模型部署平台的替代方案。Docker,Kubernetes和TensorFlow等源项目。

主要特征

多种框架: Cortex支持多种框架,包括TensorFlow,PyTorch,scikit-learn,XGBoost等。

自动缩放: Cortex自动为API进行负载平衡以处理生产工作负载。

基础架构: Cortex可以在CPU或GPU基础架构上运行推理。

滚动更新: Cortex部署后无需中断即可更新API。

Cortex部署示例

  • 情感分析:使用Cortex部署BERT模型进行情感分析

https://github.com/cortexlabs/cortex/tree/0.11/examples/tensorflow/sentiment-analyzer

  • 图像分类:部署一个Inception模型以使用Cortex对图像进行分类

https://github.com/cortexlabs/cortex/tree/0.11/examples/tensorflow/image-classifier

安装

前提条件(从https://www.cortex.dev/install复制)

  • Docker

https://docs.docker.com/install

  • AWS credentials

https://www.marktechpost.com/cluster-management/aws

代码语言:javascript
复制
# install the CLI on your machine
bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/0.11/get-cli.sh)"
 
# provision infrastructure on AWS and spin up a cluster
cortex cluster up

部署模型

代码语言:javascript
复制
# clone the Cortex repository
git clone -b 0.11 https://github.com/cortexlabs/cortex.git
 
# navigate to the iris classifier example
cd cortex/examples/sklearn/iris-classifier
 
# deploy the model to the cluster
cortex deploy
 
# view the status of the deployment
cortex get --watch
 
# get the API's endpoint
cortex get classifier
 
# classify a sample
curl -X POST -H "Content-Type: application/json" \
  -d '{ "sepal_length": 5.2, "sepal_width": 3.6, "petal_length": 1.4, "petal_width": 0.3 }' \
  <API endpoint>

GitHub:https://github.com/cortexlabs/cortex

网址:https://www.cortex.dev

教程:https://www.cortex.dev/iris-classifier

范例:https://github.com/cortexlabs/cortex/tree/0.11/examples

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-12-26,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档