>>> import mindface
>>> from models import resnet50, mobilenet025
# Create the backbone
>>> backbone = mobilenet025(1001)
# Create the model object
>>> network = RetinaFace(phase='train', backbone=backbone, in_channel=in_channel, out_channel=out_channel)
# Validate its accuracy
>>> !python eval.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt
{'Easy Val AP': 0.9446, 'Medium Val AP': 0.9364, 'Hard Val AP': 0.8942}
Image infer demo
Infer the input image with a pretrained SoTA model,
>>> !python infer.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml \
--checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
The inference results by using our pre-trained weights are shown in the following figure.
It is easy to train your model on standard datasets or your own dataset with MindFace. Model training, transfer learning, or evaluaiton can be done using one or a few line of code with flexible configuration.
Training
It is easy to train your model using train.py
, where the training strategy (e.g., augmentation, LR scheduling) can be configured with external arguments or a yaml config file.
python mindface/detection/train.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml
Distributed Training
To run in distributed mode, openmpi is required to install.
export CUDA_VISIBLE_DEVICES=0,1,2,3 # 4 GPUs
mpirun -n 4 python mindface/detection/train.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml
note: if your device is Ascend, please set the "device_target" in the config file to "Ascend".
Validation
It is easy to validate a trained model with eval.py
.
# validate a trained checkpoint
python eval.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》