Skip to content

Commit 7ec85e6

Browse files
committed
Formatted BFM2009 & BFM2017 converter script according to PEP 8
1 parent 001e015 commit 7ec85e6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

share/scripts/convert-bfm2009-to-eos.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@
2626
# Their basis is unit norm: np.linalg.norm(shape_pca_basis[:,0]) == 1.0
2727
# And the basis vectors are orthogonal: np.dot(shape_pca_basis[:,0], shape_pca_basis[:,0]) == 1.0
2828
# np.dot(shape_pca_basis[:,0], shape_pca_basis[:,1]) == 1e-08
29-
shape_pca_standard_deviations = bfm2009['shapeEV'] # These are standard deviations, not eigenvalues!
29+
shape_pca_standard_deviations = bfm2009['shapeEV'] # These are standard deviations, not eigenvalues!
3030
shape_pca_eigenvalues = np.square(shape_pca_standard_deviations)
31-
triangle_list = bfm2009['tl'] - 1 # Convert from 1-based Matlab indexing to 0-based C++ indexing
31+
triangle_list = bfm2009['tl'] - 1 # Convert from 1-based Matlab indexing to 0-based C++ indexing
3232
# The BFM has front-facing triangles defined the wrong way round (not in accordance with OpenGL) - we swap the indices:
3333
for t in triangle_list:
3434
t[1], t[2] = t[2], t[1]
35-
shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_eigenvalues, triangle_list.tolist())
35+
shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_eigenvalues,
36+
triangle_list.tolist())
3637

3738
# PCA colour model:
3839
color_mean = bfm2009['texMU']
3940
# The BFM2009's colour data is in the range [0, 255], while the SFM is in [0, 1], so we divide by 255:
4041
color_mean /= 255
4142
color_orthogonal_pca_basis = bfm2009['texPC']
42-
color_pca_standard_deviations = bfm2009['texEV'] # Again, these are standard deviations, not eigenvalues
43-
color_pca_standard_deviations /= 255 # Divide the standard deviations by the same amount as the mean
43+
color_pca_standard_deviations = bfm2009['texEV'] # Again, these are standard deviations, not eigenvalues
44+
color_pca_standard_deviations /= 255 # Divide the standard deviations by the same amount as the mean
4445
color_pca_eigenvalues = np.square(color_pca_standard_deviations)
4546

46-
color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_eigenvalues, triangle_list.tolist())
47+
color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_eigenvalues,
48+
triangle_list.tolist())
4749

4850
# Construct and save the BFM2009 model in the eos format:
4951
model = eos.morphablemodel.MorphableModel(shape_model, color_model, vertex_definitions=None,

share/scripts/convert-bfm2017-to-eos.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,28 @@
2424
# Their basis is unit norm: np.linalg.norm(shape_pca_basis[:,0]) == ~1.0
2525
# And the basis vectors are orthogonal: np.dot(shape_pca_basis[:,0], shape_pca_basis[:,0]) == 1.0
2626
# np.dot(shape_pca_basis[:,0], shape_pca_basis[:,1]) == 1e-10
27-
shape_pca_variance = np.array(hf['shape/model/pcaVariance']) # the PCA variances are the eigenvectors
27+
shape_pca_variance = np.array(hf['shape/model/pcaVariance']) # the PCA variances are the eigenvectors
2828

2929
triangle_list = np.array(hf['shape/representer/cells'])
3030

31-
shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_variance, triangle_list.transpose().tolist())
31+
shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_variance,
32+
triangle_list.transpose().tolist())
3233

3334
# PCA colour model:
3435
color_mean = np.array(hf['color/model/mean'])
3536
color_orthogonal_pca_basis = np.array(hf['color/model/pcaBasis'])
3637
color_pca_variance = np.array(hf['color/model/pcaVariance'])
3738

38-
color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_variance, triangle_list.transpose().tolist())
39+
color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_variance,
40+
triangle_list.transpose().tolist())
3941

4042
# PCA expression model:
4143
expression_mean = np.array(hf['expression/model/mean'])
4244
expression_pca_basis = np.array(hf['expression/model/pcaBasis'])
4345
expression_pca_variance = np.array(hf['expression/model/pcaVariance'])
4446

45-
expression_model = eos.morphablemodel.PcaModel(expression_mean, expression_pca_basis, expression_pca_variance, triangle_list.transpose().tolist())
47+
expression_model = eos.morphablemodel.PcaModel(expression_mean, expression_pca_basis, expression_pca_variance,
48+
triangle_list.transpose().tolist())
4649

4750
# Construct and save an eos model from the BFM data:
4851
model = eos.morphablemodel.MorphableModel(shape_model, expression_model, color_model, vertex_definitions=None,

0 commit comments

Comments
 (0)