diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-01-17 15:11:47 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-01-17 15:11:47 +0100 |
| commit | 85ae432fb6c6c17292b319bca068e46a4ea81eb3 (patch) | |
| tree | 4d0270fac0fdc7c1c1333af9c4bb82c6eb00669d /megapixels/app/processors/face_beauty.py | |
| parent | c293006ba43944ffeb4dcab17b2256f3a5491a36 (diff) | |
| parent | 03ad11fb2a3dcd425d50167b15d72d4e0ef536a2 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'megapixels/app/processors/face_beauty.py')
| -rw-r--r-- | megapixels/app/processors/face_beauty.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/megapixels/app/processors/face_beauty.py b/megapixels/app/processors/face_beauty.py index a01c6834..e2d54c98 100644 --- a/megapixels/app/processors/face_beauty.py +++ b/megapixels/app/processors/face_beauty.py @@ -1,3 +1,7 @@ +""" +https://github.com/ustcqidi/BeautyPredict +""" + import sys import os from os.path import join @@ -45,18 +49,15 @@ class FaceBeauty: self.model.load_weights(fp_model) - def beauty(self, im, bbox_dim): + def beauty(self, im, bbox_norm): '''Predicts facial "beauty" score based on SCUT-FBP attractiveness labels :param im: (numpy.ndarray) BGR image :param bbox_dim: (BBox) dimensioned BBox :returns (float) 0.0-1.0 with 1 being most attractive ''' - - face = bbox_dim.to_xyxy() - self.log.debug(f'face: {face}') - - cropped_im = im[face[1]:face[3], face[0]:face[2]] - + dim = im.shape[:2][::-1] + roi = bbox_norm.to_dim(dim).to_xyxy() + cropped_im = im[roi[1]:roi[3], roi[0]:roi[2]] im_resized = cv.resize(cropped_im, (224, 224)) # force size im_norm = np.array([(im_resized - 127.5) / 127.5]) # subtract mean |
