face3d icon indicating copy to clipboard operation
face3d copied to clipboard

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

Open Cogito2012 opened this issue 7 years ago • 20 comments

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

Cogito2012 avatar Oct 27 '18 06:10 Cogito2012

same problem here!

cnaaq avatar Dec 10 '18 12:12 cnaaq

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!

emadeldeen24 avatar Jan 09 '19 11:01 emadeldeen24

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

Cogito2012 avatar Jan 09 '19 15:01 Cogito2012

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

emadeldeen24 avatar Jan 09 '19 17:01 emadeldeen24

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?

imhpdev avatar Apr 09 '19 19:04 imhpdev

@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.

LucienXian avatar May 13 '19 09:05 LucienXian

@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

emadeldeen24 avatar May 13 '19 12:05 emadeldeen24

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?

fiona-lxd avatar Dec 11 '19 03:12 fiona-lxd

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?

varunszapp avatar Dec 11 '19 13:12 varunszapp

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?

fiona-lxd avatar Dec 12 '19 07:12 fiona-lxd

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?

varunszapp avatar Dec 12 '19 11:12 varunszapp

@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 [email protected] thankyou

musgan avatar Jun 22 '20 03:06 musgan

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 .

Yaoxingtian avatar Oct 21 '20 09:10 Yaoxingtian

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 avatar Oct 21 '20 09:10 emadeldeen24

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'

cheapskatecoder avatar Nov 02 '20 09:11 cheapskatecoder

@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

kadimakipp avatar Nov 03 '20 02:11 kadimakipp

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

genesis02 avatar Dec 09 '20 13:12 genesis02

@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

ghost avatar Jan 06 '21 09:01 ghost

@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

wxyelena avatar Feb 23 '21 00:02 wxyelena

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

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

    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

yzliu21 avatar Mar 02 '22 06:03 yzliu21