def test(model, model_type, image): # Synchronous Test counter = 0 try: # Load IE separately to check InferRequest latency exec_net, input_shape = load_to_IE(model, CPU_EXTENSION) result = perform_inference(exec_net, "S", image, input_shape) output_blob = next(iter(exec_net.outputs)) # Check for matching output shape to expected assert result[output_blob].shape == OUTPUT_SHAPES[model_type][ output_blob] # Check latency is > 0; i.e. a request occurred assert exec_net.requests[0].latency > 0.0 counter += 1 except: print("Synchronous Inference failed for {} Model.".format(model_type)) # Asynchronous Test try: # Load IE separately to check InferRequest latency exec_net, input_shape = load_to_IE(model, CPU_EXTENSION) exec_net = perform_inference(exec_net, "A", image, input_shape) output_blob = next(iter(exec_net.outputs)) # Check for matching output shape to expected assert exec_net.requests[0].outputs[ output_blob].shape == OUTPUT_SHAPES[model_type][output_blob] # Check latency is > 0; i.e. a request occurred assert exec_net.requests[0].latency > 0.0 counter += 1 except: print("Asynchronous Inference failed for {} Model.".format(model_type)) return counter
def main(): args = get_args() exec_net, input_shape = load_to_IE(args.m, CPU_EXTENSION) perform_inference(exec_net, args.r, args.i, input_shape)
def main(): args = get_args() exec_net, input_shape = load_to_IE(args.m, False) perform_inference(exec_net, args.r, args.i, input_shape)