Python caffe2.python.core.ScopedBlobReference() Examples
The following are 28
code examples of caffe2.python.core.ScopedBlobReference().
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: detector.py From DetectAndTrack with Apache License 2.0 | 6 votes |
def AffineChannelNd(self, blob_in, blob_out, dim_out, share_with=None, inplace=False): if cfg.MODEL.USE_BN: return self.SpatialBNLayer(blob_in, blob_out, dim_out, share_with, inplace) blob_out = blob_out or self.net.NextName() is_not_sharing = share_with is None param_prefix = blob_out if is_not_sharing else share_with scale = core.ScopedBlobReference( param_prefix + '_s', self.param_init_net) bias = core.ScopedBlobReference( param_prefix + '_b', self.param_init_net) if is_not_sharing: self.net.Proto().external_input.extend([str(scale), str(bias)]) self.params.extend([scale, bias]) self.weights.append(scale) self.biases.append(bias) if inplace: return self.net.AffineChannelNd([blob_in, scale, bias], blob_in) else: return self.net.AffineChannelNd([blob_in, scale, bias], blob_out)
Example #2
Source File: detector.py From DetectAndTrack with Apache License 2.0 | 6 votes |
def AffineChannel(self, blob_in, blob_out, dim_out, share_with=None, inplace=False): if cfg.MODEL.USE_BN: return self.SpatialBNLayer(blob_in, blob_out, dim_out, share_with, inplace) blob_out = blob_out or self.net.NextName() is_not_sharing = share_with is None param_prefix = blob_out if is_not_sharing else share_with scale = core.ScopedBlobReference( param_prefix + '_s', self.param_init_net) bias = core.ScopedBlobReference( param_prefix + '_b', self.param_init_net) if is_not_sharing: self.net.Proto().external_input.extend([str(scale), str(bias)]) self.params.extend([scale, bias]) self.weights.append(scale) self.biases.append(bias) if inplace: return self.net.AffineChannel([blob_in, scale, bias], blob_in) else: return self.net.AffineChannel([blob_in, scale, bias], blob_out)
Example #3
Source File: detector.py From masktextspotter.caffe2 with Apache License 2.0 | 6 votes |
def AffineChannel(self, blob_in, blob_out, share_with=None, inplace=False): """Affine transformation to replace BN in networks where BN cannot be used (e.g., because the minibatch size is too small). The AffineChannel parameters may be shared with another AffineChannelOp by specifying its blob name (excluding the '_{s,b}' suffix) in the share_with argument. The operations can be done in place to save memory. """ blob_out = blob_out or self.net.NextName() is_not_sharing = share_with is None param_prefix = blob_out if is_not_sharing else share_with scale = core.ScopedBlobReference( param_prefix + '_s', self.param_init_net) bias = core.ScopedBlobReference( param_prefix + '_b', self.param_init_net) if is_not_sharing: self.net.Proto().external_input.extend([str(scale), str(bias)]) self.params.extend([scale, bias]) self.weights.append(scale) self.biases.append(bias) if inplace: return self.net.AffineChannel([blob_in, scale, bias], blob_in) else: return self.net.AffineChannel([blob_in, scale, bias], blob_out)
Example #4
Source File: detector.py From masktextspotter.caffe2 with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #5
Source File: detector.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #6
Source File: detector.py From CBNet with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #7
Source File: detector.py From Detectron with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #8
Source File: detector.py From KL-Loss with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #9
Source File: detector.py From Detectron-Cascade-RCNN with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #10
Source File: detector.py From NucleiDetectron with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #11
Source File: detector.py From seg_every_thing with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #12
Source File: detector.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): # blobs_in = ['rpn_rois', 'roidb', 'im_info'] name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in]) # Get output blob names from the data loader blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name) return blobs_out
Example #13
Source File: detector.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 5 votes |
def GenerateProposalLabels(self, blobs_in): """Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask R-CNN (as in end-to-end Faster R-CNN training). blobs_in: - 'rpn_rois': 2D tensor of RPN proposals output by GenerateProposals - 'roidb': roidb entries that will be labeled - 'im_info': See GenerateProposals doc. blobs_out: - (variable set of blobs): returns whatever blobs are required for training the model. It does this by querying the data loader for the list of blobs that are needed. """ name = 'GenerateProposalLabelsOp:' + ','.join( [str(b) for b in blobs_in] ) # The list of blobs is not known before run-time because it depends on # the specific model being trained. Query the data loader to get the # list of output blob names. blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] self.net.Python(GenerateProposalLabelsOp().forward)( blobs_in, blobs_out, name=name ) return blobs_out
Example #14
Source File: detector.py From DetectAndTrack with Apache License 2.0 | 5 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merges RPN proposals generated at various FPN levels and then redistributes those proposals to their appropriate FPN levels for use by the RoIFeatureTransform op. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] If used during training, then the input blobs will also include [gt_boxes, roidb, im_info] and the output blobs will include (before rois) [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #15
Source File: detector.py From Detectron-Cascade-RCNN with Apache License 2.0 | 4 votes |
def DistributeCascadeProposals(self, stage): """Distribute proposals to their appropriate FPN levels. by Zhaowei Cai for Cascade R-CNN Input blobs: - proposals_<j> are the decoded proposals from stage j; see documentation from DecodeBBoxes. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights, mapped_gt_boxes]. """ stage_name = '_{}'.format(stage) # Prepare input blobs blobs_in = ['proposals' + stage_name] if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'DistributeCascadeProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = cascade_rcnn_roi_data.get_cascade_rcnn_blob_names( stage, is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( DistributeCascadeProposalsOp(self.train, stage).forward )(blobs_in, blobs_out, name=name) return outputs
Example #16
Source File: detector.py From CBNet with Apache License 2.0 | 4 votes |
def DistributeCascadeProposals(self, stage): """Distribute proposals to their appropriate FPN levels. by Zhaowei Cai for Cascade R-CNN Input blobs: - proposals_<j> are the decoded proposals from stage j; see documentation from DecodeBBoxes. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights, mapped_gt_boxes]. """ stage_name = '_{}'.format(stage) # Prepare input blobs blobs_in = ['proposals' + stage_name] if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'DistributeCascadeProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = cascade_rcnn_roi_data.get_cascade_rcnn_blob_names( stage, is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( DistributeCascadeProposalsOp(self.train, stage).forward )(blobs_in, blobs_out, name=name) return outputs
Example #17
Source File: detector.py From NucleiDetectron with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #18
Source File: detector.py From CBNet with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #19
Source File: detector.py From Detectron-DA-Faster-RCNN with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #20
Source File: detector.py From Detectron with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #21
Source File: detector.py From Detectron-Cascade-RCNN with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #22
Source File: detector.py From masktextspotter.caffe2 with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposalsRec(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsRecOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsRecOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #23
Source File: detector.py From masktextspotter.caffe2 with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #24
Source File: detector.py From seg_every_thing with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = roi_data.fast_rcnn.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #25
Source File: detector.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 4 votes |
def DistributeCascadeProposals(self, stage): """Distribute proposals to their appropriate FPN levels. by Zhaowei Cai for Cascade R-CNN Input blobs: - proposals_<j> are the decoded proposals from stage j; see documentation from DecodeBBoxes. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights, mapped_gt_boxes]. """ stage_name = '_{}'.format(stage) # Prepare input blobs blobs_in = ['proposals' + stage_name] if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'DistributeCascadeProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = cascade_rcnn_roi_data.get_cascade_rcnn_blob_names( stage, is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( DistributeCascadeProposalsOp(self.train, stage).forward )(blobs_in, blobs_out, name=name) return outputs
Example #26
Source File: detector.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnClusterProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ # Prepare input blobs k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnClusterProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = cluster_rcnn_roi_data.get_cluster_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnClusterProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #27
Source File: detector.py From Clustered-Object-Detection-in-Aerial-Image with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs
Example #28
Source File: detector.py From KL-Loss with Apache License 2.0 | 4 votes |
def CollectAndDistributeFpnRpnProposals(self): """Merge RPN proposals generated at multiple FPN levels and then distribute those proposals to their appropriate FPN levels. An anchor at one FPN level may predict an RoI that will map to another level, hence the need to redistribute the proposals. This function assumes standard blob names for input and output blobs. Input blobs: [rpn_rois_fpn<min>, ..., rpn_rois_fpn<max>, rpn_roi_probs_fpn<min>, ..., rpn_roi_probs_fpn<max>] - rpn_rois_fpn<i> are the RPN proposals for FPN level i; see rpn_rois documentation from GenerateProposals. - rpn_roi_probs_fpn<i> are the RPN objectness probabilities for FPN level i; see rpn_roi_probs documentation from GenerateProposals. If used during training, then the input blobs will also include: [roidb, im_info] (see GenerateProposalLabels). Output blobs: [rois_fpn<min>, ..., rois_rpn<max>, rois, rois_idx_restore] - rois_fpn<i> are the RPN proposals for FPN level i - rois_idx_restore is a permutation on the concatenation of all rois_fpn<i>, i=min...max, such that when applied the RPN RoIs are restored to their original order in the input blobs. If used during training, then the output blobs will also include: [labels, bbox_targets, bbox_inside_weights, bbox_outside_weights]. """ k_max = cfg.FPN.RPN_MAX_LEVEL k_min = cfg.FPN.RPN_MIN_LEVEL # Prepare input blobs rois_names = ['rpn_rois_fpn' + str(l) for l in range(k_min, k_max + 1)] score_names = [ 'rpn_roi_probs_fpn' + str(l) for l in range(k_min, k_max + 1) ] blobs_in = rois_names + score_names if self.train: blobs_in += ['roidb', 'im_info'] blobs_in = [core.ScopedBlobReference(b) for b in blobs_in] name = 'CollectAndDistributeFpnRpnProposalsOp:' + ','.join( [str(b) for b in blobs_in] ) # Prepare output blobs blobs_out = fast_rcnn_roi_data.get_fast_rcnn_blob_names( is_training=self.train ) blobs_out = [core.ScopedBlobReference(b) for b in blobs_out] outputs = self.net.Python( CollectAndDistributeFpnRpnProposalsOp(self.train).forward )(blobs_in, blobs_out, name=name) return outputs