熱影像物件偵測 (Object Detection on Thermal Image)- 2 使用TensorRT C++ Win10 - 測試onnx model
上篇 文章 我們得到了onnx格式的model,先做個測試確認這個model是可以使用的,需要在onnx framework下執行這個model,這邊使用到python onnx runtime。 一、下載onnx runtime 可以在 https://www.onnxruntime.ai/ 下載你需要的版本。 我下載的是GPU版,在python環境下輸入: pip install onnxruntime-gpu 二、寫執行程式 1.import import cv2> import numpy as np import onnxruntime as ort import onnxruntime.backend 2.讀入 onnx model modelName = 'weights/export.onnx' sess = ort.InferenceSession(modelName) 3.顯示讀入model的相關資訊 print("device", ort.get_device()) print("in count", len(sess.get_inputs())) print("out count", len(sess.get_outputs())) input_name = sess.get_inputs()[0].name print("input name", input_name) input_shape = sess.get_inputs()[0].shape print("input shape", input_shape) input_type = sess.get_inputs()[0].type print("input type", input_type) output_name0 = sess.get_outputs()[0].name print("output0 name", output_name0) output_shape0 = sess.get_outputs()[0].shape pr...