Python caffe2.python.core.NameScope() Examples
The following are 30
code examples of caffe2.python.core.NameScope().
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
caffe2.python.core
, or try the search function
.
Example #1
Source File: test_loader.py From Detectron-Cascade-RCNN with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #2
Source File: test_loader.py From Detectron with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #3
Source File: test_loader.py From masktextspotter.caffe2 with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #4
Source File: test_loader.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #5
Source File: test_loader.py From seg_every_thing with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #6
Source File: test_loader.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #7
Source File: test_loader.py From NucleiDetectron with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #8
Source File: test_loader.py From CBNet with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #9
Source File: test_loader.py From KL-Loss with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #10
Source File: test_loader.py From DetectAndTrack with Apache License 2.0 | 6 votes |
def get_net(data_loader, name): logger = logging.getLogger(__name__) blob_names = data_loader.get_output_names() net = core.Net(name) net.type = 'dag' for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): for blob_name in blob_names: blob = core.ScopedName(blob_name) workspace.CreateBlob(blob) net.DequeueBlobs( data_loader._blobs_queue_name, blob_names) logger.info("Protobuf:\n" + str(net.Proto())) return net
Example #11
Source File: test_loader.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data
Example #12
Source File: loader.py From KL-Loss with Apache License 2.0 | 5 votes |
def close_blobs_queues(self): """Close a BlobsQueue.""" for gpu_id in range(self._num_gpus): with core.NameScope('gpu_{}'.format(gpu_id)): workspace.RunOperatorOnce( core.CreateOperator( 'CloseBlobsQueue', [self._blobs_queue_name], [] ) )
Example #13
Source File: c2.py From NucleiDetectron with Apache License 2.0 | 5 votes |
def GpuNameScope(gpu_id): """Create a name scope for GPU device `gpu_id`.""" with core.NameScope('gpu_{:d}'.format(gpu_id)): yield
Example #14
Source File: loader.py From NucleiDetectron with Apache License 2.0 | 5 votes |
def close_blobs_queues(self): """Close a BlobsQueue.""" for gpu_id in range(self._num_gpus): with core.NameScope('gpu_{}'.format(gpu_id)): workspace.RunOperatorOnce( core.CreateOperator( 'CloseBlobsQueue', [self._blobs_queue_name], [] ) )
Example #15
Source File: test_loader.py From NucleiDetectron with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data
Example #16
Source File: test_loader.py From CBNet with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data
Example #17
Source File: c2.py From CBNet with Apache License 2.0 | 5 votes |
def GpuNameScope(gpu_id): """Create a name scope for GPU device `gpu_id`.""" with core.NameScope('gpu_{:d}'.format(gpu_id)): yield
Example #18
Source File: loader.py From CBNet with Apache License 2.0 | 5 votes |
def close_blobs_queues(self): """Close a BlobsQueue.""" for gpu_id in range(self._num_gpus): with core.NameScope('gpu_{}'.format(gpu_id)): workspace.RunOperatorOnce( core.CreateOperator( 'CloseBlobsQueue', [self._blobs_queue_name], [] ) )
Example #19
Source File: loader.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def shutdown(self): self.coordinator.request_stop() self.coordinator.wait_for_stop() for i in range(self._num_gpus): with core.NameScope('gpu_{}'.format(i)): self.close_blobs_queue() self.join()
Example #20
Source File: utils.py From caffe2-pose-estimation with Apache License 2.0 | 5 votes |
def NamedCudaScope(gpu_id): with core.NameScope('gpu_{:d}'.format(gpu_id)): gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, gpu_id) with core.DeviceScope(gpu_dev): yield
Example #21
Source File: model_builder.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def add_inputs(model, roidb=None): """Add network input ops. To be called *after* model_bulder.create().""" # Implementation notes: # Typically, one would create the input ops and then the rest of the net. # However, creating the input ops depends on loading the dataset, which # can take a few minutes for COCO. # We prefer to avoid waiting so debugging can fail fast. # Thus, we create the net *without input ops* prior to loading the # dataset, and then add the input ops after loading the dataset. # Since we defer input op creation, we need to do a little bit of surgery # to place the input ops at the start of the network op list. if roidb is not None: # Make debugging easier when NUM_GPUS is 1 by only using one worker # thread for loading mini-batches num_workers = 1 if cfg.NUM_GPUS == 1 else cfg.NUM_WORKERS model.roi_data_loader = RoIDataLoader( roidb, num_workers=num_workers, num_enqueuers=1, minibatch_queue_size=cfg.TRAIN.MINIBATCH_QUEUE_SIZE) orig_num_op = len(model.net._net.op) for gpu_id in range(cfg.NUM_GPUS): with core.NameScope('gpu_{}'.format(gpu_id)): with core.DeviceScope(muji.OnGPU(gpu_id)): if model.train: add_train_inputs(model) else: add_test_inputs(model) # A little op surgery to move input ops to the start of the net diff = len(model.net._net.op) - orig_num_op new_op = model.net._net.op[-diff:] + model.net._net.op[:-diff] del model.net._net.op[:] model.net._net.op.extend(new_op)
Example #22
Source File: c2.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 5 votes |
def GpuNameScope(gpu_id): """Create a name scope for GPU device `gpu_id`.""" with core.NameScope('gpu_{:d}'.format(gpu_id)): yield
Example #23
Source File: loader.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 5 votes |
def close_blobs_queues(self): """Close a BlobsQueue.""" for gpu_id in range(self._num_gpus): with core.NameScope('gpu_{}'.format(gpu_id)): workspace.RunOperatorOnce( core.CreateOperator( 'CloseBlobsQueue', [self._blobs_queue_name], [] ) )
Example #24
Source File: test_loader.py From Detectron with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data
Example #25
Source File: model_builder.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def add_parameter_update_ops(model, gpu_id): with core.DeviceScope(muji.OnGPU(gpu_id)): with core.NameScope('gpu_{}'.format(gpu_id)): # Learning rate of 0 is a dummy value to be set properly at the # start of training lr = model.param_init_net.ConstantFill( [], 'lr', shape=[1], value=0.0) one = model.param_init_net.ConstantFill( [], 'one', shape=[1], value=1.0) wd = model.param_init_net.ConstantFill( [], 'wd', shape=[1], value=cfg.SOLVER.WEIGHT_DECAY) for param in model.TrainableParams(gpu_id=gpu_id): logger.info('param ' + str(param) + ' will be updated') param_grad = model.param_to_grad[param] # Initialize momentum vector param_momentum = model.param_init_net.ConstantFill( [param], param + '_momentum', value=0.0) if param in model.biases: # Special treatment for biases (mainly to match historical impl. # details): # (1) Do not apply weight decay # (2) Use a 2x higher learning rate model.Scale(param_grad, param_grad, scale=2.0) elif cfg.SOLVER.WEIGHT_DECAY > 0: # Apply weight decay to non-bias weights model.WeightedSum([param_grad, one, param, wd], param_grad) # Update param_grad and param_momentum in place model.net.MomentumSGDUpdate( [param_grad, param_momentum, lr, param], [param_grad, param_momentum, param], momentum=cfg.SOLVER.MOMENTUM)
Example #26
Source File: c2.py From Detectron with Apache License 2.0 | 5 votes |
def GpuNameScope(gpu_id): """Create a name scope for GPU device `gpu_id`.""" with core.NameScope('gpu_{:d}'.format(gpu_id)): yield
Example #27
Source File: loader.py From Detectron with Apache License 2.0 | 5 votes |
def close_blobs_queues(self): """Close a BlobsQueue.""" for gpu_id in range(self._num_gpus): with core.NameScope('gpu_{}'.format(gpu_id)): workspace.RunOperatorOnce( core.CreateOperator( 'CloseBlobsQueue', [self._blobs_queue_name], [] ) )
Example #28
Source File: test_loader.py From Detectron-Cascade-RCNN with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data
Example #29
Source File: rpn_generator.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def im_list_proposals( model, im_list, start_ind=None, end_ind=None, total_num_images=None ): """Generate RPN proposals on all images in an imdb.""" _t = Timer() num_images = len(im_list) im_list_boxes = [[] for _ in range(num_images)] im_list_scores = [[] for _ in range(num_images)] im_list_ids = [[] for _ in range(num_images)] if start_ind is None: start_ind = 0 end_ind = num_images total_num_images = num_images for i in range(num_images): im_list_ids[i] = im_list[i]['id'] im = cv2.imread(im_list[i]['image']) with core.NameScope('gpu_{}'.format(cfg.ROOT_GPU_ID)): with core.DeviceScope( core.DeviceOption(caffe2_pb2.CUDA, cfg.ROOT_GPU_ID)): _t.tic() im_list_boxes[i], im_list_scores[i] = im_proposals(model, im) _t.toc() if i % 10 == 0: ave_time = _t.average_time eta_seconds = ave_time * (num_images - i - 1) eta = str(datetime.timedelta(seconds=int(eta_seconds))) logger.info( ('rpn_generate: range [{:d}, {:d}] of {:d}: ' '{:d}/{:d} {:.3f}s (eta: {})').format( start_ind + 1, end_ind, total_num_images, start_ind + i + 1, start_ind + num_images, ave_time, eta)) return im_list_boxes, im_list_scores, im_list_ids
Example #30
Source File: test_loader.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 5 votes |
def run_net(net): workspace.RunNetOnce(net) gpu_dev = core.DeviceOption(caffe2_pb2.CUDA, 0) name_scope = 'gpu_{}'.format(0) with core.NameScope(name_scope): with core.DeviceScope(gpu_dev): data = workspace.FetchBlob(core.ScopedName('data')) return data