Code Monkey home page Code Monkey logo

Comments (15)

HOMGH avatar HOMGH commented on August 27, 2024 1

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

Hi, @HOMGH Can you share the code for outputing 3D face mesh? thank you very much!
The part of the code which is used to generate 3D mesh is :
write_obj_with_colors(('./test' '.obj'), vertices_in, trian.T, colors_in) #save 3d face(can open with meshlab)
in which the inputs are as follows:
trian= load_3DMM_tri_reduce() or load_3DMM_tri()
colors_in = np.ones((VERTEX_NUM_REDUCE,3)) (if you just want to display textureless 3D mesh)
vertices_in = np.reshape(verti,(VERTEX_NUM_REDUCE,3)) (this is the vertices output of network)

The write_obj_with_colors function can be found in write.py file:

def  write_obj_with_colors(obj_name, vertices, triangles, colors):
    ''' Save 3D face model with texture represented by colors.
    Args:
        obj_name: str
        vertices: shape = (nver, 3)
        colors: shape = (nver, 3)
        triangles: shape = (ntri, 3)
    '''
    triangles = triangles.copy()
    triangles += 1 # meshlab start with 1
    
    if obj_name.split('.')[-1] != 'obj':
        obj_name = obj_name + '.obj'
        
    # write obj
    with open(obj_name, 'w') as f:
        
        # write vertices & colors
        for i in range(vertices.shape[0]):
            # s = 'v {} {} {} \n'.format(vertices[0,i], vertices[1,i], vertices[2,i])
            s = 'v {} {} {} {} {} {}\n'.format(vertices[i, 0], vertices[i, 1], vertices[i, 2], colors[i, 0], colors[i, 1], colors[i, 2])
            f.write(s)

        # write f: ver ind/ uv ind
        [k, ntri] = triangles.shape
        for i in range(triangles.shape[0]):
            # s = 'f {} {} {}\n'.format(triangles[i, 0], triangles[i, 1], triangles[i, 2])
            s = 'f {} {} {}\n'.format(triangles[i, 2], triangles[i, 1], triangles[i, 0])
            f.write(s)


from nonlinear_face_3dmm.

danperazzo avatar danperazzo commented on August 27, 2024

Hello, did you manage to create? I have been meaning to do the same thing

from nonlinear_face_3dmm.

HOMGH avatar HOMGH commented on August 27, 2024

Hello, did you manage to create? I have been meaning to do the same thing

No I couldn't get the correct 3D mesh. This is what I got:
Capture

from nonlinear_face_3dmm.

danperazzo avatar danperazzo commented on August 27, 2024

Did you use the generated txt to create the model? And there is no texture?

from nonlinear_face_3dmm.

HOMGH avatar HOMGH commented on August 27, 2024

Did you use the generated txt to create the model? And there is no texture?

For now, I just want to display the shape. with no texture.

from nonlinear_face_3dmm.

danperazzo avatar danperazzo commented on August 27, 2024

And how did you create this mesh?

from nonlinear_face_3dmm.

HOMGH avatar HOMGH commented on August 27, 2024

And how did you create this mesh?

I used write_obj_with_colors(('./test' '.obj'), vertices_in, tri_in, colors_in) #save 3d face(can open with meshlab).
vertices is the generated shape vertices. But I'm not sure about triangle. I used load_3DMM_tri_reduce() function, but it seems something is wrong! Any idea?

from nonlinear_face_3dmm.

danperazzo avatar danperazzo commented on August 27, 2024

Is this function available on this git repository, I did not find it in here. Is it from another repository? And I have no idea how to estimate the triangles.

from nonlinear_face_3dmm.

cassiePython avatar cassiePython commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH

from nonlinear_face_3dmm.

HOMGH avatar HOMGH commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

from nonlinear_face_3dmm.

huyanfei-cqupt avatar huyanfei-cqupt commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

Hi,@HOMGH Can you share the code for outputting 3D face mesh? thank you very much!

from nonlinear_face_3dmm.

huyanfei-cqupt avatar huyanfei-cqupt commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

Hi, @HOMGH Can you share the code for outputing 3D face mesh? thank you very much!

from nonlinear_face_3dmm.

huyanfei-cqupt avatar huyanfei-cqupt commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

Hi, @HOMGH Can you share the code for outputing 3D face mesh? thank you very much!
The part of the code which is used to generate 3D mesh is :
write_obj_with_colors(('./test' '.obj'), vertices_in, trian.T, colors_in) #save 3d face(can open with meshlab)
in which the inputs are as follows:
trian= load_3DMM_tri_reduce() or load_3DMM_tri()
colors_in = np.ones((VERTEX_NUM_REDUCE,3)) (if you just want to display textureless 3D mesh)
vertices_in = np.reshape(verti,(VERTEX_NUM_REDUCE,3)) (this is the vertices output of network)

