当前位置:网站首页>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’ \
边栏推荐
猜你喜欢
杜邦分析法剖析:居然之家新零售集团股份有限公司企业财务分析
Fuel scheme and product business modeling
The answer to the subject of Municipal Administration of the second construction company in 2022 has been provided. Please keep it
[truth] the reason why big factories are not afraid to spend money is...
2022年二建《法规》科目答案已出,请收好
Web development video tutorial, web development teaching
Chenhongzhi: bytegraph, a trillions level graph database developed by byte beating and its application and challenges
【TcaplusDB知识库】TcaplusDB-tcaplusadmin工具介绍
Product story | YuQue drawing board you don't know
Envoyer un SMS - système de carte d'accès intelligent basé sur stm32f103 + as608 module d'empreintes digitales + clé matricielle 4x4 + sim900a
随机推荐
(small information for children to children-03) batch template production of basic information collection folder for children (including PDF, word and certificate folder)
陈宏智:字节跳动自研万亿级图数据库ByteGraph及其应用与挑战
行业领先的界面组件包DevExpress 6月正式发布v21.2.8
2022年二建《市政》科目答案已出,请收好
产品故事|你所不知道的语雀画板
Machine learning (II) - logical regression theory and code explanation
塔米狗股权项目分享:北京化大化新科技股份有限公司163.79万股股份转让
CPU的分支预测
2022年二建《法规》科目答案已出,请收好
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(三)
Pointnet: deep learning on point sets for 3D classification and segmentation
Tamigou equity project sharing: transfer of 1637900 shares of Beijing Huadahua New Technology Co., Ltd
Industry development and research status based on 3D GIS technology
Machine learning (IV) - PCA (principal component analysis) theory and code explanation
Analysis of DuPont analysis method: financial analysis of the New Retail Group Co., Ltd
面试突击56:聚簇索引和非聚簇索引有什么区别?
我们的B端SaaS为什么生存得如此艰难
Analysis of different dimensions of enterprise evaluators: enterprise evaluation of Gansu Power Investment Capital Management Co., Ltd
7、场感知分解机FFM介绍
Lvgl Library Tutorial 01- porting to STM32 (touch screen)