becauseofAI / MobileFace

A face recognition solution on mobile device.
MIT License
746 stars 208 forks source link

error?? #17

Open jiagh2010 opened 5 years ago

jiagh2010 commented 5 years ago

how to use cv2 ?read image as the input of function

becauseofAI commented 5 years ago

@jiagh2010 Which task do you want to run? Maybe you can reference the example of mobileface_allinone.py

smilence86 commented 5 years ago

I'm try to run it on raspberry pi 4b, The way to install mxnet is pip install from official whl (mxnet-1.5.0-py2.py3-none-any.whl), maybe it's not use opencv when it's compile.

So I get this error when run "python get_face_boxes_gluoncv.py": mxnet.base.MXNetError: [10:31:27] /work/mxnet/src/io/image_io.cc:249: Build with USE_OPENCV=1 for image io.

Therefore, I'm try to use cv2.imread instead of presets.yolo.load_test, but failed, I'm new to mxnet, I don't know how to pass paramters to it.

mobileface_allinone.py is also use presets.yolo.load_test to parse image.

becauseofAI commented 5 years ago

@smilence86 You can use this code to transform the image format from opencv Mat to mxnet NDArray.

smilence86 commented 5 years ago

@becauseofAI I'm also get same error by these codes:

#python3 get_face_boxes_gluoncv.py

#x, img = presets.yolo.load_test(image, short=img_short)
frame = cv2.imread(image)
img_nd = nd.array(frame)
x, img = data_trans(img_nd, short=img_short)
x = x.as_in_context(ctx[0])
result = net(x)

Traceback (most recent call last): File "get_face_boxes_gluoncv.py", line 55, in x, img = data_trans(img_nd, short=img_short) File "/opt/projects/MobileFace/example/../MobileFace_Detection/utils/data_presets.py", line 91, in data_trans return transform_test(imgs, short, max_size, stride, mean, std) File "/opt/projects/MobileFace/example/../MobileFace_Detection/utils/data_presets.py", line 48, in transform_test orig_img = img.asnumpy().astype('uint8') File "/opt/projects/MobileFace/.venv/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py", line 1987, in asnumpy ctypes.c_size_t(data.size))) File "/opt/projects/MobileFace/.venv/lib/python3.7/site-packages/mxnet/base.py", line 252, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) mxnet.base.MXNetError: [11:06:51] /work/mxnet/src/io/image_io.cc:299: Build with USE_OPENCV=1 for image io.

becauseofAI commented 5 years ago

@smilence86 Have you build the MXNet with USE_OPENCV=1? Maybe you can use anaconda3 to install mxnet and opencv-python to test the code firstly.

smilence86 commented 5 years ago

@becauseofAI https://mxnet-public.s3.amazonaws.com/install/raspbian/mxnet-1.5.0-py2.py3-none-any.whl