import cv2 import numpy as np import onnxruntime as ort def load_model(model_path): """加载ONNX模型""" session = ort.InferenceSession(model_path) return session def preprocess_image(image_path): image = cv2.imread(image_path) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) image = cv2.resize(image, (224, 224)) image = image.astype(np.float32) / 255.0 # 归一化至0-1之间 # 标准化参数 mean_val = np.array([0.485, 0.456, 0.406], dtype=np.float32) std_val = np.array([0.229, 0.224, 0.225], dtype=np.float32) # 标准化图片 […]