Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions demos/face_recognition_demo/python/face_recognition_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.DEBUG, stream=sys.stdout)

DEVICE_KINDS = ['CPU', 'GPU', 'HETERO']
DEVICE_KINDS = ['CPU', 'GPU', 'NPU', 'AUTO', 'HETERO']


def build_argparser():
Expand Down Expand Up @@ -94,15 +94,18 @@ def build_argparser():
'reshaping. Example: 500 700.')

infer = parser.add_argument_group('Inference options')
infer.add_argument('-d_fd', default='CPU', choices=DEVICE_KINDS,
infer.add_argument('-d_fd', default='CPU',
help='Optional. Target device for Face Detection model. '
'Default value is CPU.')
infer.add_argument('-d_lm', default='CPU', choices=DEVICE_KINDS,
'Default value is CPU. Use HETERO:<dev1>,<dev2> or '
'AUTO:<dev1>,<dev2> for heterogeneous/automatic execution.')
infer.add_argument('-d_lm', default='CPU',
help='Optional. Target device for Facial Landmarks Detection '
'model. Default value is CPU.')
infer.add_argument('-d_reid', default='CPU', choices=DEVICE_KINDS,
'model. Default value is CPU. Use HETERO:<dev1>,<dev2> or '
'AUTO:<dev1>,<dev2> for heterogeneous/automatic execution.')
infer.add_argument('-d_reid', default='CPU',
help='Optional. Target device for Face Reidentification '
'model. Default value is CPU.')
'model. Default value is CPU. Use HETERO:<dev1>,<dev2> or '
'AUTO:<dev1>,<dev2> for heterogeneous/automatic execution.')
infer.add_argument('-v', '--verbose', action='store_true',
help='Optional. Be more verbose.')
infer.add_argument('-t_fd', metavar='[0..1]', type=float, default=0.6,
Expand Down Expand Up @@ -207,6 +210,10 @@ def center_crop(frame, crop_size):
def main():
args = build_argparser().parse_args()

for arg_name, device in [('-d_fd', args.d_fd), ('-d_lm', args.d_lm), ('-d_reid', args.d_reid)]:
if device == 'HETERO':
raise ValueError('{} requires sub-devices, e.g. HETERO:GPU,CPU'.format(arg_name))

cap = open_images_capture(args.input, args.loop)
frame_processor = FrameProcessor(args)

Expand Down
3 changes: 2 additions & 1 deletion demos/face_recognition_demo/python/ie_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self, core, model_path, model_type):

def deploy(self, device, max_requests=1):
self.max_requests = max_requests
compiled_model = self.core.compile_model(self.model, device)
config = {"PERFORMANCE_HINT": "THROUGHPUT"} if device.startswith('AUTO') else {}
compiled_model = self.core.compile_model(self.model, device, config)
self.output_tensor = compiled_model.outputs[0]
self.infer_queue = AsyncInferQueue(compiled_model, self.max_requests)
self.infer_queue.set_callback(self.completion_callback)
Expand Down