Skip to content

Commit b05108d

Browse files
authored
Merge pull request #26 from huihuilong/feature/ui-infer-api
fix:指定onnxruntime SessionOptions的intra_op_num_threads,解决centos7上pthre…
2 parents 080081d + 27b4e86 commit b05108d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

service/image_infer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def __init__(self, model_path):
1414
self.cls_thresh = 0.5
1515
self.nms_thresh = 0.2
1616
self.model_path = model_path
17-
self.model_session = onnxruntime.InferenceSession(self.model_path)
17+
so = onnxruntime.SessionOptions()
18+
# 配置intra_op_num_threads为CPU核数时最佳
19+
so.intra_op_num_threads = 4
20+
self.model_session = onnxruntime.InferenceSession(self.model_path, sess_options=so)
1821

1922
def ui_infer(self, image_path):
2023
origin_img = cv2.imread(image_path)

0 commit comments

Comments
 (0)