kangda_robotic_dog/008验证yolov8_onxx.py

9 lines
497 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import onnxruntime as ort
import numpy as np
sess = ort.InferenceSession("/home/admin-root/haotian/康达瑞贝斯机器狗/yolov8_20250820.onnx")
input_name = sess.get_inputs()[0].name
output_name = sess.get_outputs()[0].name
# 模拟输入BCHW 格式)
input_data = np.random.randint(0, 255, (1, 3, 640, 640), dtype=np.uint8)
outputs = sess.run([output_name], {input_name: input_data.astype(np.float32)})
print("输出形状:", outputs[0].shape) # 应为 [1, 84, 8400]84=80类+4坐标