def _merge_data(batch): # C x H x W max_shape = tuple( max(img.shape[d] for img, _ in batch) for d in range(3)) image_batch = [] labels_batch = None if is_multi_label: labels_batch = [] for image_idx, (img, anns) in enumerate(batch): temp = torch.zeros(max_shape, dtype=torch.float32) temp[:, :img.shape[1], :img.shape[2]] = img temp = normalize(temp) image_batch.append(temp) if is_multi_label: labels_batch.append(train_sets.handle_multi_label(anns)) image_batch = torch.stack(image_batch, 0) anchors = generate_shifted_anchors(max_shape[1:]) rgr, cls = anchor_targets_bbox(anchors, batch, len(train_sets.class2idx), multi_labels=labels_batch) reg = torch.from_numpy(rgr) cls = torch.from_numpy(cls) # [batch_size, channel, width, height] # [batch_size, all_anchors, num_classes+1] # [batch_size, all_anchors, num_values+1] return image_batch, cls, reg
def compute_targets(self, image_group, annotations_group): """ Compute target outputs for the network using images and their annotations. """ """ Compute target outputs for the network using images and their annotations. """ batches_targets = anchor_targets_bbox(self.anchors, image_group, annotations_group, self.num_classes()) return list(batches_targets)
def compute_targets(self, image_group, annotations_group): """ Compute target outputs for the network using images and their annotations. Args: image_group: List with images of a group/batch annotations_group: List with annotations of a group/batch Returns: List with the target batches for EfficientPose """ batches_targets = anchor_targets_bbox( self.anchors, image_group, annotations_group, num_classes=self.num_classes(), num_rotation_parameters=self.rotation_parameter + 2, #+1 for the is_symmetric flag and +1 for the class idx to choose the correct model 3d points num_translation_parameters=self. translation_parameter, #x,y in 2D and Tz translation_anchors=self.translation_anchors, ) return list(batches_targets)