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

使用AcrFace进行人脸识别出现ValueErrorr #23

Open
linuxonly801 opened this issue Apr 16, 2022 · 1 comment
Open

使用AcrFace进行人脸识别出现ValueErrorr #23

linuxonly801 opened this issue Apr 16, 2022 · 1 comment

Comments

@linuxonly801
Copy link

代码如下:

`import insightface_paddle as face
import logging

logging.basicConfig(level=logging.INFO)

parser = face.parser()
args = parser.parse_args()
args.det = True
args.rec = True
args.rec_model = 'ArcFace' # 这里使用ArcFace
args.index = './demo/friends/index.bin'
args.output = './output'
input_path = './demo/friends/query/friends2.jpg'
predictor = face.InsightFace(args=args)
res = predictor.predict(input_path, print_info=True)
print(next(res))`

报错信息如下:
Traceback (most recent call last):
File "D:/PaddleRepo/insight-face-paddle/insightface_paddle_demo.py", line 18, in
print(next(res))
File "D:\PaddleRepo\insight-face-paddle\insightface_paddle.py", line 759, in predict
labels = self.rec_predictor.retrieval(np_feature)
File "D:\PaddleRepo\insight-face-paddle\insightface_paddle.py", line 555, in retrieval
feature).squeeze()
File "D:\PaddleRepo\venv\lib\site-packages\sklearn\metrics\pairwise.py", line 1179, in cosine_similarity
X, Y = check_pairwise_arrays(X, Y)
File "D:\PaddleRepo\venv\lib\site-packages\sklearn\utils\validation.py", line 72, in inner_f
return f(**kwargs)
File "D:\PaddleRepo\venv\lib\site-packages\sklearn\metrics\pairwise.py", line 161, in check_pairwise_arrays
X.shape[1], Y.shape[1]))
ValueError: Incompatible dimension for X and Y matrices: X.shape[1] == 128 while Y.shape[1] == 512

@Nothing1024
Copy link

index.bin生成时需要借助Recognition模型来获取对应的embedding,官方提供的index.bin应该使用mobileface生成的,embedding_size为128
https://github.com/deepinsight/insightface/blob/master/recognition/arcface_paddle/configs/ms1mv2_mobileface.py#L21
而ArcFace的embedding_size是512
https://github.com/deepinsight/insightface/blob/master/recognition/arcface_paddle/configs/ms1mv3_r50.py#L21
所以会在https://github.com/littletomatodonkey/insight-face-paddle/blob/main/insightface_paddle.py#L554 时提示维度错误

可以在build_index时选择ArcFace模型,然后用新的index.bin索引进行识别,经测试后可以正常预测

feature.size:512
INFO:root:File: t1.png, predict label(s): ['test291']
INFO:root:Predict complete!

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