Skip to content

Conversation

@heabeounMKTO
Copy link

@heabeounMKTO heabeounMKTO commented Nov 1, 2025

  • added arcface embedding extraction demo using yolov8-face to extract face keypoints and extract embedding from detected face
  • added calib3d to cmake for cv::estimateAffinePartial2D
  • added optional comparison function for comparing embeddings

@tencent-adm
Copy link
Member

tencent-adm commented Nov 1, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Nov 1, 2025

The binary size change of libncnn.so (bytes)

architecture base size pr size difference
x86_64 15216992 15208240 -8752 😘
armhf 6206792 6210540 +3748 ⚠️
aarch64 9524440 9523592 -848 😘

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);
Copy link
Member

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.

}


void normalize_arcface(std::array<float, 512> &feature) {
Copy link
Member

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

#include <float.h>
#include <stdio.h>
#include <vector>
#include <iostream>
Copy link
Member

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

Comment on lines 40 to 52
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},
};
Copy link
Member

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

}

/* you can extract another image and compare using get_similarity()
*/
Copy link
Member

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

@heabeounMKTO
Copy link
Author

@nihui ive made changes according to your request that includes:

  • replace cv::calib3d fucntion with an ncnn one
  • replace std::array with std::vector
  • use printf and fprintf
  • local variables for mean , norm and arcface_dst
  • command line args for inputting two images
    please tell me if there is anything you want to change , thanks

@heabeounMKTO heabeounMKTO requested a review from nihui November 4, 2025 13:06
@nihui
Copy link
Member

nihui commented Nov 5, 2025

hello, please enable github action in YOUR FORKED REPO to make code-format workflow work

@heabeounMKTO
Copy link
Author

hello, please enable github action in YOUR FORKED REPO to make code-format workflow work

I already enabled it in my forked repo in
Settings > Actions > General > Actions permissions > Allow all actions and reusable workflows

@nihui
Copy link
Member

nihui commented Nov 5, 2025

hello, please enable github action in YOUR FORKED REPO to make code-format workflow work

I already enabled it in my forked repo in Settings > Actions > General > Actions permissions > Allow all actions and reusable workflows

Then you need to commit and push a dummy change (eg. adding an empty line) to trigger your code-format workflow.

@nihui
Copy link
Member

nihui commented Nov 5, 2025

goto https://github.com/heabeounMKTO/ncnn/settings/actions

check Allow all actions and reusable workflows in Actions permissions
check Read and write permissions in Workflow permissions

push a dummy commit

@heabeounMKTO
Copy link
Author

heabeounMKTO commented Nov 5, 2025

goto https://github.com/heabeounMKTO/ncnn/settings/actions

check Allow all actions and reusable workflows in Actions permissions check Read and write permissions in Workflow permissions

push a dummy commit

this is my permissions in the earlier commit, still doesnt seem to work?
Screenshot_2025-11-05_18-55-48

@nihui
Copy link
Member

nihui commented Nov 5, 2025

https://github.com/heabeounMKTO/ncnn/actions
The enabled workflows can be found there

@heabeounMKTO
Copy link
Author

https://github.com/heabeounMKTO/ncnn/actions The enabled workflows can be found there

ohh thanks, i am not familiar with github actions.

@heabeounMKTO
Copy link
Author

i got an error on code format run
The job was not started because your account is locked due to a billing issue. , do i need to setup billing?

@nihui
Copy link
Member

nihui commented Nov 7, 2025

i got an error on code format run The job was not started because your account is locked due to a billing issue. , do i need to setup billing?

You can refer to GitHub's official documentation on creating support tickets for assistance with account and billing issues:
https://docs.github.com/en/support/contacting-github-support/creating-a-support-ticket

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.

@heabeounMKTO
Copy link
Author

@nihui i've resolved the code formatting issue now, thanks for bearing with me!

@nihui nihui closed this Nov 7, 2025
@nihui nihui reopened this Nov 7, 2025
@nihui nihui requested a review from Copilot November 7, 2025 05:14
Copy link
Contributor

Copilot AI left a 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.

@heabeounMKTO
Copy link
Author

hello @nihui , would you like me to commit the copilot suggested changes?

@nihui
Copy link
Member

nihui commented Nov 10, 2025

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 resolve conversation.

@heabeounMKTO
Copy link
Author

ive added some suggestions from the bot @nihui , please review and give me some feedback, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants