Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The onnx model(which is transfor by export_onnx.py) out put is differ from pytoch model #478

Open
Genlk opened this issue Dec 9, 2022 · 0 comments

Comments

@Genlk
Copy link

Genlk commented Dec 9, 2022

def image_preprocess(img_path):
img = cv2.imread(img_path).astype("float32")/255
# mean = [103.53, 116.28, 123.675] # Image net values
# std = [57.375, 57.12, 58.395]
mean = [113.533554, 118.14172, 123.63607]
std = [21.405144, 21.405144, 21.405144]
mean = np.array(mean, dtype=np.float32).reshape(1, 1, 3) / 255
std = np.array(std, dtype=np.float32).reshape(1, 1, 3) / 255
img = (img - mean) / std
img = np.transpose(img, (2, 0, 1))
img = np.expand_dims(img, axis=0)
return img

def test_onnx_model(onnx_model,img_path=None):
if img_path is None:
img_path = "path for img"
imgdata = image_preprocess(img_path)
sess = rt.InferenceSession(onnx_model)
input_name = sess.get_inputs()[0].name
output_detect_name = sess.get_outputs()[0].name
pred_onnx0= sess.run([output_detect_name], {input_name: imgdata})
print("outputs:")
print(np.array(pred_onnx0))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant