首页 > 其他分享 >onnxruntime InferenceSession

onnxruntime InferenceSession

时间:2023-01-04 13:24:56浏览次数:36  
标签:sess name onnxruntime import InferenceSession output np input

 

import onnxruntime
import onnx
import numpy as np

input = np.random.rand(1,3,224,224).astype(dtype=np.float32)
sess = onnxruntime.InferenceSession("add_model.onnx")
result = sess.run(["output"],{"input":input})
print(result)

 

 

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)

 

标签:sess,name,onnxruntime,import,InferenceSession,output,np,input
From: https://www.cnblogs.com/sinferwu/p/17024543.html

相关文章

  • windows上用vs2017静态编译onnxruntime-gpu CUDA cuDNN TensorRT的坎坷之路
    因为工作业务需求的关系,需编译onnxruntime引入项目中使用,主项目exe是使用的vs2017+qt5.12。onnxruntime就不用介绍是啥了撒,在优化和加速AI机器学习推理和训练这块赫赫有名......
  • onnxruntime 部署时input注意
     input_feed中的feats是转换成onnx时的名字,其可通过https://netron.app/ 查看onnx模型结构得到。feats2=feats2.unsqueeze(0).numpy()embeddings2=session.run(......
  • onnxruntime源码解析之C接口简介
    一、C接口1.简介其他语言的接口都是在C接口的基础上,进一步的封装。C的接口头文件为:onnxruntime_c_api.h头文件内包含了详细的注释和说明。总体上,除了一些数据结构的......