Skip to content

Commit 1264cc2

Browse files
committed
Changed gaze tracking to always use single thread to avoid excessive CPU usage.
1 parent 44d97a9 commit 1264cc2

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tracker.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def worker_thread(session, frame, input, crop_info, queue, input_name, idx, trac
140140
conf, lms = tracker.landmarks(output[0], crop_info)
141141
if conf > tracker.threshold:
142142
try:
143-
eye_state = tracker.get_eye_state(frame, lms, single=True)
143+
eye_state = tracker.get_eye_state(frame, lms)
144144
except:
145145
eye_state = [(1.0, 0.0, 0.0, 0.0), (1.0, 0.0, 0.0, 0.0)]
146146
queue.put((session, conf, (lms, eye_state), crop_info, idx))
@@ -548,14 +548,12 @@ def __init__(self, width, height, model_type=3, detection_threshold=0.6, thresho
548548
self.input_name = self.session.get_inputs()[0].name
549549

550550
options = onnxruntime.SessionOptions()
551-
options.inter_op_num_threads = 1
552-
options.intra_op_num_threads = max(max_threads,4)
551+
#options.intra_op_num_threads = max(max_threads,4)
552+
options.intra_op_num_threads = 1
553553
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
554554
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
555555
options.log_severity_level = 3
556556
self.gaze_model = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_gaze32_split_opt.onnx"), sess_options=options)
557-
options.intra_op_num_threads = 1
558-
self.gaze_model_single = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_gaze32_split_opt.onnx"), sess_options=options)
559557

560558
self.detection = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_detection_opt.onnx"), sess_options=options)
561559
self.faces = []
@@ -922,7 +920,7 @@ def extract_face(self, frame, lms):
922920
frame = frame[y1:y2, x1:x2]
923921
return frame, lms, offset
924922

925-
def get_eye_state(self, frame, lms, single=False):
923+
def get_eye_state(self, frame, lms):
926924
if self.no_gaze:
927925
return [(1.0, 0.0, 0.0, 0.0), (1.0, 0.0, 0.0, 0.0)]
928926
lms = np.array(lms)
@@ -938,10 +936,7 @@ def get_eye_state(self, frame, lms, single=False):
938936
return [(1.0, 0.0, 0.0, 0.0), (1.0, 0.0, 0.0, 0.0)]
939937
both_eyes = np.concatenate((right_eye, left_eye))
940938
results = None
941-
if single:
942-
results = self.gaze_model_single.run([], {self.input_name: both_eyes})
943-
else:
944-
results = self.gaze_model.run([], {self.input_name: both_eyes})
939+
results = self.gaze_model.run([], {self.input_name: both_eyes})
945940
open = [0, 0]
946941
open[0] = 1#results[1][0].argmax()
947942
open[1] = 1#results[1][1].argmax()

0 commit comments

Comments
 (0)