커뮤니티
Python/TensorFlow
제목:    Gender Age Estimator
  585   김윤중

Agenda

  • Generate dataset of face/face with mask images, using 68 landmark detection.
  • Agender(age gender) model  building for face/face with mask 
  • Train agender model
  • Create application of agender model.

Summary of estimation models of age and gender

  • https://github.com/diovisgood/agender
  • samples
    • Accuracy
      • ResNet50 by Youness Mansar    link    link    MIT    Keras/TensorFlow    224x224x3    gender: one number, age: 8 classes    ~100Mb    NO
      • ConvNet by Sefik Ilkin Serengil    link    link    unspecified    Keras/TensorFlow    224x224x3    gender: 1 number, age: 101 class    553Mb, 514Mb    YES
      • ConvNet by Chengwei Zhang    link    link    unspecified    Keras/TensorFlow    64x64x3    gender: 1 number, age: 101 class    186Mb    YES
      • ConvNet by Yusuke Uchida    None    link    MIT    Keras/TensorFlow    32x32x3    gender: 1 number, age: 101 class    187Mb    YES
      •  
    • Real time
      • SSR-Net (original)    link    link    Apache License 2.0    Keras/TensorFlow    64x64x3    gender: one number, age: one number    0.32Mb    YES
      • ConvNet by Gil Levi and Tal Hassner    link    link    as is    Caffe    256x256x3    gender: 2 classses, age: 8 classes    43.5Mb, 43.5Mb    YES
    • SSR-Net: A Compact Soft Stagewise Regression Network for Age Estimation
      • by Tsun-Yi Yang, Yi-Hsuan Huang, Yen-Yu Lin, Pi-Cheng Hsiu, Yung-Yu Chuang.
      • Source code: https://github.com/shamangary/SSR-Net
      • Third party source code: https://github.com/shamangary/SSR-Net
      • License: Apache License 2.0
      • Framework: Keras/TensorFlow
      • Input: RGB images 64x64x3
      • Output:
        • gender: one number in range [0..1], where 0 = Female, 1 = Male.
        • age: one number
      • Model weights size:
        • gender0.32 Mb,
        • age0.32 Mb,
      • Pre-trained model available: YES
      • Last models update: Apr 2018

 

Agender Project for the real-time estimation of age and gender

  • A small demo project to try and test OpenCV library and also implement on-the-fly face detection, age and gender estimation using pre-trained models.
  •  https://github.com/diovisgood/agender
  • used two such models for real-time estimation of age and gender using only average CPU:
    • SSR-Net by Tsun-Yi Yang, Yi-Hsuan Huang, Yen-Yu Lin, Pi-Cheng Hsiu, Yung-Yu Chuang.
    • ConvNet by Gil Levi and Tal Hassner.
  • processes
    1. Get a smaller resized frame. As it is faster to process small images and this merely does not affect quality.
    2. Find faces/faces with mask on a small frame .
      • HARR
        • face_cascade = cv.CascadeClassifier('face_haar/haarcascade_frontalface_alt.xml') 
          gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
          detections = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)
      • trained cnn
        • face_net = cv.dnn.readNetFromTensorflow('face_net/opencv_face_detector_uint8.pb', 'face_net/opencv_face_detector.pbtxt')
          blob = cv.dnn.blobFromImage(img, 1.0, (300, 300), mean=(104, 117, 123), swapRB=True, crop=False)    
          face_net.setInput(blob)
          detections = face_net.forward()
    3. Use faces coordinates of a small frame to extract faces patches from original (big) frame.
    4. Convert and adjust faces patches to a format that model expects. Construct a blob with all faces.
    5. Pass a blob of faces through model(s) to get predicted genders and ages for all faces.
      • SRR net
        • gender_net = SSR_net_general(face_size, stage_num, lambda_local, lambda_d)()
        • gender_net.load_weights('age_gender_ssrnet/ssrnet_gender_3_3_3_64_1.0_1.0.h5') 
        • blob = np.empty((len(faces), face_size, face_size, 3))
        • genders = gender_net.predict(blob)
        • ages = age_net.predict(blob)
      • ConvNet by Gil Levi and Tal Hassner with Caffe
        • blob = cv.dnn.blobFromImages(faces, scalefactor=1.0, size=(227, 227),
                   mean=(78.4263377603, 87.7689143744, 114.895847746),
                   swapRB=False)
        • gender_net.setInput(blob)
        • genders = gender_net.forward()
        • age_net.setInput(blob)
        • ages = age_net.forward()
    6. Draw a rectangle around each face and a label with estimated gender and age.