Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: number of dims don't match in permute #19

Closed
vmorshc opened this issue Jul 21, 2021 · 3 comments
Closed

RuntimeError: number of dims don't match in permute #19

vmorshc opened this issue Jul 21, 2021 · 3 comments

Comments

@vmorshc
Copy link

vmorshc commented Jul 21, 2021

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

@sajjjadayobi
Copy link
Owner

Does this happen with other images as well?

@vmorshc
Copy link
Author

vmorshc commented Jul 22, 2021

Does this happen with other images as well?

no, only with this and few more

@sajjjadayobi
Copy link
Owner

sajjjadayobi commented Jul 22, 2021

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants