mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-09-26 11:31:28 +08:00
update docs and add back benchmark
This commit is contained in:
20
benchmark.py
Normal file → Executable file
20
benchmark.py
Normal file → Executable 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")
|
Reference in New Issue
Block a user