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