yfeng95 / face3d

Python tools for 3D face: 3DMM, Mesh processing(transform, camera, light, render), 3D face representations.
2.65k stars 611 forks source link

How to prepare examples/Data/example1.mat file? #11

Open Cogito2012 opened 5 years ago

Cogito2012 commented 5 years ago

I have not found any codes to generate your test .mat file: examples/Data/example1.mat

When I get the BFM data as the README instructed, how can I prepare these mat files into example1.mat, i.e., vertices and triangles?

I tried directly using the tri and shapePC in 01_MorphableModel.mat, and use the w_exp in Model_Expression.mat to compute the vertex as vertices and triangles, but the PNCC result is strange ...

Hope anyone can provide instructions, thanks

cnaaq commented 5 years ago

same problem here!

emadeldeen24 commented 5 years ago

I had the same issue, but I thought that I can just create the vertices, triangles, and colors from the images directly instead of creating a .mat file. So after some search, I found this github project. I used the code in this file and you will have to import this file and this one too, and you will finally get the requirements in the variables: "colors", "image_vertices" and "bfm.triangles". Hope this helps, and good luck!

Cogito2012 commented 5 years ago

@Emadeldeen-24 Thank you very much! I'll have a try~~

emadeldeen24 commented 5 years ago

you are welcome! I created this gist to make easier for anyone to use.

imhpdev commented 5 years ago

def generate_colors(self, tex_para): colors = self.model['texMU'] + self.model['texPC']@(tex_para) colors = np.reshape(colors, [3, len(colors) // 3], 'F').T / 255. return colors

In above code I'm getting syntax error with @(tex_para). Does anyone explain what does that line do?

LucienXian commented 5 years ago

@Emadeldeen-24 I get the segmentation fault when I use the file you provided. why? In the line of the code model['tri'] = model['tri'].T.copy(order='C').astype(np.int32) - 1

gdb debug

Thread 1 "python" received signal SIGSEGV, Segmentation fault. 0x00007ffff7de375c in elf_machine_rela (skip_ifunc=0, reloc_addr_arg=0x7fffdc761aa0, version=0x18, sym=0x7fffdc51f500, reloc=0x7fffdc51ffe0, map=0x555556960af0) at ../sysdeps/x86_64/dl-machine.h:303 303 ../sysdeps/x86_64/dl-machine.h: No such file or directory.

emadeldeen24 commented 5 years ago

@Emadeldeen-24 I get the segmentation fault when I use the file you provided. why? In the line of the code model['tri'] = model['tri'].T.copy(order='C').astype(np.int32) - 1

gdb debug

Thread 1 "python" received signal SIGSEGV, Segmentation fault. 0x00007ffff7de375c in elf_machine_rela (skip_ifunc=0, reloc_addr_arg=0x7fffdc761aa0, version=0x18, sym=0x7fffdc51f500, reloc=0x7fffdc51ffe0, map=0x555556960af0) at ../sysdeps/x86_64/dl-machine.h:303 303 ../sysdeps/x86_64/dl-machine.h: No such file or directory.

can't see that in my code

fiona-lxd commented 4 years ago

not sure actually, but thou can try using scipy. https://docs.scipy.org/doc/scipy/reference/tutorial/io.html

Hi, thank you for your contribute. I have found that, in your codes, triangles = bfm.triangles and triangles will never get changed. What if I want to get the 3D model of a 2D image. I found that with your code, we can have the face expression and position changed, but the face didn't match the input face. Do you have any advices?

varunszapp commented 4 years ago

What exactly is the difference between triangles and full_triangles in example1.mat? @Emadeldeen-24 your code produces triangles, but how do I get the full_triangles that I need in 7_generate_uv_map.py?

fiona-lxd commented 4 years ago

What exactly is the difference between triangles and full_triangles in example1.mat? @Emadeldeen-24 your code produces triangles, but how do I get the full_triangles that I need in 7_generate_uv_map.py?

I found no difference..... By the way, does anybody know how to make the eyes closed?

varunszapp commented 4 years ago

Hi! I was trying to run 7_generate_uv_map.py on a sample image instead of example1.mat, by using the technique given by @Emadeldeen-24. The results are being produced, but the scale of the reconstructed image is not correct.

Original image: morgan

files produced on running 7_generate_uv_map.py:

  1. image.jpg morgan_image

the texture map and uv_position_map seem fine though. What am I doing wrong?

musgan commented 4 years ago

@Emadeldeen-24 I get the segmentation fault when I use the file you provided. why? In the line of the code model['tri'] = model['tri'].T.copy(order='C').astype(np.int32) - 1 gdb debug

Thread 1 "python" received signal SIGSEGV, Segmentation fault. 0x00007ffff7de375c in elf_machine_rela (skip_ifunc=0, reloc_addr_arg=0x7fffdc761aa0, version=0x18, sym=0x7fffdc51f500, reloc=0x7fffdc51ffe0, map=0x555556960af0) at ../sysdeps/x86_64/dl-machine.h:303 303 ../sysdeps/x86_64/dl-machine.h: No such file or directory.

can't see that in my code

can you share your model BFM.mat. I got error when I load this model. I'll be so appreciated if you can send me a email at muhusgan@gmail.com thankyou

Yaoxingtian commented 3 years ago

you are welcome! I created this gist to make easier for anyone to use.

HI,did you delete this [gist], I cannot find any info .

emadeldeen24 commented 3 years ago

you are welcome! I created this gist to make easier for anyone to use.

HI,did you delete this [gist], I cannot find any info .

I updated the link for you

cheapskatecoder commented 3 years ago

you are welcome! I created this gist to make easier for anyone to use.

I was trying out your gist and there seems to be an Attribute Error, could you help iron this out ?

    x = mesh_numpy.transform.from_image(landmarks, h, w)
AttributeError: module 'face3d.mesh_numpy.transform' has no attribute 'from_image'
kadimakipp commented 3 years ago

@cheapskatecoder you can check this https://github.com/Shade5/FaceFitting I guess, "from_image" is this https://github.com/Shade5/FaceFitting/blob/master/mesh/transform.py

genesis02 commented 3 years ago

you are welcome! I created this gist to make easier for anyone to use.

HI,did you delete this [gist], I cannot find any info .

I updated the link for you

@emadeldeen24 The images generated by using example1.mat and by using your gist are very different for the IBUG image provided in the code. 1 2

ghost commented 3 years ago

@emadeldeen24 I get the .obj from https://github.com/cleardusk/3DDFA_V2 and how can I get the .mat as you by the .obj from https://github.com/cleardusk/3DDFA_V2. I want to transfer the .obj to img like this. frame0_render

wxyelena commented 3 years ago

@emadeldeen24 I get the .obj from https://github.com/cleardusk/3DDFA_V2 and how can I get the .mat as you by the .obj from https://github.com/cleardusk/3DDFA_V2. I want to transfer the .obj to img like this. frame0_render

hallo did you solve this problem? Because i also want to get a 2d image from .obj

yzliu21 commented 2 years ago

不客气!我创建了这个要点,使任何人都更容易使用。

我正在尝试您的要点,似乎存在属性错误,您能帮助解决这个问题吗?

    x = mesh_numpy.transform.from_image(landmarks, h, w)
AttributeError: module 'face3d.mesh_numpy.transform' has no attribute 'from_image'

@cheapskatecoder Hello, I also encountered the same problem, did you solve it? I would be very grateful if I could get your help