Python detectron.utils.io.cache_url() Examples
The following are 18
code examples of detectron.utils.io.cache_url().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
detectron.utils.io
, or try the search function
.
Example #1
Source File: infer.py From CBNet with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #2
Source File: infer.py From KL-Loss with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #3
Source File: infer.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #4
Source File: infer.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #5
Source File: infer.py From Detectron with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #6
Source File: infer.py From Detectron-Cascade-RCNN with Apache License 2.0 | 6 votes |
def check_args(args): assert ( (args.rpn_pkl is not None and args.rpn_cfg is not None) or (args.rpn_pkl is None and args.rpn_cfg is None) ) if args.rpn_pkl is not None: args.rpn_pkl = cache_url(args.rpn_pkl, cfg.DOWNLOAD_CACHE) assert os.path.exists(args.rpn_pkl) assert os.path.exists(args.rpn_cfg) if args.models_to_run is not None: assert len(args.models_to_run) % 2 == 0 for i, model_file in enumerate(args.models_to_run): if len(model_file) > 0: if i % 2 == 0: model_file = cache_url(model_file, cfg.DOWNLOAD_CACHE) args.models_to_run[i] = model_file assert os.path.exists(model_file), \ '\'{}\' does not exist'.format(model_file)
Example #7
Source File: config.py From Detectron with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #8
Source File: config.py From CBNet with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #9
Source File: config.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #10
Source File: config.py From KL-Loss with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #11
Source File: config.py From Detectron-Cascade-RCNN with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #12
Source File: config.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 5 votes |
def cache_cfg_urls(): """Download URLs in the config, cache them locally, and rewrite cfg to make use of the locally cached file. """ __C.TRAIN.WEIGHTS = cache_url(__C.TRAIN.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TEST.WEIGHTS = cache_url(__C.TEST.WEIGHTS, __C.DOWNLOAD_CACHE) __C.TRAIN.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TRAIN.PROPOSAL_FILES ) __C.TEST.PROPOSAL_FILES = tuple( cache_url(f, __C.DOWNLOAD_CACHE) for f in __C.TEST.PROPOSAL_FILES )
Example #13
Source File: infer_simple.py From Detectron with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=args.thresh, kp_thresh=args.kp_thresh, ext=args.output_ext, out_when_no_box=args.out_when_no_box )
Example #14
Source File: infer_simple.py From Detectron-Cascade-RCNN with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=0.7, kp_thresh=2, ext=args.output_ext, out_when_no_box=args.out_when_no_box )
Example #15
Source File: infer_simple.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=args.thresh, kp_thresh=args.kp_thresh, ext=args.output_ext, out_when_no_box=args.out_when_no_box )
Example #16
Source File: infer_simple.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=0.7, kp_thresh=2, ext=args.output_ext, out_when_no_box=args.out_when_no_box )
Example #17
Source File: infer_simple.py From CBNet with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=0.7, kp_thresh=2, ext=args.output_ext, out_when_no_box=args.out_when_no_box )
Example #18
Source File: infer_simple.py From KL-Loss with Apache License 2.0 | 4 votes |
def main(args): logger = logging.getLogger(__name__) merge_cfg_from_file(args.cfg) cfg.NUM_GPUS = 1 args.weights = cache_url(args.weights, cfg.DOWNLOAD_CACHE) assert_and_infer_cfg(cache_urls=False) assert not cfg.MODEL.RPN_ONLY, \ 'RPN models are not supported' assert not cfg.TEST.PRECOMPUTED_PROPOSALS, \ 'Models that require precomputed proposals are not supported' model = infer_engine.initialize_model_from_cfg(args.weights) dummy_coco_dataset = dummy_datasets.get_coco_dataset() if os.path.isdir(args.im_or_folder): im_list = glob.iglob(args.im_or_folder + '/*.' + args.image_ext) else: im_list = [args.im_or_folder] for i, im_name in enumerate(im_list): out_name = os.path.join( args.output_dir, '{}'.format(os.path.basename(im_name) + '.' + args.output_ext) ) logger.info('Processing {} -> {}'.format(im_name, out_name)) im = cv2.imread(im_name) timers = defaultdict(Timer) t = time.time() with c2_utils.NamedCudaScope(0): cls_boxes, cls_segms, cls_keyps = infer_engine.im_detect_all( model, im, None, timers=timers ) logger.info('Inference time: {:.3f}s'.format(time.time() - t)) for k, v in timers.items(): logger.info(' | {}: {:.3f}s'.format(k, v.average_time)) if i == 0: logger.info( ' \ Note: inference on the first image will be slower than the ' 'rest (caches and auto-tuning need to warm up)' ) vis_utils.vis_one_image( im[:, :, ::-1], # BGR -> RGB for visualization im_name, args.output_dir, cls_boxes, cls_segms, cls_keyps, dataset=dummy_coco_dataset, box_alpha=0.3, show_class=True, thresh=args.thresh, kp_thresh=args.kp_thresh, ext=args.output_ext, out_when_no_box=args.out_when_no_box )