RuntimeError: number of dims don't match in permute
vmorshc opened this issue · 3 comments
When i try recognize same images, i get next error:
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, 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 45, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 199, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 111, 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 from None
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/middleware/cors.py", line 86, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/usr/local/lib/python3.8/site-packages/starlette/middleware/cors.py", line 142, in simple_response
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in call
raise exc from None
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 566, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
response = await func(request)
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 201, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
return await dependant.call(**values)
File "/app/./main.py", line 519, in get_age
genders, ages = age_gender_detector.detect(faces)
File "/usr/local/lib/python3.8/site-packages/facelib/AgeGender/Detector.py", line 46, in detect
faces = faces.permute(0, 3, 1, 2)
RuntimeError: number of dims don't match in permute
Image sample: https://drive.google.com/open?id=14xAAW5a74dpNynF3xji5eMQO7yWjPN2c
Does this happen with other images as well?
Does this happen with other images as well?
no, only with this and few more
Printing faces.shape
and getting 0 led me to conclude that the problem is with the face detector and not age or gender detection.
The image is very low quality, so the face detector model cannot find any faces on it.
simple solution is
faces, boxes, scores, landmarks = face_detector.detect_align(img)
if len(faces.shape) == 1:
print("the model can't find any faces")