当前位置:网站首页>002. Torchserve calls the official library model
002. Torchserve calls the official library model
2022-06-13 12:11:00 【nsq1101】
Preface
stay PyTorch Generate model in environment .pt Format , Put it in the specified directory , Re convert to .mar Format , Prediction by model
1、 Locally generated .pt Model
#scripted mode
from torchvision import models
import torch
model = models.resnet18(pretrained=True)
sm = torch.jit.script(model)
sm.save("/Users/hb/serve/model-archiver/resnet-18.pt")
2、 Convert to .mar Format
# model-archiver
pip install .
torch-model-archiver -f --model-name resnet-18 \
--version 1.0 \
--serialized-file resnet-18.pt \
--handler image_classifier \
--export-path model-store/
An error may be reported , hold \ Delete all of them and they will run successfully
torch-model-archiver -f --model-name resnet-18 --version 1.0 --serialized-file resnet-18.pt --handler image_classifier --export-path model-store/
3、 docker start-up torchserve
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、 Registration model
curl --location --request POST 'http://localhost:8081/models' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "resnet-18.mar",
"batch_size": 64,
"initial_workers": 1
}'
The code may report an error , Wrong format
https://code.bizseer.com/puruokun/torch-serving/-/tree/master/
Code modified from here , It can be used ; Copy to other places , Copying and using again will cause problems .
5、 forecast
Download the pictures
curl -O https://s3.amazonaws.com/model-server/inputs/kitten.jpgforecast
curl 'http://127.0.0.1:8080/predictions/resnet-18' -T kitten.jpg
6、 Delete unregistered and useless models ( Optional )
curl --location --request DELETE ‘http://localhost:8081/models/shape_cnn’ \
边栏推荐
- Kubernetes deploying ActiveMQ
- 我和指针那些事——初识指针
- 【管理知多少】“风险登记册”本身的风险
- 杜邦分析法剖析:居然之家新零售集团股份有限公司企业财务分析
- 7、场感知分解机FFM介绍
- 2022年二建《市政》科目答案已出,请收好
- [tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (II)
- 7.5.4:Spire Office for .NET New Version
- Pointnet: deep learning on point sets for 3D classification and segmentation
- Problems encountered in using the Pluto table of the flutter plug-in
猜你喜欢
UNIX环境高级编程(APUE,第三版)---环境搭建
UE4, ue5 phantom engine, command console command, parameter set
Pulsar producer
Projet de développement web, développement d'une page Web
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(二)
2022年二建《公路》科目答案已出,请收好
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(一)
【福利】,分分钟搞定
Lucene from introduction to practice
M1 体验win11
随机推荐
【Scala】Scala常用代码库—六大特征与引用
OpenCV学习笔记(二):读取mnist数据集
基於STM32F103+AS608指紋模塊+4X4矩陣按鍵+SIM900A發短信——智能門禁卡系統
redis实操-查询数据库信息存入redis对比两次差异
5 LockSupport与线程中断
web开发者,web开发后台开发
Machine learning (III) - LDA (linear discriminant analysis) theory and code explanation
003、torchserve 调用LSTM模型预测
面试突击56:聚簇索引和非聚簇索引有什么区别?
Details of fitfi sports money making chain game system development mode
Interview questions MySQL database
LVGL库入门教程01-移植到STM32(触摸屏)
Based on STM32F103 - as608 fingerprint module + serial port printing
SMS sending + serial port printing based on stm32f103-sim900a
IDEA 使用
2022.2:EyeshotPro EyeshotUltimate EyeshotFem
Web development project, web single page development
Projet de développement web, développement d'une page Web
数字化转型的深层逻辑 -企业数字化思考之二
Industry development and research status based on 3D GIS technology