def main(): c2_utils.import_detectron_ops() parser = argparse.ArgumentParser( description='Classification model testing') parser.add_argument('--config_file', type=str, default=None, required=True, help='Optional config file for params') parser.add_argument('opts', help='see config.py for all options', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() if args.config_file is not None: cfg_from_file(args.config_file) if args.opts is not None: cfg_from_list(args.opts) assert_and_infer_cfg() print_cfg() test(args)
def build_graph(self): c2_utils.import_detectron_ops() # OpenCL may be enabled by default in OpenCV3; disable it because it's not # thread safe and causes unwanted GPU memory allocations. cv2.ocl.setUseOpenCL(False) merge_cfg_from_file(self.config.args['config_path']) # If this is a CPU kernel, tell Caffe2 that it should not use # any GPUs for its graph operations cpu_only = True for handle in self.config.devices: if handle.type == DeviceType.GPU.value: cpu_only = False if cpu_only: cfg.NUM_GPUS = 0 else: cfg.NUM_GPUS = 1 # TODO: wrap this in "with device" weights_path = cache_url(self.config.args['weights_path'], cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) model = infer_engine.initialize_model_from_cfg(weights_path) return model
import time from caffe2.python import workspace from core.config import assert_and_infer_cfg from core.config import cfg from core.config import merge_cfg_from_file from utils.io import cache_url from utils.timer import Timer import core.test_engine as infer_engine import datasets.dummy_datasets as dummy_datasets import utils.c2 as c2_utils import utils.logging import utils.vis as vis_utils c2_utils.import_detectron_ops() # OpenCL may be enabled by default in OpenCV3; disable it because it's not # thread safe and causes unwanted GPU memory allocations. cv2.ocl.setUseOpenCL(False) def parse_args(): parser = argparse.ArgumentParser(description='End-to-end inference') parser.add_argument('--cfg', dest='cfg', help='cfg model file (/path/to/model_config.yaml)', default=None, type=str) parser.add_argument('--wts', dest='weights', help='weights model file (/path/to/model_weights.pkl)',
from caffe2.proto import caffe2_pb2 from core.config import assert_and_infer_cfg from core.config import cfg from core.config import merge_cfg_from_file from core.config import merge_cfg_from_list from modeling import generate_anchors import core.test_engine as test_engine import utils.c2 as c2_utils import utils.vis as vis_utils import utils.logging import utils.model_convert_utils as mutils from utils.model_convert_utils import op_filter, convert_op_in_proto c2_utils.import_contrib_ops() c2_utils.import_detectron_ops() logger = utils.logging.setup_logging(__name__) def parse_args(): parser = argparse.ArgumentParser( description='Convert a trained network to pb format' ) parser.add_argument( '--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument( '--net_name', dest='net_name', help='optional name for the net', default="detectron", type=str) parser.add_argument(