onnx_runtime 推理

onnx_runtime 推理

import numpy as np
import onnx
import onnxruntime as rt
#create input data
input_data = np.ones((1, 3, 299, 299), dtype=np.float32)
#create runtime session
sess = rt.InferenceSession("inception_v3.onnx")
# get output name
input_name = sess.get_inputs()[0].name
print("input name", input_name)
output_name= sess.get_outputs()[0].name
print("output name", output_name)
output_shape = sess.get_outputs()[0].shape
print("output shape", output_shape)
#forward model
res = sess.run([output_name], {input_name: input_data})
out = np.array(res)

https://blog.csdn.net/wsp_1138886114/article/details/123271871

https://github.com/onnx/onnx/tree/main

https://github.com/microsoft/onnxruntime

posted @   michaelchengjl  阅读(94)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2022-08-11 pytorch 模型参数的保存与加载
2022-08-11 pytorch模型转换为onnx,并使用netron可视化
2022-08-11 深度学习框之 静态图&动态图
2022-08-11 衡量AI算力的“FLOPS”
点击右上角即可分享
微信分享提示