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

How to make eye blinking #23

Open
0724veni opened this issue Mar 10, 2020 · 6 comments
Open

How to make eye blinking #23

0724veni opened this issue Mar 10, 2020 · 6 comments

Comments

@0724veni
Copy link

0724veni commented Mar 10, 2020

Thanks for great work. There is a lot of help for me
Although I saw other issue about eye blinking, I don't implement eye blinking.
What you said is removing eye parts of mesh (the triangles) that correspond to the eye regions.

  1. how to remove eye parts of mesh in code?
    What i know is
  • len(mesh) = 175
    mean3DShape, blendshapes, mesh, idxs3D, idxs2D = utils.load3DFaceModel("candide.npz")
  • mesh means 'FACE LIST' in candide
    What you mentioned

I don't know where eye parts is in 175. So could you give me advice? Could you give me edidted candide.npz model which remove eye parts?

  1. len(mesh) is differnt from 'FACE LIST' in candide3.wfm. why is it??
    This candide3.wfm is the latest version of candide model(v3.1.6)
    len(mesh) = 175
    'FACE LIST' in candide3.wfm = 184
    What do you think about?
    Maybe are you deleting some parts in 'FACE LIST'?
    What you said about model is 'processed version'

  2. Your Code doesn't work transition between .txt to .npz.

  • transition code
  • .txt
    Is transition code for your 'processed version' candide model?
  • error
    Traceback (most recent call last):
    File "candide.py", line 192, in
    tempMode = np.zeros((1, mean3.shape[0], mean3.shape[1]))
    IndexError: tuple index out of range
@MarekKowalski
Copy link
Owner

MarekKowalski commented Apr 7, 2020

Hi,
sorry for the massive delay with answering.
The way to find out which faces (triangles) correspond to eyes would be to save the mean3DShape with the mesh topology to a .ply or .obj file. You would then open that file in something like meshlab and check triangle indices. You can easily save to .obj and .ply using packages like trimesh. Writing an obj writer yourself is very easy as well. I am trying to find an .obj file for candide on my old computer.

I think I removed some triangles that corresponded to forehead and maybe sides of the face, hence len(mesh) < official number of triangles.

I think that the .txt file I used in the transition code was the original candide. The processed version refers to removing the triangles as mentioned above. That would not be required until line .. of the script you linked.
The error you got seems to suggest that mean3 (the mean 3D shape) does not load correctly, not sure why.

@MarekKowalski
Copy link
Owner

I found an .obj file on my old machine that should correspond to the mesh used in the app, it is attached. As mentioned above you can open it in meshlab and easily check which triangle is which. You can then remove the corresponding rows from the mesh matrix in code to remove the triangles from the face swap.

candideInterior3.zip

@ZhangLei999
Copy link

The eye area is deleted by use meshlab. And save the result.obj as candideInterior3.obj. Then I remove the corresponding rows from the mesh matrix in code like this:
mean3DShape, blendshapes, _, idxs3D, idxs2D = utils.load3DFaceModel( os.path.join(os.path.dirname(file), "..", "candide2.npz"))
_, mesh = loadOBJ("./candideInterior3.obj")
It doesn't work.
微信截图_20210713155515

@MarekKowalski
Copy link
Owner

Hi, can you explain what exactly does not work?

@ZhangLei999
Copy link

After face-swap, the expression on my face was distorted. And the eyes were still not closed.

@MarekKowalski
Copy link
Owner

I see, one problem may be that the mesh variable you load does not assume the same number of points in the mesh or the same order of the points as the mesh that is loaded from the .npz file. I suggest that this is something you may want to investigate.

Perhaps it would be easier if you did as I suggested above and simply delete the rows of the original mesh that correspond to the eyes. This way you can be sure that you are modifying the right thing. To find out which triangles correspond to the eyes you can try visualizing the mesh from the Python app itself with consecutive triangles removed until you find which ones are covering the eyes.

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

3 participants