参考:
https://github.com/yu4u/age-gender-estimation
0.环境
ubuntu16.04
python3.6
cuda10.1
tensorflow-gpu==2.3.0
absl-py==0.11.0
astunparse==1.6.3
cachetools==4.1.1
certifi==2020.12.5
chardet==3.0.4
cmake==3.18.4.post1
dataclasses==0.8
dlib==19.21.1
gast==0.3.3
google-auth==1.23.0
google-auth-oauthlib==0.4.2
google-pasta==0.2.0
grpcio==1.34.0
h5py==2.10.0
idna==2.10
importlib-metadata==3.1.1
Keras-Preprocessing==1.1.2
Markdown==3.3.3
numpy==1.18.5
oauthlib==3.1.0
omegaconf==2.0.5
opencv-python==4.1.0.25
opt-einsum==3.3.0
protobuf==3.14.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycurl==7.43.0
pygobject==3.20.0
python-apt==1.1.0b1+ubuntu0.16.4.10
PyYAML==5.3.1
requests==2.25.0
requests-oauthlib==1.3.0
rsa==4.6
scipy==1.4.1
six==1.15.0
tensorboard==2.4.0
tensorboard-plugin-wit==1.7.0
tensorflow-estimator==2.3.0
termcolor==1.1.0
typing-extensions==3.7.4.3
unattended-upgrades==0.1
urllib3==1.26.2
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.4.0
pandas
scikit-learn
hydra
hydra-core
albumentations
tqdm
环境用的tensorflow-v2.3.0,本来在1.12.0上调试好了,不过模型调用上起不来。尝试编译等等一系列操作。受到毒打后,终于向tensorflow-v2.3.0屈服了。
1.demo
python demo.py
或者指定目录下图片进行识别:
python demo.py --weight_file ./pretrained_models/EfficientNetB3_224_weights.11-3.44.hdf5 --image_dir ./data/imdb_crop/00
自己设置下gpu的话,大概推理使用1G以内的GPU大小吧。
2.训练
python train.py
训练大概使用9G左右的GPU大小。
3.测试
按照https://github.com/yu4u/age-gender-estimation/blob/master/appa-real,下载与准备数据,测试:
python evaluate_appa_real.py --weight_file ./checkpoint/EfficientNetB3_224_weights.14-3.45.hdf5