Skip to content

Instantly share code, notes, and snippets.

@satyajitghana
Created August 25, 2020 06:15
Show Gist options
  • Save satyajitghana/bb80a991b2d48f18c8b33627cabc9ea4 to your computer and use it in GitHub Desktop.
Save satyajitghana/bb80a991b2d48f18c8b33627cabc9ea4 to your computer and use it in GitHub Desktop.
import onnxruntime
ort_session = onnxruntime.InferenceSession("simple_pose_estimation.quantized.onnx")
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
# compute ONNX Runtime output prediction
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(tr_img.unsqueeze(0))}
ort_outs = ort_session.run(None, ort_inputs)
ort_outs = np.array(ort_outs[0][0]) # to get 16x64x64 output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment