patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.92k stars 598 forks source link

Incompatible function arguments in fit_shape_and_pose in Python #262

Closed ria-kim closed 5 years ago

ria-kim commented 5 years ago
landmark_ids = list(map(str, range(1, 69))) # generates the numbers 1 to 68, as strings
image_width = img.shape[1]
image_height = img.shape[0]

model = eos.morphablemodel.load_model("/eos/share/sfm_shape_3448.bin")
blendshapes = eos.morphablemodel.load_blendshapes("/eos/share/expression_blendshapes_3448.bin")
landmark_mapper = eos.core.LandmarkMapper('/eos/share/ibug_to_sfm.txt')
edge_topology = eos.morphablemodel.load_edge_topology('/eos/share/sfm_3448_edge_topology.json')
contour_landmarks = eos.fitting.ContourLandmarks.load('/eos/share/ibug_to_sfm.txt')
model_contour = eos.fitting.ModelContour.load('/eos/share/sfm_model_contours.json')

(mesh, pose, shape_coeffs, blendshape_coeffs) = eos.fitting.fit_shape_and_pose(model, blendshapes,
    landmarks, landmark_ids, landmark_mapper,
    image_width, 
    image_height, 
    edge_topology, 
    contour_landmarks, 
    model_contour)

I've tried to run the demo in python, but it breaks when running the fit_shape_and_pose() at the line where there is the model_contour. Following is the error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-8-616e5640e835> in <module>()
     17 (mesh, pose, shape_coeffs, blendshape_coeffs) = eos.fitting.fit_shape_and_pose(morphablemodel_with_expressions,
     18     landmarks, landmark_mapper, image_width, image_height, edge_topology, contour_landmarks,
---> 19     model_contour)

fit_shape_and_pose(): incompatible function arguments. The following argument types are supported:
    1. (morphable_model: eos.morphablemodel.MorphableModel, landmarks: List[eos.core.Landmark], landmark_mapper: eos.core.LandmarkMapper, image_width: int, image_height: int, edge_topology: eos.morphablemodel.EdgeTopology, contour_landmarks: eos.fitting.ContourLandmarks, model_contour: eos.fitting.ModelContour, num_iterations: int = 5, num_shape_coefficients_to_fit: Optional[int] = None, lambda_identity: float = 30.0, num_expression_coefficients_to_fit: Optional[int] = None, lambda_expressions: Optional[float] = 30.0) -> Tuple[eos.core.Mesh, eos.fitting.RenderingParameters, List[float], List[float]]

I'm not sure why I'm getting this message, or what I would be able to do about this, since I'm just running the demo on an image I already have. I can provide more information if neccessary!

patrikhuber commented 5 years ago

Is it possible you're using an outdated demo.py file? I think there is no overload to fit_shape_and_pose anymore that takes blendshapes as a parameter, but you can check the documentation/headers. The expressions are integrated into the MorphableModel class. The latest demo.py reflects that by constructing a morphablemodel_with_expressions and passing that to fit_shape_and_pose.

I'm closing this, feel free to re-open if you're still having an issue or if that piece of code is really still wrong somewhere in the eos repo.

ria-kim commented 5 years ago

Thanks! Switching to the new demo.py worked great- thank you for such a prompt response~