anhttran / 3dmm_cnn

Regressing Robust and Discriminative 3D Morphable Models with a very Deep Neural Network
Other
858 stars 254 forks source link

Full head model #10

Closed samsgates closed 7 years ago

samsgates commented 7 years ago

how to create full head model for training dataset( same like BFM, but full head) output will be full head 3d model only mesh, no color or texture

anhttran commented 7 years ago

Hi, To use the full head, you can change trimBaselFace.py:

  1. Do not use vertex_indices3, which is for mesh trimming
  2. Change this line of code: faces = mod_struct.faces to
    faces = model['tl']
    faces[:,[1, 2]] = faces[:,[2, 1]]

Note that the landmark indices will be outdated. Though, we do not use these landmarks in this release.

samsgates commented 7 years ago

i didn't seen the below line in code

faces = mod_struct.faces

any way i have changed "trimBaselFace.py" code as your instruction. but full head model not generated in output, i got same result like half head model.

I have attached edited file as "trim.py", please update and send me back with changes required for generate full head

trim.py.zip

dingtiandu commented 7 years ago

Hi Your result 3d ALPHA only has 99 numbers.Can I get a ALPHA of 199 numbers, just like the old version of BFM dataset? Hoping for replying.

anhttran commented 7 years ago

@samsgates My bad. I looked into a wrong code. Please find the updated code for full head model below.

##MATLAB: BFM.shapeMU = model.shapeMU/1000;
shapeMU = model['shapeMU']/1000;
##MATLAB: BFM.shapeMU(1:3:end) = BFM.shapeMU(1:3:end) + mod_struct.tx;
shapeMU[0:-1:3] = shapeMU[0:-1:3] +  mod_struct.tx
##MATLAB: BFM.shapeEV = model.shapeEV(1:99)/1000;
shapeEV = model['shapeEV'][0:99]/1000.
##MATLAB BFM.shapePC = model.shapePC(:,1:99);
shapePC = model['shapePC'][:,0:99]
##MATLAB  BFM.texMU = model.texMU(:,:);
texMU = model['texMU']
##MATLAB  BFM.texPC = model.texPC(:,1:99);
texPC = model['texPC'][:,0:99];
##MATLAB  BFM.texEV = model.texEV(1:99);
texEV = model['texEV'][0:99];
innerLandmarkIndex = mod_struct.innerLandmarkIndex  # Outdated
outerLandmarkIndex = mod_struct.outerLandmarkIndex # Outdated

#% Faces
faces_tmp = model['tl']
#faces = faces_tmp,[2 1 3])
faces = np.dstack([faces_tmp[:,1], faces_tmp[:,0], faces_tmp[:,2]])
faces = faces[0]

@dingtiandu We only use 99 parameters for shape & texture since they are good enough for face recognition purpose according to Blanz's paper: http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=1227983

samsgates commented 7 years ago

Thanks for your response