Use this notebook to verify the accuracy of a trained ArcFace model in ONNX format on the validation datasets.
The following packages need to be installed before proceeding:
sudo apt-get install protobuf-compiler libprotoc-dev(required for ONNX. This will work for any linux system. For detailed installation guidelines head over to ONNX documentation)
pip install onnx
pip install mxnet-cu90mkl --pre -U(tested on this version GPU, can use other versions.
--preindicates a pre build of MXNet which is required here for ONNX version compatibility.
-Uuninstalls any existing MXNet version allowing for a clean install)
pip install numpy
pip install matplotlib
pip install opencv-python
pip install scikit-learn
pip install easydict
pip install pickle
In order to do inference with a python script:
Verify that all dependencies are installed using the cell below. Continue if no errors encountered, warnings can be ignored.
load_bin()loads validation datasets
load_property()loads information like image size, number of identities from the property file in the dataset folder
class LFoldis used to split the data for K-fold crossvalidation
calculate_roc()computes accuracy on each fold of cross validation using
calculate_accuracy()computes the actual accuracy for test samples by thresholding the distance between embedding vectors of a test image pair and comparing the output with the ground truth for the pair
evaluate()splits embeddings into test pairs and computes accuracies using
test() takes a validation set
data_set and the MXNet model
mx_model as input and computes accuracies using
evaluate() on the set using
nfolds cross validation.
This is the main function and it loads the ONNX model, loads the validation datasets and computes the validation accuracies on the data according to the verification targets specified above. The accuracy for each target is displayed in the output of the cell.