RetinaFace-TVM icon indicating copy to clipboard operation
RetinaFace-TVM copied to clipboard

Python inference

Open dexception opened this issue 4 years ago • 0 comments

import numpy as np
import nnvm.compiler
import nnvm.testing
import tvm
from tvm.contrib import graph_runtime
import mxnet as mx
import cv2
from mxnet import ndarray as nd

ctx = tvm.cpu()
data_shape = (640, 480, 3)
loaded_json = open("./models/480P/mnet.25.x86.cpu.json").read()
loaded_lib = tvm.module.load("./models/480P/mnet.25.x86.cpu.so")
loaded_params = bytearray(open("./models/480P/mnet.25.x86.cpu.params", "rb").read())

module = graph_runtime.create(loaded_json, loaded_lib, ctx)
module.load_params(loaded_params)

img = cv2.imread('/home/xyz/desktop/7.jpg')
resized = cv2.resize(img, (480, 640))
input_data = tvm.nd.array(resized.astype("float32"))

module.run(data=input_data)
ret = module.get_output(0).asnumpy()

I am not aware of the output shape and the way to fetch rest of the results. Can you be kind enough to help with rest of the code ?

dexception avatar Mar 12 '20 13:03 dexception