diff options
| -rw-r--r-- | client/faceAnalysis/faceAnalysis.result.js | 7 | ||||
| -rw-r--r-- | megapixels/app/server/tasks/demo.py | 61 |
2 files changed, 59 insertions, 9 deletions
diff --git a/client/faceAnalysis/faceAnalysis.result.js b/client/faceAnalysis/faceAnalysis.result.js index 62ff174c..1c8a2ffb 100644 --- a/client/faceAnalysis/faceAnalysis.result.js +++ b/client/faceAnalysis/faceAnalysis.result.js @@ -64,7 +64,10 @@ class FaceAnalysisResult extends Component { } console.log(data.data) - const results = ['blur_fn', 'points_3d_68', 'landmarks_3d_68', 'landmarks_2d_68', 'pose'].map(tag => { + const results = [ + 'blur_fn', 'points_3d_68', 'landmarks_3d_68', 'landmarks_2d_68', 'pose', + 'age_real', 'age_apparent', 'gender' + ].map(tag => { if (tag in data.data) { const { title, url } = data.data[tag] return ( @@ -79,7 +82,7 @@ class FaceAnalysisResult extends Component { return ( <div> - {!(step && total && message) ? '' : (<span>{step} / {total}: {message}</span>)} + {!(step && total && message) ? '' : (<span>Step {step} / {total}: {message}</span>)} <div className='results'> {results} </div> diff --git a/megapixels/app/server/tasks/demo.py b/megapixels/app/server/tasks/demo.py index 38a0a3c2..5143dd56 100644 --- a/megapixels/app/server/tasks/demo.py +++ b/megapixels/app/server/tasks/demo.py @@ -24,7 +24,7 @@ def demo_task(self, uuid_name, fn): from app.utils import logger_utils, file_utils, im_utils, display_utils, draw_utils from app.utils import plot_utils - from app.processors import face_detector, face_landmarks + from app.processors import face_detector, face_landmarks, face_age_gender from app.models.data_store import DataStore # TODO add selective testing @@ -175,14 +175,61 @@ def demo_task(self, uuid_name, fn): save_image('pose', 'Pose', im_pose) # ---------------------------------------------------------------------------- - # generate pose from 68 point 2D landmarks + # age - step('Done') + # real + age_real_predictor = face_age_gender.FaceAgeReal() + st = time.time() + age_real = age_real_predictor.predict(im_resized, bbox_dim) + log.info(f'age real took: {(time.time()-st)/1000:.5f}s') + + # apparent + age_apparent_predictor = face_age_gender.FaceAgeApparent() + st = time.time() + age_apparent = age_apparent_predictor.predict(im_resized, bbox_dim) + log.info(f'age apparent took: {(time.time()-st)/1000:.5f}s') + + # gender + gender_predictor = face_age_gender.FaceGender() + st = time.time() + gender = gender_predictor.predict(im_resized, bbox_dim) + log.info(f'gender took: {(time.time()-st)/1000:.5f}s') + + # ---------------------------------------------------------------------------- + # output + + log.info(f'Face coords: {bbox_dim} face') + log.info(f'Age (real): {(age_real):.2f}') + log.info(f'Age (apparent): {(age_apparent):.2f}') + log.info(f'gender: {gender}') + + + # ---------------------------------------------------------------------------- + # draw + + # draw real age + im_age_real = im_resized.copy() + draw_utils.draw_bbox(im_age_real, bbox_dim) + txt = f'{(age_real):.2f}' + draw_utils.draw_text(im_age_real, bbox_dim.pt_tl, txt) - # done - # self.log.debug('Add age real') - # self.log.debug('Add age apparent') - # self.log.debug('Add gender') + # apparent age + im_age_apparent = im_resized.copy() + draw_utils.draw_bbox(im_age_apparent, bbox_dim) + txt = f'{(age_apparent):.2f}' + draw_utils.draw_text(im_age_apparent, bbox_dim.pt_tl, txt) + + # gender + im_gender = im_resized.copy() + draw_utils.draw_bbox(im_age_apparent, bbox_dim) + txt = f"M: {gender['m']:.2f}, F: {gender['f']:.2f}" + draw_utils.draw_text(im_gender, (10, dim[1]-20), txt) + + save_image('age_real', 'Age (Real)', im_age_real) + save_image('age_apparent', 'Age (Apparent)', im_age_apparent) + save_image('gender', 'Gender', im_gender) + + step('Done') # # 3DDFA # self.log.debug('Add depth') |
