当前位置:网站首页>004、torchserve 调用LR二分类预测
004、torchserve 调用LR二分类预测
2022-06-13 12:05:00 【nsq1101】
前言
Pytorch框架下,LR模型二分类预测
模型代码参考Logistic 回归(实现二分类)
一、总体步骤
1、运行博客中代码,保存模型
model_script = torch.jit.script(model)
model_script.save('/Users/serve/model-archiver/LR_scr.pt')
2、转为mar格式
"""
model-archiver % torch-model-archiver -f --model-name LR_scr \--version 1.0 \
--serialized-file LR_scr.pt \
--handler /Users/hb/Desktop/sheng/quan/Coding/Test/LRHandler.py \
--export-path model-store/
"""
3、运行docker
"""
docker run --rm -it -p 8080:8080 -p 8081:8081 --name mar -v $(pwd)/model-store:/home/model-server/model-store -v $(pwd)/examples:/home/model-server/examples pytorch/torchserve:latest
"""
4、注册模型
"""
curl --location --request POST 'http://localhost:8081/models' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "LR_scr.mar",
"batch_size": 64,
"initial_workers": 1
}'
"""
5、预测
"""
curl --location --request POST 'http://localhost:8080/predictions/LR_scr' \
--header 'Content-Type: application/json' \
--data-raw '[4.1]'
"""
二、总结
1、Pytorch 框架下运行一个模型,保存为pt格式
2、数据预处理的方式,转为mar格式,在handler.py 中需要根据输入的数据,进行格式变换
3、输出结果的展示
边栏推荐
- Docker dockerfile installation mysql5.7
- LVGL库入门教程01-移植到STM32(触摸屏)
- docker Dockerfile安装mysql5.7
- [tcapulusdb knowledge base] Introduction to tcapulusdb analytical text export
- [tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (II)
- Pointnet: deep learning on point sets for 3D classification and segmentation
- 机器学习(四)—PCA(主成分分析)理论与代码详解
- UE4,UE5虚幻引擎,Command Console控制台命令,参数集
- How camunda uses script script nodes
- 14. Notes on using border decorator of WPF
猜你喜欢

秒云与趋动科技联合发布容器云平台与GPU资源池化整体解决方案

我和指针那些事——初识指针

2022年二建《公路》科目答案已出,请收好

【TcaplusDB知识库】TcaplusDB-tcaplusadmin工具介绍
![[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (I)](/img/46/e4a85bffa4b135fcd9a8923e10f69f.png)
[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (I)
![[benefits] in minutes](/img/e0/217fe575c1a31b04a9b0699ec44f25.png)
[benefits] in minutes

基于STM32F103——矩阵按键+串口打印

Pulsar 消费者

查询当前电脑cpu核心数

Pointnet: deep learning on point sets for 3D classification and segmentation
随机推荐
银行业务系统数据库设计与实现
Books + videos + learning notes + skill improvement resource library, interview must ask
Fuel scheme and product business modeling
【TcaplusDB知识库】TcaplusDB分析型文本导出介绍
Auto.js 悬浮窗居中
"Forget to learn again" shell Basics - 30. Use of SED command
【TcaplusDB知识库】TcaplusDB-tcaplusadmin工具介绍
Pulsar 消息的构成
面试突击56:聚簇索引和非聚簇索引有什么区别?
web开发者,web开发后台开发
Web development video tutorial, web development teaching
机器学习(一)—线性回归理论与代码详解
手动加密 ESP 设备量产固件并烧录的流程
数据库连接数设置多少合适?
14、wpf之Border装饰器使用小记
break algorithm---multi-interface
7.5.4:Spire Office for .NET New Version
想发自己的NFT,你要先搞清楚这6个问题
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (II)
Details of fitfi sports money making chain game system development mode