Transfer learning for age, gender and emotion classifications on mobilenet architecture in a single feed-forward!
pip3 install numpy scipy tensorflow
- Download this emotion dataset, https://drive.google.com/open?id=1V9fy_Me9ZjmMTJoTWz0L8AUdIW5k35bE, unzip in current directory
- Download pretrained mobilenet V2, https://storage.googleapis.com/mobilenet_v2/checkpoints/mobilenet_v2_1.0_224.tgz, and unzip in current directory
- Download this age and gender dataset, https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/static/wiki_crop.tar, unzip in current directory
- run prepare_dataset.ipynb using Jupyter Notebook
- run,
mkdir crop
python3 augmentation.py
- Run jupyter notebook,
jupyter notebook
- run emotion-transfer-learning.ipynb, you can check the batch size and epoch inside the notebook.
- run age-gender-transfer-learning.ipynb, you can check the batch and epoch inside the notebook.
- You can check tensorboard during training session,
tensorboard --logdir=./logs
python3 live.py
- run,
python3 save-tf-serving.py
- run,
tensorflow_model_server --port=9000 --model_name=mobilenet --model_base_path=serving/versions
- 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
You can download pretrained age-emotion-gender here, https://drive.google.com/file/d/1t--oS5G4ErLcrFcItEm-cBg8NGfssixs/view?usp=sharing
Accuracy gender during training
Entropy gender during training
Absolute loss age during training
I able to get 17 fps on GTX 970M, while CPU around 8 fps.