SthPhoenix / InsightFace-REST

InsightFace REST API for easy deployment of face recognition services with TensorRT in Docker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demo_client not working for cpu based app

MyraBaba opened this issue · comments

Hi,

I started app from command line for cpu as you mentioned.

demo_celint.py fine for GPU docker and working well.

But cpu (run from command line) version gives internal error.

HI! Could you be more specific please? Does server provide some traceback in logs?

Server side :

`INFO: 127.0.0.1:52954 - "POST /extract HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/fastapi/applications.py", line 208, in call
await super().call(scope, receive, send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in call
raise exc
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/routing.py", line 656, in call
await route.handle(scope, receive, send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/routing.py", line 259, in handle
await self.app(scope, receive, send)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/starlette/routing.py", line 61, in app
response = await func(request)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/fastapi/routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "/Users/tulpar/Projects/InsightFace-REST/src/api_trt/app.py", line 81, in extract
output = await processing.extract(images, max_size=data.max_size, return_face_data=data.return_face_data,
File "/Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/processing.py", line 201, in extract
output = await self.embed(images, max_size=max_size, return_face_data=return_face_data, threshold=threshold,
File "/Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/processing.py", line 151, in embed
faces_by_img = (e for e in await _get([img.facedata for img in imgs_iterable]))
File "/Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/face_model.py", line 256, in get
crops = face_align.norm_crop_batched(images[orig_id], landmarks)
File "/Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/utils/fast_face_align.py", line 134, in norm_crop_batched
Ms = estimate_norm_batch(landmarks, image_size, mode)
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/numba/core/dispatcher.py", line 482, in _compile_for_args
error_rewrite(e, 'typing')
File "/Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/numba/core/dispatcher.py", line 423, in error_rewrite
raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<function det at 0x7feaa86f75e0>) found for signature:

det(array(float64, 2d, C))

There are 2 candidate implementations:

  • Of which 2 did not match due to:
    Overload in function 'det_impl': File: numba/np/linalg.py: Line 2017.
    With argument(s): '(array(float64, 2d, C))':
    Rejected as the implementation raised a specific error:
    ImportError: scipy 0.16+ is required for linear algebra
    raised from /Users/tulpar/Projects/Deepfake-Detection2/venv/InsightFace-REST-Nov2021/lib/python3.8/site-packages/numba/np/linalg.py:65

During: resolving callee type: Function(<function det at 0x7feaa86f75e0>)
During: typing of call at /Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/utils/fast_face_align.py (69)

File "modules/utils/fast_face_align.py", line 69:
def _umeyama(src, dst, estimate_scale):

d = np.ones((dim,), dtype=np.double)
if np.linalg.det(A) < 0:
^

During: resolving callee type: type(CPUDispatcher(<function _umeyama at 0x7fead85ab310>))
During: typing of call at /Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/utils/fast_face_align.py (114)

During: resolving callee type: type(CPUDispatcher(<function _umeyama at 0x7fead85ab310>))
During: typing of call at /Users/tulpar/Projects/InsightFace-REST/src/api_trt/modules/utils/fast_face_align.py (114)

File "modules/utils/fast_face_align.py", line 114:
def estimate_norm(lmk, image_size=112, mode='arcface'):

params = _umeyama(lmk, src[0], True)
^`

demo_client.py side :

`
Server: http://localhost:18081
Inference backend: onnx
Detection model: centerface
Recognition model: arcface_r100_v1

Benchmark configs:
Number of iterations: 10
Minimum num. of files per iter: 1000
Number of threads: 10

No data directory provided. Using test_images/Stallone.jpg for testing.
Total files detected: 1
Number of files is less than 1000. Files will be cycled.

Running benchmark...
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/Users/tulpar/Projects/InsightFace-REST/demo_client.py", line 111, in extract
content = ujson.loads(resp.content)
ValueError: Expected object or value
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/tulpar/Projects/InsightFace-REST/demo_client.py", line 196, in
r = pool.map(_part_extract_vecs, im_batches)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/pool.py", line 771, in get
raise self._value
ValueError: Expected object or value

Process finished with exit code 1
`

That seems to be related to issue with numba cache I have mentioned in #62 , for some reason if cache was first built for GPU version it won't work in CPU version, you can try clearing caches or just run from clean clone.

Same errors both cache=False and clean clone

FYI

For some reason I can't reproduce your errors, CPU version works both in docker and from command line.

Actually your issue seems to be related to following lines of traceback:

Rejected as the implementation raised a specific error:
ImportError: scipy 0.16+ is required for linear algebra

yes now its worked. how I missed it.

thx

Glad to help you )