cpu multipart detection error
MyraBaba opened this issue · comments
Hi,
I trying to run cpu docker on my mac os x. its deployed succesfully and I try to send lumia.jpd from api multipart it gives error :
`docker attach 0d72e0e344fd
100%|██████████████████████████████████████████████████████████████████████████| 254556/254556 [03:27<00:00, 1228.47KB/s]
100%|██████████████████████████████████████████████████████████████████████████████| 3219/3219 [00:02<00:00, 1471.47KB/s]
Starting InsightFace-REST using 1 workers.
WARNING:root:No module named 'cupy'
(1, 3, 640, 640)
INFO: Started server process [37]
INFO:uvicorn.error:Started server process [37]
INFO: Waiting for application startup.
INFO:uvicorn.error:Waiting for application startup.
INFO: Application startup complete.
INFO:uvicorn.error:Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:18080 (Press CTRL+C to quit)
INFO:uvicorn.error:Uvicorn running on http://0.0.0.0:18080 (Press CTRL+C to quit)
INFO: 127.0.0.1:54150 - "GET /info HTTP/1.1" 200 OK
INFO: 127.0.0.1:54152 - "GET /info HTTP/1.1" 200 OK
INFO: 172.17.0.1:38110 - "GET /docs HTTP/1.1" 200 OK
INFO: 172.17.0.1:38110 - "GET /static/swagger-ui.css HTTP/1.1" 200 OK
INFO: 172.17.0.1:38114 - "GET /static/swagger-ui-bundle.js HTTP/1.1" 200 OK
INFO: 172.17.0.1:38114 - "GET /openapi.json HTTP/1.1" 200 OK
INFO: 172.17.0.1:38110 - "GET /static/favicon.png HTTP/1.1" 304 Not Modified
INFO: 172.17.0.1:38118 - "POST /multipart/draw_detections HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/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 "/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 208, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc
File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in call
raise exc
File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 656, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 259, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 61, in app
response = await func(request)
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "/app/./app.py", line 128, in draw_upl
output = await processing.draw(file, threshold=threshold,
File "/app/./modules/processing.py", line 223, in draw
faces = await self.model.get([image], threshold=threshold, return_face_data=False,
File "/app/./modules/face_model.py", line 211, in get
det_predictions = zip(*_partial_detect(batch_imgs))
File "/app/./modules/face_model.py", line 45, in detect
bboxes, landmarks = self.retina.detect(data, threshold=threshold)
File "/app/./modules/model_zoo/detectors/scrfd.py", line 217, in detect
blob = self._preprocess(imgs)
File "/app/./modules/model_zoo/detectors/scrfd.py", line 292, in _preprocess
blob = cv2.dnn.blobFromImage(
cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-24v3eisa/opencv/modules/dnn/src/dnn.cpp:370: error: (-215:Assertion failed) image0.dims == 2 in function 'blobFromImages'
ERROR:uvicorn.error:Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/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 "/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 208, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc
File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in call
raise exc
File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 656, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 259, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 61, in app
response = await func(request)
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "/app/./app.py", line 128, in draw_upl
output = await processing.draw(file, threshold=threshold,
File "/app/./modules/processing.py", line 223, in draw
faces = await self.model.get([image], threshold=threshold, return_face_data=False,
File "/app/./modules/face_model.py", line 211, in get
det_predictions = zip(*_partial_detect(batch_imgs))
File "/app/./modules/face_model.py", line 45, in detect
bboxes, landmarks = self.retina.detect(data, threshold=threshold)
File "/app/./modules/model_zoo/detectors/scrfd.py", line 217, in detect
blob = self._preprocess(imgs)
File "/app/./modules/model_zoo/detectors/scrfd.py", line 292, in _preprocess
blob = cv2.dnn.blobFromImage(
cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-24v3eisa/opencv/modules/dnn/src/dnn.cpp:370: error: (-215:Assertion failed) image0.dims == 2 in function 'blobFromImages'
I'm currently working on solution, for now closing as duplicate issue. See #62
Thanks.
Also if possible please ad instructions to run as and app without docker.
Best
Thanks.
Also if possible please ad instructions to run as and app without docker.
Best
You mean running without FastAPI as stand-alone module?
In this case there are some issues in current version - module is using some asyncio features to optimize FastAPI performance, which make it incompatible with synchronous code.
Models dir location is currently read from MODELS_DIR
environment variable. You can launch app like:
export MODELS_DIR=path/to/your/models
uvicorn app:app --port 18080 --host 0.0.0.0 --workers 4
You can set any environment variables used to run docker image this way, for example INFERENCE_BACKEND=onnx
, DET_NAME=scrfd_500m_gnkps
and REC_NAME=w600k_r50
I'll add it as argument to related classes though.
I have added root_dir
argument to Processing class. You can override it by changing its value in app.py
.
Keep in mind that environment variables have higher priority in this project and their value will be used first instead of hard-coded values
On Ubuntu I was able to run CPU version without docker with following modifications to src/api_trt/entrypoint.sh
:
#!/bin/bash
echo Preparing models...
python prepare_models.py
echo Starting InsightFace-REST using $NUM_WORKERS workers.
export MODELS_DIR=/home/user/PycharmProjects/InsightFace-REST/models
export INFERENCE_BACKEND=onnx
export NUM_WORKERS=1
uvicorn app:app --port 18080 --host 0.0.0.0 --workers $NUM_WORKERS