Last active
September 14, 2021 19:32
-
-
Save hmahadik/cc50bc19bb9c7b3dc03591ba87240b1f to your computer and use it in GitHub Desktop.
Script to measure time taken to run an embeddings model using pyarmnn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cv_utils | |
import network_executor | |
import utils | |
import cv2 | |
import time | |
import sys | |
try: | |
model_path = os.path.join('/tmp', sys.argv[1]) | |
except: | |
print(f"Error: args missing. e.g. python3 pyarmnn_embed.py /tmp/mobilenet_v1_embed.tflite") | |
sys.exit(0) | |
backends = ["CpuAcc", "CpuRef"] | |
executor = network_executor.ArmnnNetworkExecutor(model_path, backends) | |
img = cv2.imread('/usr/local/share/deepvision/images/identities/person-0132/0132_c1s1_023176_00.jpg') | |
input_tensors = cv_utils.preprocess(img, executor.input_binding_info) | |
output_result = executor.run(input_tensors) | |
start = time.time() | |
output_result = executor.run(input_tensors) | |
end = time.time() | |
print(f"Output: {output_result}") | |
print(f"Embed time: {round((end-start)*1000,1)} ms") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First make sure that you clone
armnn
and cd into the right folder before running this gist: