-
Notifications
You must be signed in to change notification settings - Fork 4.4k
arcface demo #6386
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
base: master
Are you sure you want to change the base?
arcface demo #6386
Conversation
|
The binary size change of libncnn.so (bytes)
|
examples/arcface.cpp
Outdated
| dst[i].x = ARCFACE_DST[i][0] * ratio + diff_x; | ||
| dst[i].y = ARCFACE_DST[i][1] * ratio; | ||
| } | ||
| output = cv::estimateAffinePartial2D(lmk, dst, cv::noArray(), cv::LMEDS, 0.99, 2000, 0.99, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is ncnn::get_affine_transform for this purpose.
so we can remove opencv_calib3d dependency.
examples/arcface.cpp
Outdated
| } | ||
|
|
||
|
|
||
| void normalize_arcface(std::array<float, 512> &feature) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
port to std::vector for c++03 compatibility
examples/arcface.cpp
Outdated
| #include <float.h> | ||
| #include <stdio.h> | ||
| #include <vector> | ||
| #include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use printf/fprintf for logging and file io
drop the iostream header
examples/arcface.cpp
Outdated
| const float mean_vals[][3] = { | ||
| {0.f, 0.f, 0.f}, | ||
| {0.f, 0.f, 0.f}, | ||
| {0.f, 0.f, 0.f}, | ||
| {0.f, 0.f, 0.f}, | ||
| }; | ||
|
|
||
| const float norm_vals[][3] = { | ||
| {1 / 255.f, 1 / 255.f, 1 / 255.f}, | ||
| {1 / 255.f, 1 / 255.f, 1 / 255.f}, | ||
| {1 / 255.f, 1 / 255.f, 1 / 255.f}, | ||
| {1 / 255.f, 1 / 255.f, 1 / 255.f}, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare mean_vals and norm_vals as local variable
I see that only the first row is used
examples/arcface.cpp
Outdated
| } | ||
|
|
||
| /* you can extract another image and compare using get_similarity() | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ask the user to provide two images and output the similarity
./arcface a.jpg b.jpg
a.jpg face = x y w h
b.jpg face = x y w h
similarity = 0.9555
|
@nihui ive made changes according to your request that includes:
|
|
hello, please enable github action in YOUR FORKED REPO to make code-format workflow work |
I already enabled it in my forked repo in |
Then you need to commit and push a dummy change (eg. adding an empty line) to trigger your code-format workflow. |
|
goto https://github.com/heabeounMKTO/ncnn/settings/actions check push a dummy commit |
this is my permissions in the earlier commit, still doesnt seem to work? |
|
https://github.com/heabeounMKTO/ncnn/actions |
ohh thanks, i am not familiar with github actions. |
|
i got an error on code format run |
You can refer to GitHub's official documentation on creating support tickets for assistance with account and billing issues: Since this is an account-specific issue that's preventing the workflow from running, you'll need to resolve it with GitHub Support before the code format check can complete. The pull request cannot be merged until the code format check passes. |
|
@nihui i've resolved the code formatting issue now, thanks for bearing with me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new example demonstrating face recognition using YOLOv8-face for face detection and ArcFace for embedding extraction. The example loads two face images, detects faces, extracts embeddings, and computes similarity between them.
- Implements complete face detection and recognition pipeline with YOLOv8-face and ArcFace models
- Adds utility classes for bounding box management and non-maximum suppression
- Integrates the new example into the CMake build system
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 21 comments.
| File | Description |
|---|---|
| examples/arcface.cpp | New example implementing face detection with YOLOv8-face and embedding extraction with ArcFace, including utilities for bbox operations, NMS, and face alignment |
| examples/CMakeLists.txt | Registers the new arcface example in the build system |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
hello @nihui , would you like me to commit the copilot suggested changes? |
Hello, it depends on whether you agree with copilot's suggestions. Sometimes copilot's suggested modifications are reasonable, in which case you should accept and submit the changes. Other times, they are not, in which case you should ignore them and choose to |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
ive added some suggestions from the bot @nihui , please review and give me some feedback, thanks ! |

cv::estimateAffinePartial2D