Ultra-Light-Fast-Generic-Face-Detector-1MB icon indicating copy to clipboard operation
Ultra-Light-Fast-Generic-Face-Detector-1MB copied to clipboard

MNN python inference throws runtime_error

Open kushalchordiya216 opened this issue 4 years ago • 1 comments

I'm running the example inference script MNN/python/ultraface_py_mnn.py. I have installed all required dependencies, here is an output of pip freeze in the current environment

certifi==2020.4.5.1 cycler==0.10.0 flatbuffers==1.12 future==0.18.2 graphviz==0.14 kiwisolver==1.2.0 matplotlib==3.2.1 MNN==1.0.1 more-itertools==7.2.0 notedown==1.5.1 numpy==1.18.4 onnx==1.7.0 onnxruntime==1.3.0 opencv-python==4.2.0.34 pandas==1.0.3 pandoc-attributes==0.1.7 Pillow==7.1.2 protobuf==3.12.1 ptflops==0.6.2 pydot-ng==2.0.0 pynvim==0.3.2 pyparsing==2.4.7 python-dateutil==2.8.1 python-utils==2.4.0 pytz==2020.1 six==1.15.0 torch==1.5.0 torchstat==0.0.7 torchsummary==1.5.1 torchvision==0.6.0 typing==3.7.4.1 typing-extensions==3.7.4.2

when I run the script as it is, I get the following error

priors nums:4420 terminate called after throwing an instance of 'std::runtime_error' what(): numpy type does not match

I ran the script in debug mode to find out the exact line responsible for the error and it was this one, line 129,

tmp_input = MNN.Tensor((1, 3, input_size[1], input_size[0]), MNN.Halide_Type_Float, image, MNN.Tensor_DimensionType_Caffe) platform: Ubuntu 18.04, Linux kernel 5.3.0 Python version : Python 3.7.7

kushalchordiya216 avatar May 27 '20 14:05 kushalchordiya216

you should convert data to float32: image = np.asarray(image, dtype=np.float32) tmp_input = MNN.Tensor((1, 3, input_size[1], input_size[0]), MNN.Halide_Type_Float, image, MNN.Tensor_DimensionType_Caffe)

PanJinquan avatar May 28 '20 02:05 PanJinquan