#!/usr/bin/env python
"""
- Copyright (c) 2018 Intel Corporation
+ Copyright (C) 2018-2019 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
from __future__ import print_function
import sys
import os
-from argparse import ArgumentParser
+from argparse import ArgumentParser, SUPPRESS
import cv2
import numpy as np
import logging as log
def build_argparser():
- parser = ArgumentParser()
- parser.add_argument("-m", "--model", help="Path to an .xml file with a trained model.", required=True, type=str)
- parser.add_argument("-i", "--input", help="Path to a folder with images or path to an image files", required=True,
- type=str, nargs="+")
- parser.add_argument("-l", "--cpu_extension",
- help="MKLDNN (CPU)-targeted custom layers.Absolute path to a shared library with the kernels "
- "impl.", type=str, default=None)
- parser.add_argument("-pp", "--plugin_dir", help="Path to a plugin folder", type=str, default=None)
- parser.add_argument("-d", "--device",
- help="Specify the target device to infer on; CPU, GPU, FPGA or MYRIAD is acceptable. Sample "
- "will look for a suitable plugin for device specified (CPU by default)", default="CPU",
- type=str)
- parser.add_argument("-nt", "--number_top", help="Number of top results", default=10, type=int)
- parser.add_argument("-ni", "--number_iter", help="Number of inference iterations", default=1, type=int)
- parser.add_argument("--mean_val_r", "-mean_val_r",
- help="Mean value of red chanel for mean value subtraction in postprocessing ", default=0,
- type=float)
- parser.add_argument("--mean_val_g", "-mean_val_g",
- help="Mean value of green chanel for mean value subtraction in postprocessing ", default=0,
- type=float)
- parser.add_argument("--mean_val_b", "-mean_val_b",
- help="Mean value of blue chanel for mean value subtraction in postprocessing ", default=0,
- type=float)
- parser.add_argument("-pc", "--perf_counts", help="Report performance counters", default=False, action="store_true")
+ parser = ArgumentParser(add_help=False)
+ args = parser.add_argument_group('Options')
+ args.add_argument('-h', '--help', action='help', default=SUPPRESS, help='Show this help message and exit.')
+ args.add_argument("-m", "--model", help="Path to an .xml file with a trained model.", required=True, type=str)
+ args.add_argument("-i", "--input", help="Path to a folder with images or path to an image files", required=True,
+ type=str, nargs="+")
+ args.add_argument("-l", "--cpu_extension",
+ help="Optional. Required for CPU custom layers. "
+ "Absolute MKLDNN (CPU)-targeted custom layers. Absolute path to a shared library with the "
+ "kernels implementations", type=str, default=None)
+ args.add_argument("-pp", "--plugin_dir", help="Path to a plugin folder", type=str, default=None)
+ args.add_argument("-d", "--device",
+ help="Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD is acceptable. Sample "
+ "will look for a suitable plugin for device specified. Default value is CPU", default="CPU",
+ type=str)
+ args.add_argument("-nt", "--number_top", help="Number of top results", default=10, type=int)
+ args.add_argument("-ni", "--number_iter", help="Number of inference iterations", default=1, type=int)
+ args.add_argument("--mean_val_r", "-mean_val_r",
+ help="Mean value of red chanel for mean value subtraction in postprocessing ", default=0,
+ type=float)
+ args.add_argument("--mean_val_g", "-mean_val_g",
+ help="Mean value of green chanel for mean value subtraction in postprocessing ", default=0,
+ type=float)
+ args.add_argument("--mean_val_b", "-mean_val_b",
+ help="Mean value of blue chanel for mean value subtraction in postprocessing ", default=0,
+ type=float)
+ args.add_argument("-pc", "--perf_counts", help="Report performance counters", default=False, action="store_true")
return parser
# Loading model to the plugin
log.info("Loading model to the plugin")
exec_net = plugin.load(network=net)
- del net
# Start sync inference
log.info("Starting inference ({} iterations)".format(args.number_iter))
out_img = os.path.join(os.path.dirname(__file__), "out_{}.bmp".format(batch))
cv2.imwrite(out_img, data)
log.info("Result image was saved to {}".format(out_img))
- del exec_net
- del plugin
if __name__ == '__main__':