update docs and add back benchmark

This commit is contained in:
Blake Blackshear
2020-02-22 08:59:16 -06:00
parent 6ef22cf578
commit e6892d66b8
6 changed files with 62 additions and 104 deletions

20
benchmark.py Normal file → Executable file
View File

@@ -1,20 +1,18 @@
import statistics
import numpy as np
from edgetpu.detection.engine import DetectionEngine
import time
from frigate.edgetpu import ObjectDetector
# Path to frozen detection graph. This is the actual model that is used for the object detection.
PATH_TO_CKPT = '/frozen_inference_graph.pb'
# Load the edgetpu engine and labels
engine = DetectionEngine(PATH_TO_CKPT)
object_detector = ObjectDetector()
frame = np.zeros((300,300,3), np.uint8)
flattened_frame = np.expand_dims(frame, axis=0).flatten()
input_frame = np.expand_dims(frame, axis=0)
detection_times = []
for x in range(0, 1000):
objects = engine.detect_with_input_tensor(flattened_frame, threshold=0.1, top_k=3)
detection_times.append(engine.get_inference_time())
for x in range(0, 100):
start = time.monotonic()
object_detector.detect_raw(input_frame)
detection_times.append(time.monotonic()-start)
print("Average inference time: " + str(statistics.mean(detection_times)))
print(f"Average inference time: {statistics.mean(detection_times)*1000:.2f}ms")