Skip to content

Commit 6c22317

Browse files
committed
add npu support
1 parent 01a34cd commit 6c22317

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

examples/person_detection/scrfd_person.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
def detect_person(img, detector):
1313
bboxes, kpss = detector.detect(img)
14-
bboxes = np.round(bboxes[:,:4]).astype(np.int)
15-
kpss = np.round(kpss).astype(np.int)
14+
bboxes = np.round(bboxes[:,:4]).astype(np.int32)
15+
kpss = np.round(kpss).astype(np.int32)
1616
kpss[:,:,0] = np.clip(kpss[:,:,0], 0, img.shape[1])
1717
kpss[:,:,1] = np.clip(kpss[:,:,1], 0, img.shape[0])
1818
vbboxes = bboxes.copy()

python-package/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For ``insightface<=0.1.5``, we use MXNet as inference backend.
1414

1515
Starting from insightface>=0.2, we use onnxruntime as inference backend.
1616

17-
You have to install ``onnxruntime-gpu`` manually to enable GPU inference, or install ``onnxruntime`` to use CPU only inference.
17+
You have to install ``onnxruntime-gpu`` manually to enable GPU inference, or ``pip install onnxruntime-cann`` manually to enable NPU inference, or install ``onnxruntime`` to use CPU only inference.
1818

1919
## Change Log
2020

@@ -54,7 +54,7 @@ import insightface
5454
from insightface.app import FaceAnalysis
5555
from insightface.data import get_image as ins_get_image
5656
57-
app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
57+
app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CANNExecutionProvider', 'CPUExecutionProvider'])
5858
app.prepare(ctx_id=0, det_size=(640, 640))
5959
img = ins_get_image('t1')
6060
faces = app.get(img)

python-package/insightface/model_zoo/model_zoo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def find_onnx_file(dir_path):
6868
return paths[-1]
6969

7070
def get_default_providers():
71-
return ['CUDAExecutionProvider', 'CPUExecutionProvider']
71+
return ['CUDAExecutionProvider', 'CANNExecutionProvider', 'CPUExecutionProvider']
7272

7373
def get_default_provider_options():
7474
return None

web-demos/src_recognition/arcface_onnx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, model_file=None, session=None):
4242
self.input_std = input_std
4343
#print('input mean and std:', self.input_mean, self.input_std)
4444
if self.session is None:
45-
self.session = onnxruntime.InferenceSession(self.model_file, providers=['CUDAExecutionProvider'])
45+
self.session = onnxruntime.InferenceSession(self.model_file, providers=['CUDAExecutionProvider', 'CANNExecutionProvider'])
4646
input_cfg = self.session.get_inputs()[0]
4747
input_shape = input_cfg.shape
4848
input_name = input_cfg.name

web-demos/src_recognition/scrfd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, model_file=None, session=None):
7474
if self.session is None:
7575
assert self.model_file is not None
7676
assert osp.exists(self.model_file)
77-
self.session = onnxruntime.InferenceSession(self.model_file, providers=['CUDAExecutionProvider'])
77+
self.session = onnxruntime.InferenceSession(self.model_file, providers=['CUDAExecutionProvider', 'CANNExecutionProvider'])
7878
self.center_cache = {}
7979
self.nms_thresh = 0.4
8080
self.det_thresh = 0.5

0 commit comments

Comments
 (0)