The write_obj_with_colors function can be found in write.py file:

def  write_obj_with_colors(obj_name, vertices, triangles, colors):
    ''' Save 3D face model with texture represented by colors.
    Args:
        obj_name: str
        vertices: shape = (nver, 3)
        colors: shape = (nver, 3)
        triangles: shape = (ntri, 3)
    '''
    triangles = triangles.copy()
    triangles += 1 # meshlab start with 1
    
    if obj_name.split('.')[-1] != 'obj':
        obj_name = obj_name + '.obj'
        
    # write obj
    with open(obj_name, 'w') as f:
        
        # write vertices & colors
        for i in range(vertices.shape[0]):
            # s = 'v {} {} {} \n'.format(vertices[0,i], vertices[1,i], vertices[2,i])
            s = 'v {} {} {} {} {} {}\n'.format(vertices[i, 0], vertices[i, 1], vertices[i, 2], colors[i, 0], colors[i, 1], colors[i, 2])
            f.write(s)

        # write f: ver ind/ uv ind
        [k, ntri] = triangles.shape
        for i in range(triangles.shape[0]):
            # s = 'f {} {} {}\n'.format(triangles[i, 0], triangles[i, 1], triangles[i, 2])
            s = 'f {} {} {}\n'.format(triangles[i, 2], triangles[i, 1], triangles[i, 0])
            f.write(s)

Hi, @HOMGH Thank you so much for replying to me so quickly。
I have another question. Where should the code you share be added to the model file? Can you give me some tips? Thank you very much for sharing and look forward to hearing from you.

image
Hi, I want to ask what does "trian.T" in the red box mean above image?
Is it convenient to contact you by email? My email address is "[email protected]". Looking forward to your reply.

from nonlinear_face_3dmm.

huyanfei-cqupt avatar huyanfei-cqupt commented on August 27, 2024

Hello, did you manage to create? I have been meaning to do the same thing

No I couldn't get the correct 3D mesh. This is what I got:
Capture

Hi,@HOMGH can you share code of the G_loss_frecon for me ? Thank you.

from nonlinear_face_3dmm.

XuZhengzhuo avatar XuZhengzhuo commented on August 27, 2024

The author adopted the Basel Face Model (BFM) facial mesh triangle topology as stated in his paper. @HOMGH
the problem is that I'm getting always the same 3D mesh for each input (the below 3D mesh). It seems I'm getting the mean shape!
image

Hi, @HOMGH Can you share the code for outputing 3D face mesh? thank you very much!
The part of the code which is used to generate 3D mesh is :
write_obj_with_colors(('./test' '.obj'), vertices_in, trian.T, colors_in) #save 3d face(can open with meshlab)
in which the inputs are as follows:
trian= load_3DMM_tri_reduce() or load_3DMM_tri()
colors_in = np.ones((VERTEX_NUM_REDUCE,3)) (if you just want to display textureless 3D mesh)
vertices_in = np.reshape(verti,(VERTEX_NUM_REDUCE,3)) (this is the vertices output of network)

The write_obj_with_colors function can be found in write.py file:

def  write_obj_with_colors(obj_name, vertices, triangles, colors):
    ''' Save 3D face model with texture represented by colors.
    Args:
        obj_name: str
        vertices: shape = (nver, 3)
        colors: shape = (nver, 3)
        triangles: shape = (ntri, 3)
    '''
    triangles = triangles.copy()
    triangles += 1 # meshlab start with 1
    
    if obj_name.split('.')[-1] != 'obj':
        obj_name = obj_name + '.obj'
        
    # write obj
    with open(obj_name, 'w') as f:
        
        # write vertices & colors
        for i in range(vertices.shape[0]):
            # s = 'v {} {} {} \n'.format(vertices[0,i], vertices[1,i], vertices[2,i])
            s = 'v {} {} {} {} {} {}\n'.format(vertices[i, 0], vertices[i, 1], vertices[i, 2], colors[i, 0], colors[i, 1], colors[i, 2])
            f.write(s)

        # write f: ver ind/ uv ind
        [k, ntri] = triangles.shape
        for i in range(triangles.shape[0]):
            # s = 'f {} {} {}\n'.format(triangles[i, 0], triangles[i, 1], triangles[i, 2])
            s = 'f {} {} {}\n'.format(triangles[i, 2], triangles[i, 1], triangles[i, 0])
            f.write(s)

What is the vertices_in? Do you mean the output 'pred_shape.txt' ? Many thanks.

from nonlinear_face_3dmm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.