def clip_transformed_annotations(self, image_group, annotations_group, group):
    '\n        Filter annotations by removing those that are outside of the image bounds or whose width/height < 0.\n        '
    filtered_image_group = []
    filtered_annotations_group = []
    for (index, (image, annotations)) in enumerate(zip(image_group, annotations_group)):
        image_height = image.shape[0]
        image_width = image.shape[1]
        annotations['bboxes'][:, 0] = np.clip(annotations['bboxes'][:, 0], 0, (image_width - 2))
        annotations['bboxes'][:, 1] = np.clip(annotations['bboxes'][:, 1], 0, (image_height - 2))
        annotations['bboxes'][:, 2] = np.clip(annotations['bboxes'][:, 2], 1, (image_width - 1))
        annotations['bboxes'][:, 3] = np.clip(annotations['bboxes'][:, 3], 1, (image_height - 1))
        small_indices = np.where((((annotations['bboxes'][:, 2] - annotations['bboxes'][:, 0]) < 10) | ((annotations['bboxes'][:, 3] - annotations['bboxes'][:, 1]) < 10)))[0]
        if len(small_indices):
            for k in annotations_group[index].keys():
                annotations_group[index][k] = np.delete(annotations[k], small_indices, axis=0)
        if (annotations_group[index]['bboxes'].shape[0] != 0):
            filtered_image_group.append(image)
            filtered_annotations_group.append(annotations_group[index])
        else:
            warnings.warn('Image with id {} (shape {}) contains no valid boxes after transform'.format(group[index], image.shape))
    return (filtered_image_group, filtered_annotations_group)
Filter annotations by removing those that are outside of the image bounds or whose width/height < 0.
def clip_transformed_annotations(self, image_group, annotations_group, group):
    '\n        \n        '
    filtered_image_group = []
    filtered_annotations_group = []
    for (index, (image, annotations)) in enumerate(zip(image_group, annotations_group)):
        image_height = image.shape[0]
        image_width = image.shape[1]
        annotations['bboxes'][:, 0] = np.clip(annotations['bboxes'][:, 0], 0, (image_width - 2))
        annotations['bboxes'][:, 1] = np.clip(annotations['bboxes'][:, 1], 0, (image_height - 2))
        annotations['bboxes'][:, 2] = np.clip(annotations['bboxes'][:, 2], 1, (image_width - 1))
        annotations['bboxes'][:, 3] = np.clip(annotations['bboxes'][:, 3], 1, (image_height - 1))
        small_indices = np.where((((annotations['bboxes'][:, 2] - annotations['bboxes'][:, 0]) < 10) | ((annotations['bboxes'][:, 3] - annotations['bboxes'][:, 1]) < 10)))[0]
        if len(small_indices):
            for k in annotations_group[index].keys():
                annotations_group[index][k] = np.delete(annotations[k], small_indices, axis=0)
        if (annotations_group[index]['bboxes'].shape[0] != 0):
            filtered_image_group.append(image)
            filtered_annotations_group.append(annotations_group[index])
        else:
            warnings.warn('Image with id {} (shape {}) contains no valid boxes after transform'.format(group[index], image.shape))
    return (filtered_image_group, filtered_annotations_group)