Skip to content

fitrialif/Age-Gender-Emotion-Mobilenet

Repository files navigation

Age-Gender-Emotion-Mobilenet

Transfer learning for age, gender and emotion classifications on mobilenet architecture in a single feed-forward!

Requirements

pip3 install numpy scipy tensorflow

How-to Prepare Datasets

  1. Download this emotion dataset, https://drive.google.com/open?id=1V9fy_Me9ZjmMTJoTWz0L8AUdIW5k35bE, unzip in current directory
  2. Download pretrained mobilenet V2, https://storage.googleapis.com/mobilenet_v2/checkpoints/mobilenet_v2_1.0_224.tgz, and unzip in current directory
  3. Download this age and gender dataset, https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/static/wiki_crop.tar, unzip in current directory
  4. run prepare_dataset.ipynb using Jupyter Notebook
  5. run,
mkdir crop
python3 augmentation.py

How-to Train

  1. Run jupyter notebook,
jupyter notebook
  1. run emotion-transfer-learning.ipynb, you can check the batch size and epoch inside the notebook.
  2. run age-gender-transfer-learning.ipynb, you can check the batch and epoch inside the notebook.
  3. You can check tensorboard during training session,
tensorboard --logdir=./logs

To test on live camera

python3 live.py

How-to use tensorflow serving

  1. run,
python3 save-tf-serving.py
  1. run,
tensorflow_model_server --port=9000 --model_name=mobilenet --model_base_path=serving/versions
  1. run client-serving.ipynb
img = imread('test/another-husein.jpg')
request.inputs['image'].CopyFrom(
  tf.contrib.util.make_tensor_proto(img.astype(dtype=np.float32), shape=img.shape))
result_future = stub.Predict(request, 30.)
print(label_genders[np.argmax(result_future.outputs['gender'].float_val)])
# male
print(label_emotions[np.argmax(result_future.outputs['emotion'].float_val)])
# surprise
print(result_future.outputs['age'].float_val[0]-9)
# 22.0

Results

alt text

alt text

Accuracy gender during training

alt text

Entropy gender during training

alt text

Absolute loss age during training

alt text

I able to get 17 fps on GTX 970M, while CPU around 8 fps.

About

Transfer learning for age, gender and emotion classifications on mobilenet architecture in a single feed-forward!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published