convert-the-model-to-rknn/002验证ONNX模型.py
2025-08-15 10:24:30 +08:00

12 lines
502 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/rk3588/pytorch模型转rknn/models/yolov8m.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坐标