https://github.com/BoyuanJiang/Age-Gender-Estimate-TF
0. Environment
ubuntu16.04
python3.6
tensorflow==1.10.0
dlib==19.8.1
opencv-python==4.1.0.25
matplotlib==3.3.1
imutils==0.4.3
numpy==1.19.2
pandas==1.1.2
scipy
scikit-learn
scikit-image
tqdm
1. Prepare and process data
https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/static/imdb_crop.tar,
https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/static/wiki_crop.tar。
To process data, first modify convert_to_records_multiCPU.py and replace line 120 with the following:
'file_name': _bytes_feature(bytes(file_name[index][0], 'utf-8'))}))
Then run the following to convert to tfrecord:
python convert_to_records_multiCPU.py --imdb --nworks 8
(This process is too long, I thought it was a mistake. More than 7 hours)
Take the /data/train directory as an example:
2. Prepare the pre-trained model
https://pan.baidu.com/s/1dFewgqH (about 80 M) , put it in the models directory according to the author's request.
cp ./weight_from_facenet_20170512-110547.zip ./models/
cd models/ && unzip ./weight_from_facenet_20170512-110547.zip && cd ..
3. Training
CUDA_VISIBLE_DEVICES=1 python train.py --lr 1e-3 --weight_decay 1e-5 --epoch 6 --batch_size 128 --keep_prob 0.8 --cuda
This is the tensorboard visualization result reproduced by the author.
4. Test
The author of the test part wrote in great detail:
https://github.com/BoyuanJiang/Age-Gender-Estimate-TF