medusa.crop.bbox_crop
#
Module with a “crop model” which crops an image by creating a bounding box based on a set of existing (2D) landmarks.
Based on the implementation in DECA (see ../recon/flame/deca/license.md).
Module Contents#
- class medusa.crop.bbox_crop.BboxCropModel(lms_model_name='2d106det', output_size=(224, 224), device=DEVICE)[source]#
A model that crops an image by creating a bounding box based on a set of face landmarks; based on the implementation from DECA.
- Parameters:
name (str) – Name of the landmark model from Insightface that should be used; options are ‘2d106det’ (106 landmarks) or ‘1k3d68’ (68 landmarks)
output_size (tuple[int]) – Desired size of the cropped image
detector (BaseDetector) – A Medusa-based detector
device (str) – Either ‘cuda’ (GPU) or ‘cpu’
- forward(imgs)[source]#
Crops images to the desired size.
- Parameters:
imgs (str, Path, tuple, list, array_like, torch.tensor) – A path to an image, or a tuple/list of them, or already loaded images as a torch.tensor or numpy array
- Returns:
out_crop – Dictionary with cropping outputs; includes the keys “imgs_crop” (cropped images) and “crop_mat” (3x3 crop matrices)
- Return type:
dict