|
| 1 | +# FaceNet |
| 2 | + |
| 3 | +This document has instructions for how to run FaceNet for the |
| 4 | +following modes/precisions: |
| 5 | +* [FP32 inference](#fp32-inference-instructions) |
| 6 | + |
| 7 | +Benchmarking instructions and scripts for model training and inference |
| 8 | +other precisions are coming later. |
| 9 | + |
| 10 | +## FP32 Inference Instructions |
| 11 | + |
| 12 | +1. Clone the [davidsandberg/facenet](https://github.com/davidsandberg/facenet) repository: |
| 13 | + |
| 14 | +``` |
| 15 | +$ git clone https://github.com/davidsandberg/facenet.git |
| 16 | +``` |
| 17 | + |
| 18 | +2. Clone this [intelai/models](https://github.com/IntelAI/models) |
| 19 | +repository: |
| 20 | + |
| 21 | +``` |
| 22 | +$ git clone https://github.com/IntelAI/models.git |
| 23 | +``` |
| 24 | + |
| 25 | +3. Download and extract the pre-trained model. |
| 26 | +``` |
| 27 | +$ wget https://storage.googleapis.com/intel-optimized-tensorflow/models/facenet_fp32_pretrained_model.tar.gz |
| 28 | +$ tar -zxvf facenet_fp32_pretrained_model.tar.gz |
| 29 | +$ ls checkpoint |
| 30 | +model-20181015-153825.ckpt-90.data-00000-of-00001 model-20181015-153825.ckpt-90.index model-20181015-153825.meta |
| 31 | +``` |
| 32 | + |
| 33 | +4. If you would like to run FaceNet FP32 inference, you will need the aligned LFW dataset. |
| 34 | +Instructions for downloading the dataset and converting it can be found in the documentation |
| 35 | +[here](https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw), step 2 to step 4. |
| 36 | + |
| 37 | +5. Navigate to the `benchmarks` directory in your local clone of |
| 38 | +the [intelai/models](https://github.com/IntelAI/models) repo from step 2. |
| 39 | +The `launch_benchmark.py` script in the `benchmarks` directory is |
| 40 | +used for starting a benchmarking run in a optimized TensorFlow docker |
| 41 | +container. It has arguments to specify which model, framework, mode, |
| 42 | +precision, and docker image. |
| 43 | + |
| 44 | +Substitute in your own `--checkpoint` pretrained model file path (from step 3), |
| 45 | +and `--data-location` (from step 4). |
| 46 | + |
| 47 | +FaceNet can be run for latency benchmarking, throughput |
| 48 | +benchmarking, or accuracy. Use one of the following examples below, |
| 49 | +depending on your use case. |
| 50 | + |
| 51 | +* For latency (using `--batch-size 1`): |
| 52 | + |
| 53 | +``` |
| 54 | +python launch_benchmark.py \ |
| 55 | + --model-name facenet \ |
| 56 | + --precision fp32 \ |
| 57 | + --mode inference \ |
| 58 | + --framework tensorflow \ |
| 59 | + --batch-size 1 \ |
| 60 | + --socket-id 0 \ |
| 61 | + --checkpoint /home/<user>/checkpoints \ |
| 62 | + --data-location /home/<user>/dataset \ |
| 63 | + --model-source-dir /home/<user>/facenet/ \ |
| 64 | + --docker-image intelaipg/intel-optimized-tensorflow:latest-devel-mkl |
| 65 | +``` |
| 66 | +Example log tail when benchmarking for latency: |
| 67 | +``` |
| 68 | +Batch 979 elapsed Time 0.0297989845276 |
| 69 | +Batch 989 elapsed Time 0.029657125473 |
| 70 | +Batch 999 elapsed Time 0.0295519828796 |
| 71 | +Batchsize: 1 |
| 72 | +Time spent per BATCH: 30.1561 ms |
| 73 | +Total samples/sec: 33.1608 samples/s |
| 74 | +2019-03-28 21:00:02.725536: W tensorflow/core/kernels/queue_base.cc:277] _2_input_producer: Skipping cancelled enqueue attempt with queue not closed |
| 75 | +2019-03-28 21:00:02.725672: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 76 | +2019-03-28 21:00:02.725683: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 77 | +2019-03-28 21:00:02.725693: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 78 | +2019-03-28 21:00:02.725713: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 79 | +2019-03-28 21:00:02.725722: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 80 | +2019-03-28 21:00:02.725746: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 81 | +2019-03-28 21:00:02.725776: W tensorflow/core/kernels/queue_base.cc:277] _1_batch_join/fifo_queue: Skipping cancelled enqueue attempt with queue not closed |
| 82 | +lscpu_path_cmd = command -v lscpu |
| 83 | +lscpu located here: /usr/bin/lscpu |
| 84 | +Ran inference with batch size 1 |
| 85 | +Log location outside container: {--output-dir value}/benchmark_facenet_inference_fp32_20190328_205911.log |
| 86 | +``` |
| 87 | + |
| 88 | +* For throughput (using `--batch-size 100`): |
| 89 | + |
| 90 | +``` |
| 91 | +python launch_benchmark.py \ |
| 92 | + --model-name facenet \ |
| 93 | + --precision fp32 \ |
| 94 | + --mode inference \ |
| 95 | + --framework tensorflow \ |
| 96 | + --batch-size 100 \ |
| 97 | + --socket-id 0 \ |
| 98 | + --checkpoint /home/<user>/checkpoints \ |
| 99 | + --data-location /home/<user>/dataset \ |
| 100 | + --model-source-dir /home/<user>/facenet/ \ |
| 101 | + --docker-image intelaipg/intel-optimized-tensorflow:latest-devel-mkl |
| 102 | +``` |
| 103 | +Example log tail when benchmarking for throughput: |
| 104 | +``` |
| 105 | +Batch 219 elapsed Time 0.446497917175 |
| 106 | +Batch 229 elapsed Time 0.422048091888 |
| 107 | +Batch 239 elapsed Time 0.433968067169 |
| 108 | +Batchsize: 100 |
| 109 | +Time spent per BATCH: 434.5414 ms |
| 110 | +Total samples/sec: 230.1277 samples/s |
| 111 | +Accuracy: 0.98833+-0.00489 |
| 112 | +Validation rate: 0.96200+-0.01968 @ FAR=0.00100 |
| 113 | +Area Under Curve (AUC): 0.999 |
| 114 | +Equal Error Rate (EER): 0.011 |
| 115 | +lscpu_path_cmd = command -v lscpu |
| 116 | +lscpu located here: /usr/bin/lscpu |
| 117 | +Ran inference with batch size 100 |
| 118 | +Log location outside container: {--output-dir value}/benchmark_facenet_inference_fp32_20190329_002623.log |
| 119 | +``` |
| 120 | + |
| 121 | +* For accuracy (using `--accuracy-only`, and `--batch-size 100`): |
| 122 | + |
| 123 | +``` |
| 124 | +python launch_benchmark.py \ |
| 125 | + --model-name facenet \ |
| 126 | + --precision fp32 \ |
| 127 | + --mode inference \ |
| 128 | + --framework tensorflow \ |
| 129 | + --accuracy-only \ |
| 130 | + --batch-size 100 \ |
| 131 | + --socket-id 0 \ |
| 132 | + --checkpoint /home/<user>/checkpoints \ |
| 133 | + --data-location /home/<user>/dataset \ |
| 134 | + --model-source-dir /home/<user>/facenet/ \ |
| 135 | + --docker-image intelaipg/intel-optimized-tensorflow:latest-devel-mkl |
| 136 | +``` |
| 137 | +Example log tail when benchmarking for accuracy: |
| 138 | +``` |
| 139 | +Batch 219 elapsed Time 0.398629188538 |
| 140 | +Batch 229 elapsed Time 0.354953050613 |
| 141 | +Batch 239 elapsed Time 0.366483926773 |
| 142 | +Batchsize: 100 |
| 143 | +Time spent per BATCH: 388.5419 ms |
| 144 | +Total samples/sec: 257.3725 samples/s |
| 145 | +Accuracy: 0.98833+-0.00489 |
| 146 | +Validation rate: 0.96200+-0.01968 @ FAR=0.00100 |
| 147 | +Area Under Curve (AUC): 0.999 |
| 148 | +Equal Error Rate (EER): 0.011 |
| 149 | +lscpu_path_cmd = command -v lscpu |
| 150 | +lscpu located here: /usr/bin/lscpu |
| 151 | +Ran inference with batch size 100 |
| 152 | +Log location outside container: {--output-dir value}/benchmark_facenet_inference_fp32_20190328_214145.log |
| 153 | +``` |
| 154 | + |
| 155 | +Note that the `--verbose` or `--output-dir` flag can be added to any of the above commands |
| 156 | +to get additional debug output or change the default output location.. |
0 commit comments