Skip to content

Instantly share code, notes, and snippets.

@Tony607
Created May 4, 2019 07:45
Show Gist options
  • Save Tony607/05e74058dedfcfb5f4e8e025552207e5 to your computer and use it in GitHub Desktop.
Save Tony607/05e74058dedfcfb5f4e8e025552207e5 to your computer and use it in GitHub Desktop.
How to run Keras model on RK3399Pro | DLology
import time
times = []
# Run inference 20 times and do the average.
for i in range(20):
start_time = time.time()
# Use the API internal call directly.
results = rknn.rknn_base.inference(
inputs=[img], data_type="uint8", data_format="nhwc", outputs=None
)
# Alternatively, use the external API call.
# outputs = rknn.inference(inputs=[img])
delta = time.time() - start_time
times.append(delta)
# Calculate the average time for inference.
mean_delta = np.array(times).mean()
fps = 1 / mean_delta
print("average(sec):{:.3f},fps:{:.2f}".format(mean_delta, fps))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment