performancer on inference
This commit is contained in:
parent
94bef68fd7
commit
7a9c02d4dd
@ -10,6 +10,8 @@ import cv2
|
||||
import numpy as np
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from lib.helpers import time_this
|
||||
|
||||
if "--no-gpu" in sys.argv:
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
||||
|
||||
@ -37,8 +39,8 @@ else:
|
||||
|
||||
if "--no-tflite" not in sys.argv:
|
||||
try:
|
||||
Interpreter = tf.lite.Interpreter
|
||||
# from tflite_runtime.interpreter import Interpreter
|
||||
#Interpreter = tf.lite.Interpreter
|
||||
from tflite_runtime.interpreter import Interpreter
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
logging.exception(traceback.format_exc())
|
||||
|
||||
@ -335,6 +337,7 @@ class Vision(Component):
|
||||
self.log.info(f"initialized model {self.model!r} with mode {self.tf_mode!r}")
|
||||
self.loading_model_signal.emit({"status": "done"})
|
||||
|
||||
@time_this
|
||||
def check_features(self, frame, lock=True):
|
||||
if self.interpreter is not None and frame.shape != self.interpreter.get_input_details()[0]["shape"][1:3]:
|
||||
tensor = np.expand_dims(cv2.resize(frame, self.interpreter.get_input_details()[0]["shape"][1:3], interpolation=cv2.INTER_LINEAR), axis=0)
|
||||
@ -693,10 +696,7 @@ class Vision(Component):
|
||||
# VISION_CONSUMER TASK
|
||||
if consumable is None:
|
||||
return
|
||||
t1=time.time()
|
||||
detections = self.check_features(consumable["frame"])
|
||||
t2=time.time()
|
||||
print(f"detection time: {(t2-t1):.3f}")
|
||||
results = self.process_detections(detections)
|
||||
return {"detections": detections, "results": results}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user