Merge pull request #37 from yamichan420/master
specify list of providers for onnxruntime.InferenceSession()
This commit is contained in:
commit
da3eaadfb9
2 changed files with 10 additions and 5 deletions
|
|
@ -66,7 +66,8 @@ class RetinaFaceDetector():
|
||||||
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
||||||
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
||||||
options.log_severity_level = 3
|
options.log_severity_level = 3
|
||||||
self.session = onnxruntime.InferenceSession(model_path, sess_options=options)
|
providersList = onnxruntime.capi._pybind_state.get_available_providers()
|
||||||
|
self.session = onnxruntime.InferenceSession(model_path, sess_options=options, providers=providersList)
|
||||||
self.res_w, self.res_h = res
|
self.res_w, self.res_h = res
|
||||||
with open(json_path, "r") as prior_file:
|
with open(json_path, "r") as prior_file:
|
||||||
self.priorbox = np.array(json.loads(prior_file.read()))
|
self.priorbox = np.array(json.loads(prior_file.read()))
|
||||||
|
|
|
||||||
12
tracker.py
12
tracker.py
|
|
@ -527,8 +527,12 @@ class Tracker():
|
||||||
self.retinaface_scan = RetinaFaceDetector(model_path=os.path.join(model_base_path, "retinaface_640x640_opt.onnx"), json_path=os.path.join(model_base_path, "priorbox_640x640.json"), threads=2, top_k=max_faces, res=(640, 640))
|
self.retinaface_scan = RetinaFaceDetector(model_path=os.path.join(model_base_path, "retinaface_640x640_opt.onnx"), json_path=os.path.join(model_base_path, "priorbox_640x640.json"), threads=2, top_k=max_faces, res=(640, 640))
|
||||||
self.use_retinaface = use_retinaface
|
self.use_retinaface = use_retinaface
|
||||||
|
|
||||||
|
# OTR 1.9 and later requires specifying providers
|
||||||
|
# explicitly as an argument in InferenceSession()
|
||||||
|
providersList = onnxruntime.capi._pybind_state.get_available_providers()
|
||||||
|
|
||||||
# Single face instance with multiple threads
|
# Single face instance with multiple threads
|
||||||
self.session = onnxruntime.InferenceSession(os.path.join(model_base_path, model), sess_options=options)
|
self.session = onnxruntime.InferenceSession(os.path.join(model_base_path, model), sess_options=options, providers=providersList)
|
||||||
|
|
||||||
# Multiple faces with single threads
|
# Multiple faces with single threads
|
||||||
self.sessions = []
|
self.sessions = []
|
||||||
|
|
@ -544,7 +548,7 @@ class Tracker():
|
||||||
options.intra_op_num_threads += 1
|
options.intra_op_num_threads += 1
|
||||||
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
||||||
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
||||||
self.sessions.append(onnxruntime.InferenceSession(os.path.join(model_base_path, model), sess_options=options))
|
self.sessions.append(onnxruntime.InferenceSession(os.path.join(model_base_path, model), sess_options=options, providers=providersList))
|
||||||
self.input_name = self.session.get_inputs()[0].name
|
self.input_name = self.session.get_inputs()[0].name
|
||||||
|
|
||||||
options = onnxruntime.SessionOptions()
|
options = onnxruntime.SessionOptions()
|
||||||
|
|
@ -553,9 +557,9 @@ class Tracker():
|
||||||
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
options.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL
|
||||||
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
||||||
options.log_severity_level = 3
|
options.log_severity_level = 3
|
||||||
self.gaze_model = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_gaze32_split_opt.onnx"), sess_options=options)
|
self.gaze_model = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_gaze32_split_opt.onnx"), sess_options=options, providers=providersList)
|
||||||
|
|
||||||
self.detection = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_detection_opt.onnx"), sess_options=options)
|
self.detection = onnxruntime.InferenceSession(os.path.join(model_base_path, "mnv3_detection_opt.onnx"), sess_options=options, providers=providersList)
|
||||||
self.faces = []
|
self.faces = []
|
||||||
|
|
||||||
# Image normalization constants
|
# Image normalization constants
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue