frigate/benchmark.py

18 lines
464 B
Python
Raw Normal View History

2019-06-04 21:38:41 -05:00
import statistics
import numpy as np
2020-02-22 08:59:16 -06:00
import time
from frigate.edgetpu import ObjectDetector
2019-06-04 21:38:41 -05:00
2020-02-22 08:59:16 -06:00
object_detector = ObjectDetector()
2019-06-04 21:38:41 -05:00
frame = np.zeros((300,300,3), np.uint8)
2020-02-22 08:59:16 -06:00
input_frame = np.expand_dims(frame, axis=0)
2019-06-04 21:38:41 -05:00
detection_times = []
2020-02-22 08:59:16 -06:00
for x in range(0, 100):
start = time.monotonic()
object_detector.detect_raw(input_frame)
detection_times.append(time.monotonic()-start)
2019-06-04 21:38:41 -05:00
2020-02-22 08:59:16 -06:00
print(f"Average inference time: {statistics.mean(detection_times)*1000:.2f}ms")