parameters: (self, proposals, targets)
return_statement: return proposals_new
docstring: Arguments:
              proposals: list[BoxList]
              targets: list[BoxList]
docstring_summary: Arguments:
              proposals: list[BoxList]
              targets: list[BoxList]
docstring_tokens: Arguments : proposals : list [ BoxList ] targets : list [ BoxList ]
function: def add_gt_proposals(self, proposals, targets):
          """
          Arguments:
              proposals: list[BoxList]
              targets: list[BoxList]
          """
          # Get the device we're operating on
          device = proposals[0].bbox.device
  
          gt_boxes = [target.copy_with_fields([]) for target in targets]
  
          # later cat of bbox requires all fields to be present for all bbox
          # so we need to add a dummy for objectness that's missing
          for gt_box in gt_boxes:
              gt_box.add_field("objectness", torch.ones(len(gt_box), device=device))
  
          proposals_new = []
          for proposal, gt_box in zip(proposals, gt_boxes):
              proposal = cat_boxlist((proposal, gt_box))
              # yk: add a field to indicate if a box is a proposal or gt
              is_gt = torch.zeros(proposal.bbox.shape[0], dtype=torch.uint8, device=device)
              if len(gt_box) > 0:
                  is_gt[-gt_box.bbox.shape[0]:] = 1
              proposal.add_field("is_gt", is_gt)
              proposals_new.append(proposal)
  
          return proposals_new
function_tokens: def add_gt_proposals ( self , proposals , targets ) : # Get the device we're operating on device = proposals [ 0 ] . bbox . device gt_boxes = [ target . copy_with_fields ( [ ] ) for target in targets ] # later cat of bbox requires all fields to be present for all bbox # so we need to add a dummy for objectness that's missing for gt_box in gt_boxes : gt_box . add_field ( "objectness" , torch . ones ( len ( gt_box ) , device = device ) ) proposals_new = [ ] for proposal , gt_box in zip ( proposals , gt_boxes ) : proposal = cat_boxlist ( ( proposal , gt_box ) ) # yk: add a field to indicate if a box is a proposal or gt is_gt = torch . zeros ( proposal . bbox . shape [ 0 ] , dtype = torch . uint8 , device = device ) if len ( gt_box ) > 0 : is_gt [ - gt_box . bbox . shape [ 0 ] : ] = 1 proposal . add_field ( "is_gt" , is_gt ) proposals_new . append ( proposal ) return proposals_new