[go: nahoru, domu]

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

Facemesh from mediapipe #1316

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

David-rn
Copy link
Contributor

Description

According to issue #1274, this PR extends the usage of from_mediapipe function to support FaceMesh.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

The following Google Colab describes the process used for testing this new feature. It allows to upload a picture to test it. (This Colab feature only worked in Chrome for me).

The first part of the Colab is the examples from the PoseLandmaker to ensure that this functionality is still working after the new changes.

Any specific deployment considerations

  • As discussed in the issue thread, I created two Skeletons: FACEMESH_TESSELATION_NO_IRIS and FACEMESH_TESSELATION to support the legacy code with optional refinement of the iris. However, there is a minor difference between the skeletons described in the mediapipe library and the ones in this PR. The skeletons represent the connections between each point on them, but there are 2 points out of the 478 that do not have a connection (the centre of the iris). Since the EdgeAnnotator class uses the SKELETONS_BY_VERTEX_COUNT variable for counting unique vertices in the skeleton, I connected each center to itself to have a unique vertex count of 478. This can be appreciate in the Google Colab notebook.

  • The code was updated to look for the correct inference result using the hasattr method, which makes easier to integrate the HandLandmarker results in the future (if it is planned).

  • The docstring was updated to add a FaceLandmarker inference example. (The lines are probably too long but the pre-commit won't reformat)

Docs

  • Docs updated? What were the changes:

Copy link
Collaborator
@LinasKo LinasKo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @David-rn,

Excellent work as always! There's a few extra tests in the Colab that I'd like to see.

  1. I see the section "Modern" at the end, but the code is missing; likely not saved. This is probably the copy of what's in the docstring + download of the landmarker task.
  2. Can we test with an empty image? np.empty((640,640,3), dtype=np.uint8) usually works.
  3. I wonder, can this detect more than 1 face?

@David-rn
Copy link
Contributor Author
David-rn commented Jul 1, 2024

Hi @LinasKo, Thanks for the comments!

My bad!! I don't know why it was not saved. In the same link you can find now the saved version with the extra considerations:

  1. Indeed it was not saved.
  2. The last example is an empty (noise) image.
  3. Yes it can, since it wasn't saved it didn't appear. It can handle more than one face, but num_faces attribute needs to be set.

@onuralpszr
Copy link
Collaborator
onuralpszr commented Jul 1, 2024

@David-rn thanks for fixing collab (I was also curious why is it was missing, I thought you were working) can you change commit sha in last commit for trigger pre-commit (There was a github server issue at the time but it is fixed so pre-commit should work fine again)

Without any change you can do this

git add --amend --no-edit 
git push -f

@David-rn David-rn force-pushed the feat/facemesh_from_mediapipe branch from 5e94100 to a023259 Compare July 1, 2024 17:33
@LinasKo LinasKo linked an issue Jul 5, 2024 that may be closed by this pull request
@LinasKo
Copy link
Collaborator
LinasKo commented Jul 5, 2024

I've tested it with multiple images, checked out how the docs look, added a bit of a change. I believe my suggestion in the colab to test on an empty image wasn't entirely correct - I meant np.zeroes rather than np.empty. Still, the result looks as I'd expect in both cases.

Thank you @David-rn (and @onuralpszr) - another flawless, well-described contribution. It's a pleasure working with you :)

Merging!

(fyi @SkalskiP, skeletons.py now contains a variable which is a VERY long list of edges. I want the functionality in the repo now, but if it bothers us, we can export it to a json file later).

@LinasKo LinasKo merged commit c40734f into roboflow:develop Jul 5, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

[KeyPoints] - extend from_mediapipe with Google MediaPipe FaceMesh
3 participants