Translocations_Detector/models/detr.py
def forward(self, outputs, targets):
        """ This performs the loss computation.

        Parameters:
             outputs: dict of tensors, see the output specification of the model for the format
             targets: list of dicts, such that len(targets) == batch_size.
                      The expected keys in each dict depends on the losses applied, see each loss' doc
        """
        outputs_without_aux = {k: v for k, v in outputs.items() if k != 'aux_outputs'}

        # Retrieve the matching between the outputs of the last layer and the targets
        indices = self.matcher(outputs_without_aux, targets)

        # Compute the average number of target segments accross all nodes, for normalization purposes
        num_segments = sum(len(t["labels"]) for t in targets)
        num_segments = torch.as_tensor([num_segments], dtype=torch.float, device=next(iter(outputs.values())).device)
        if is_dist_avail_and_initialized():
            torch.distributed.all_reduce(num_segments)
        num_segments = torch.clamp(num_segments / get_world_size(), min=1).item()

        # Compute all the requested losses
        losses = {}
        for loss in self.losses:
            losses.update(self.get_loss(loss, outputs, targets, indices, num_segments))


        return losses
 This performs the loss computation.

        Parameters:
             outputs: dict of tensors, see the output specification of the model for the format
             targets: list of dicts, such that len(targets) == batch_size.
                      The expected keys in each dict depends on the losses applied, see each loss' doc
        
This performs the loss computation.
This performs the loss computation .
def forward(self, outputs, targets):
        outputs_without_aux = {k: v for k, v in outputs.items() if k != 'aux_outputs'}
        indices = self.matcher(outputs_without_aux, targets)
        num_segments = sum(len(t["labels"]) for t in targets)
        num_segments = torch.as_tensor([num_segments], dtype=torch.float, device=next(iter(outputs.values())).device)
        if is_dist_avail_and_initialized():
            torch.distributed.all_reduce(num_segments)
        num_segments = torch.clamp(num_segments / get_world_size(), min=1).item()
        losses = {}
        for loss in self.losses:
            losses.update(self.get_loss(loss, outputs, targets, indices, num_segments))
        return losses
def forward ( self , outputs , targets ) : outputs_without_aux = { k : v for k , v in outputs . items ( ) if k != 'aux_outputs' } indices = self . matcher ( outputs_without_aux , targets ) num_segments = sum ( len ( t [ "labels" ] ) for t in targets ) num_segments = torch . as_tensor ( [ num_segments ] , dtype = torch . float , device = next ( iter ( outputs . values ( ) ) ) . device ) if is_dist_avail_and_initialized ( ) : torch . distributed . all_reduce ( num_segments ) num_segments = torch . clamp ( num_segments / get_world_size ( ) , min = 1 ) . item ( ) losses = { } for loss in self . losses : losses . update ( self . get_loss ( loss , outputs , targets , indices , num_segments ) ) return losses
This performs the loss computation.
This performs the loss computation .
""" This performs the loss computation.

        Parameters:
             outputs: dict of tensors, see the output specification of the model for the format
             targets: list of dicts, such that len(targets) == batch_size.
                      The expected keys in each dict depends on the losses applied, see each loss' doc
        """ # Retrieve the matching between the outputs of the last layer and the targets # Compute the average number of target segments accross all nodes, for normalization purposes # Compute all the requested losses
self
outputs
dict of tensors, see the output specification of the model for the format
dict of tensors see the output specification of the model for the format
targets
list of dicts, such that len(targets) == batch_size.
The expected keys in each dict depends on the losses applied, see each loss' doc
list of dicts such that len ( targets ) == batch_size . The expected keys in each dict depends on the losses applied see each loss ' doc