def __init__(self, ann_fnames, img_dir, labels, batch_size, anchors=COCO_ANCHORS, min_net_size=320, max_net_size=608, jitter=True, shuffle=True): self.ann_fnames = ann_fnames self.img_dir = img_dir self.lable_names = labels self.min_net_size = (min_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.max_net_size = (max_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.jitter = jitter self.anchors = create_anchor_boxes(anchors) self.batch_size = batch_size self.shuffle = shuffle self.steps_per_epoch = int(len(ann_fnames) / batch_size) self._epoch = 0 self._end_epoch = False self._index = 0 self._initial_net_size()
def __init__(self, ann_fnames, img_dir, labels, batch_size, anchors=[ 23, 121, 30, 241, 40, 174, 42, 273, 53, 316, 56, 230, 66, 303, 81, 318, 104, 337 ], min_net_size=224, max_net_size=224, jitter=True, shuffle=True): self.ann_fnames = ann_fnames self.img_dir = img_dir self.lable_names = labels self.min_net_size = (min_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.max_net_size = (max_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO # self.min_net_size = min_net_size # self.max_net_size = max_net_size self.jitter = jitter self.anchors = create_anchor_boxes(anchors) self.batch_size = batch_size self.shuffle = shuffle self.steps_per_epoch = int(len(ann_fnames) / batch_size) self._epoch = 0 self._end_epoch = False self._index = 0 self._initial_net_size()
def __init__(self, ann_fnames, img_dir, labels, batch_size, anchors=COCO_ANCHORS, min_net_size=320, max_net_size=608, data_augmentation=True, shuffle=True, keep_image_ratio=False): self.ann_fnames = ann_fnames self.img_dir = img_dir self.lable_names = labels self.min_net_size = (min_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.max_net_size = (max_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.data_augmentation = data_augmentation self.anchors = create_anchor_boxes(anchors) self.batch_size = batch_size self.shuffle = shuffle self.keep_image_ratio = keep_image_ratio self.steps_per_epoch = int(len(ann_fnames) / batch_size) self._epoch = -1 self._new_epoch = True self._index = 0 self._net_size = self.min_net_size
def __init__(self, dataDirectories, labelNames, batch_size, anchors=COCO_ANCHORS, image_size=320, shuffleData=True, augmentations=None, normalizeImage=True): self.annotationObjects = AnnotationObject.loadFromDirectories( dataDirectories, labelNames, shuffleData) self._numOfLabels = len(labelNames) self.image_size = image_size self.anchors = create_anchor_boxes(anchors) self.batch_size = batch_size self.augmentations = self._composeAugmentations(augmentations) self.normalizeImage = normalizeImage
def __init__(self, ann_fnames, img_dir, labels, anchors, min_net_size=320, max_net_size=608, jitter=True): self.ann_fnames = ann_fnames self.img_dir = img_dir self.lable_names = labels self.min_net_size = (min_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.max_net_size = (max_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.jitter = jitter self.anchors = create_anchor_boxes(anchors) self.net_size = DEFAULT_NETWORK_SIZE
def __init__( self, annotations, anchors, max_box_per_image=30, batch_size=2, min_net_size=320, max_net_size=608, shuffle=True, jitter=True, ): self.annotations = annotations self._batch_size = batch_size self.max_box_per_image = max_box_per_image self.min_net_size = (min_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.max_net_size = (max_net_size // DOWNSAMPLE_RATIO) * DOWNSAMPLE_RATIO self.shuffle = shuffle self.jitter = jitter self.anchors = create_anchor_boxes(anchors) self.net_size = DEFAULT_NETWORK_SIZE if shuffle: np.random.shuffle(self.annotations)
# image = image / 255. list_ys = _create_empty_xy(image_size, numOfLabels) for original_box, label in zip(boxes, coded_labels): max_anchor, scale_index, box_index = _find_match_anchor( original_box, anchors) _coded_box = _encode_box(list_ys[scale_index], original_box, max_anchor, image_size, image_size) _assign_box(list_ys[scale_index], box_index, _coded_box, label) return image, list_ys[2], list_ys[1], list_ys[0] anchors = create_anchor_boxes([ 10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326 ]) labels = [*range(10)] numOfLabels = len(labels) net_size = 288 image_size = net_size def makeImage(value): return np.full([image_size, image_size, 3], value, np.uint8) def main(): annObjects = [(makeImage(1), np.array([(10, 10, 20, 20)]), [1]), (makeImage(2), np.array([(10, 10, 20, 20), (10, 10, 60, 60)]), [2, 3])]
def __init__(self, net_size, nClasses, anchors): self.net_size = net_size self.nClasses = nClasses self.anchorBoxes = create_anchor_boxes(anchors)