当前位置:网站首页>Tis tutorial 03 export
Tis tutorial 03 export
2022-06-22 12:36:00 【Zhou xiansen likes vegetarian food】
brief introduction
as everyone knows , The model deployment framework deploys a deep learning model , So we hope TIS Only the reasoning of the model is processed , Therefore, it is necessary to provide it with an appropriate model . And for PyTorch In terms of the model of , There are two main deployment level models , One is universal ONNX Model In order to support many frameworks , The other is PyTorch Self contained TorchScript Model . This paper and This series All other articles in have adopted TorchScript Model for deployment .
TorchScript
First of all, let's introduce TorchScript What is it ?

TorchScript The main application scenario is to put Python/PyTorch Convert the code to an equivalent C++ Code to improve the operational efficiency of the online production environment deployment of the deep learning model .Python The code will be compiled into TorchScript A format that the compiler can understand (ScriptModule),C++ The production environment can load files in this format and use the built-in JIT To execute the corresponding code .
Landing on the model level , It's really just the PyTorch Model from Python process ( It generally refers to the development environment , For model design and training ) Save in and load into no Python rely on ( Generally refers to the deployment environment , For online deployment of models ) In the process of . In the process , pure Python The model is transformed to be independent of Python Of TorchScript Program , Such as C++ Environment , It makes the deployment of production environment possible , In this environment ,Python The program may not be applicable due to performance and multithreading .
TorchScript from PyTorch1.x Start to improve , yes PyTorch and TensorFlow The competitive industrial deployment is a significant contribution to the market .
Model export
actually ,TorchScript Support is Python To C++ This kind of efficient locale transformation , One of the most typical is the use of C++ Compiling LibTorch library . however ,TorchScript Become an ecological , There is also a lower level of grammar to learn , In the following, I will just introduce the common strategies for model export , as for LibTorch The details of using Triton Inference Server There is no need to pay too much attention , We just need to focus on the model in TIS The reasoning operation structure in the .
To preserve TorchScript Model , You need to build this model first and track it once , You can serialize the model to a local file .
import torch
x = torch.randn(1, 3, 640, 640)
model = create_model('yolov5s')
ts_model = torch.jit.trace(model, x, strict=False)
ts_model.save('yolov5.ts.pt')
The top one is to use TorchScript take PyTorch Example code of model export , I'm here to yolov5s export . As for the details of model loading , By TIS To be responsible for , in fact TIS Support includes TensorRT、TorchScript(LibTorch)、TensorFlow And a variety of back ends , We just need to improve the input and output configuration details .
summary
This article simply introduces TorchScript Simple operation of model export , If you want to know more, please study it in detail Official documents .
边栏推荐
猜你喜欢

胡润研究院首发中国元宇宙潜力企业榜,巨杉数据库入选未来之星企业

1961 check if string is a prefix of array

SAP-FI-财务报表版本设定

Vue mixed write Minxin, virtual dom/ref, dynamic components, cache keep

Flutter -- realize the tabbar switching effect of Netease cloud music

1961-Check If String Is a Prefix of Array(检查字符串是否为数组前缀)

巨杉数据库受邀出席鲲鹏开发者年度盛会2022,共建国产化数字底座

TIS教程04-客户端
![[lihongyi] notes on deep learning of machine learning -- Introduction to training model clearance](/img/d6/22db1b5fb8c9fcaa0e9b800a0998d0.png)
[lihongyi] notes on deep learning of machine learning -- Introduction to training model clearance

Getting started with webrtc: 11 In kurento, rtendpoint is used to pull RTP streams for clustering in live broadcast
随机推荐
银行支付接口开发之子账户
什么是C语言结构体字节对齐,为什么要对齐?
access_token不到两个小时失效的处理办法
Sap-abap- how to call an external interface by webapi
胡润研究院首发中国元宇宙潜力企业榜,巨杉数据库入选未来之星企业
TIS教程04-客户端
SAP-ABAP-BAPI_GOODSMVT_CREATE创建物料凭证bapi的各种情况如何赋值
OGG-01431、01003、01151无奈的处理方式
查看gstreamer插件
ffmpeg将amr格式转成mp3格式
Invisible traffic Commander: on Urban Rail Transit Signal System
Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值
C language itoa() function and atoi() function explanation (integer to character c implementation)
awk语言与oracle数据库交互取近半年情况
SAP-ABAP-如何用WEBAPI的方式调用外部接口
Fast establishment of tensorflow2 model optimization environment
Vue混写Minxin、虚拟Dom/ref、动态组件、缓存keep
Fault tolerant heap shim applied to current process. This is usually due to previous crashes
Tensorflow2 模型优化环境快速搭建
第十二届 蓝桥杯 嵌入式设计与开发项目 决赛