def common_config(manifest_file, manifest_root, batch_size, subset_pct, h=96, w=96, scale=[1., 1.]): cache_root = get_data_cache_or_nothing('stl10-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'subset_fraction': float(subset_pct / 100.0), 'macrobatch_size': 5000, 'type': 'image,label', 'cache_directory': cache_root, 'image': { 'height': h, 'width': w, 'scale': scale }, 'label': { 'binary': False } }
def common_config(manifest_file, batch_size): cache_root = get_data_cache_or_nothing('mnist-cache/') return {'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'minibatch_size': batch_size, 'macrobatch_size': 25000, 'cache_directory': cache_root, 'type': 'image,label', 'image': {'height': 28, 'width': 28, 'channels': 1}, 'label': {'binary': False}}
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('ucf-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'macrobatch_size': batch_size * 12, 'type': 'video,label', 'cache_directory': cache_root, 'video': {'max_frame_count': 16, 'frame': {'height': 112, 'width': 112, 'scale': [0.875, 0.875]}}, 'label': {'binary': False} }
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('whale-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'macrobatch_size': batch_size * 12, 'type': 'audio,label', 'cache_directory': cache_root, 'audio': {'sample_freq_hz': 2000, 'max_duration': '2 seconds', 'frame_length': '80 milliseconds', 'frame_stride': '40 milliseconds'}, 'label': {'binary': False} }
def common_config(manifest_file, manifest_root, batch_size, subset_pct): cache_root = get_data_cache_or_nothing('cifar-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'subset_fraction': float(subset_pct/100.0), 'macrobatch_size': 5000, 'type': 'image,label', 'cache_directory': cache_root, 'image': {'height': 32, 'width': 32, 'scale': [0.8, 0.8]}, 'label': {'binary': False} }
def PASCALVOC(manifest_file, manifest_root, rois_per_img=256, height=1000, width=1000, inference=False): """ Returns the aeon dataloader configuration for PASCAL VOC dataset. """ CLASSES = ('__background__', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor') # if inference, we do not shuffle or flip do_transforms = not inference image_config = {"type": "image", "height": height, "width": width} localization_config = { "type": "localization_rcnn", "height": height, "width": width, "rois_per_image": rois_per_img, "class_names": CLASSES, "scaling_factor": 1. / 16 } augmentation = { "type": "image", "fixed_aspect_ratio": True, "flip_enable": do_transforms, "crop_enable": False } return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'etl': [image_config, localization_config], 'cache_directory': get_data_cache_or_nothing(subdir='pascalvoc_cache'), 'shuffle_enable': do_transforms, 'shuffle_manifest': do_transforms, 'batch_size': 1, 'block_size': 100, 'augmentation': [augmentation] }
def common_config(manifest_file, manifest_root, batch_size, subset_pct): cache_root = get_data_cache_or_nothing('cifar-cache/') image_config = {"type": "image", "height": 32, "width": 32} label_config = {"type": "label", "binary": False} augmentation = {"type": "image", "scale": [0.8, 0.8], "crop_enable": True} return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'batch_size': batch_size, 'block_size': 5000, 'subset_fraction': float(subset_pct / 100.0), 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation] }
def KITTI(manifest_file, manifest_root, rois_per_img=256, height=375, width=1242, inference=False): """ Returns the aeon dataloader configuration for KITTI dataset. """ CLASSES = ('__background__', 'Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram', 'Misc', 'DontCare') # if inference, we do not shuffle or flip do_transforms = not inference image_config = {"type": "image", "height": height, "width": width} localization_config = { "type": "localization_rcnn", "rois_per_image": rois_per_img, "height": height, "width": width, "class_names": CLASSES, "scaling_factor": 1. / 16 } augmentation = { "type": "image", "fixed_aspect_ratio": True, "flip_enable": do_transforms, "crop_enable": False } return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'etl': [image_config, localization_config], 'cache_directory': get_data_cache_or_nothing(subdir='kitti_cache'), 'shuffle_enable': do_transforms, 'shuffle_manifest': do_transforms, 'batch_size': 1, 'block_size': 100, 'augmentation': [augmentation] }
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('whale-cache/') audio_config = {"type": "audio", "sample_freq_hz": 2000, "max_duration": '2 seconds', "frame_length": '80 milliseconds', "frame_stride": '40 milliseconds'} label_config = {"type": "label", "binary": False} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'batch_size': batch_size, 'block_size': batch_size * 12, 'cache_directory': cache_root, 'etl': [audio_config, label_config]}
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('whale-cache/') audio_config = {"type": "audio", "sample_freq_hz": 2000, "max_duration": '2 seconds', "frame_length": '80 milliseconds', "frame_stride": '40 milliseconds'} label_config = {"type": "label", "binary": False} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'batch_size': batch_size, 'block_size': batch_size * 12, 'cache_directory': cache_root, 'etl': [audio_config, label_config]}
def common_config(manifest_file, manifest_root, batch_size, subset_pct): cache_root = get_data_cache_or_nothing('lsun_cache/') image_config = {"type": "image", "height": 64, "width": 64} label_config = {"type": "label", "binary": False} augmentation = {"type": "image", "scale": [1., 1.]} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'batch_size': batch_size, 'subset_fraction': float(subset_pct/100.0), 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]}
def common_config(manifest_file, manifest_root, batch_size, subset_pct): cache_root = get_data_cache_or_nothing('cifar-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'subset_fraction': float(subset_pct / 100.0), 'macrobatch_size': 5000, 'type': 'image,label', 'cache_directory': cache_root, 'image': { 'height': 32, 'width': 32, 'scale': [0.8, 0.8] }, 'label': { 'binary': False } }
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('whale-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'macrobatch_size': batch_size * 12, 'type': 'audio,label', 'cache_directory': cache_root, 'audio': { 'sample_freq_hz': 2000, 'max_duration': '2 seconds', 'frame_length': '80 milliseconds', 'frame_stride': '40 milliseconds' }, 'label': { 'binary': False } }
def common_config(manifest_file, manifest_root, batch_size, subset_pct): # export NEON_DATA_CACHE_DIR=</data/cache/> cache_root = get_data_cache_or_nothing('i1k-cache/') image_config = {"type": "image", "height": 224, "width": 224} label_config = {"type": "label", "binary": False} augmentation = {"type": "image", "scale": [0.875, 0.875], "crop_enable": True} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'batch_size': batch_size, 'subset_fraction': float(subset_pct/100.0), 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]}
def PASCALVOC(manifest_file, manifest_root, rois_per_img=256, height=1000, width=1000, inference=False): """ Returns the aeon dataloader configuration for PASCAL VOC dataset. """ CLASSES = ('__background__', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor') # if inference, we do not shuffle or flip do_transforms = not inference image_config = {"type": "image", "height": height, "width": width} localization_config = {"type": "localization_rcnn", "height": height, "width": width, "rois_per_image": rois_per_img, "class_names": CLASSES, "scaling_factor": 1. / 16} augmentation = {"type": "image", "fixed_aspect_ratio": True, "flip_enable": do_transforms, "crop_enable": False} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'etl': [image_config, localization_config], 'cache_directory': get_data_cache_or_nothing(subdir='pascalvoc_cache'), 'shuffle_enable': do_transforms, 'shuffle_manifest': do_transforms, 'batch_size': 1, 'block_size': 100, 'augmentation': [augmentation]}
def common_config(manifest_file, batch_size): cache_root = get_data_cache_or_nothing('cifar10-cache/') image_config = {"type": "image", "height": 32, "width": 32} label_config = {"type": "label", "binary": False} augmentation = { "type": "image", "scale": [0.8, 0.8], "center": False, "flip_enable": True } return { 'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation] }
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('ucf-cache/') return { 'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'minibatch_size': batch_size, 'macrobatch_size': batch_size * 12, 'type': 'video,label', 'cache_directory': cache_root, 'video': { 'max_frame_count': 16, 'frame': { 'height': 112, 'width': 112, 'scale': [0.875, 0.875] } }, 'label': { 'binary': False } }
def KITTI(manifest_file, manifest_root, rois_per_img=256, height=375, width=1242, inference=False): """ Returns the aeon dataloader configuration for KITTI dataset. """ CLASSES = ('__background__', 'Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram', 'Misc', 'DontCare') # if inference, we do not shuffle or flip do_transforms = not inference image_config = {"type": "image", "height": height, "width": width} localization_config = {"type": "localization_rcnn", "rois_per_image": rois_per_img, "height": height, "width": width, "class_names": CLASSES, "scaling_factor": 1. / 16} augmentation = {"type": "image", "fixed_aspect_ratio": True, "flip_enable": do_transforms, "crop_enable": False} return {'manifest_filename': manifest_file, 'manifest_root': manifest_root, 'etl': [image_config, localization_config], 'cache_directory': get_data_cache_or_nothing(subdir='kitti_cache'), 'shuffle_enable': do_transforms, 'shuffle_manifest': do_transforms, 'batch_size': 1, 'block_size': 100, 'augmentation': [augmentation]}
def PASCALVOC(manifest_file, manifest_root, rois_per_img=256, height=1000, width=1000, inference=False): """ Returns the aeon dataloader configuration for PASCAL VOC dataset. """ CLASSES = ('__background__', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor') # if inference, we do not shuffle or flip do_transforms = not inference image_decode_cfg = dict(height=height, width=width, flip_enable=do_transforms, crop_enable=False, fixed_aspect_ratio=True) localization_cfg = dict(rois_per_image=rois_per_img, class_names=CLASSES, scaling_factor=1. / 16) return dict( manifest_filename=manifest_file, manifest_root=manifest_root, type='image,localization', image=image_decode_cfg, cache_directory=get_data_cache_or_nothing(subdir='pascalvoc_cache'), shuffle_every_epoch=do_transforms, shuffle_manifest=do_transforms, minibatch_size=1, macrobatch_size=100, localization=localization_cfg, )
def common_config(manifest_file, manifest_root, batch_size): cache_root = get_data_cache_or_nothing('ucf-cache/') video_config = { "type": "video", "max_frame_count": 16, "frame": { "height": 112, "width": 112 } } label_config = {"type": "label", "binary": True} return { "manifest_filename": manifest_file, "manifest_root": manifest_root, "batch_size": batch_size, "block_size": 5000, "cache_directory": cache_root, "etl": [video_config, label_config], "augmentation": [] }
def KITTI(manifest_file, manifest_root, rois_per_img=256, height=375, width=1242, inference=False): """ Returns the aeon dataloader configuration for KITTI dataset. """ CLASSES = ('__background__', 'Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram', 'Misc', 'DontCare') # if inference, we do not shuffle or flip do_transforms = not inference image_decode_cfg = dict(height=height, width=width, flip_enable=do_transforms, crop_enable=False, fixed_aspect_ratio=True) localization_cfg = dict(rois_per_image=rois_per_img, class_names=CLASSES, scaling_factor=1. / 16) return dict( manifest_filename=manifest_file, manifest_root=manifest_root, type='image,localization', image=image_decode_cfg, cache_directory=get_data_cache_or_nothing(subdir='kitti_cache'), shuffle_every_epoch=do_transforms, shuffle_manifest=do_transforms, minibatch_size=1, macrobatch_size=100, localization=localization_cfg, )
def get_ssd_config(img_reshape, inference=False): ssd_config = OrderedDict() ssd_config['batch_size'] = 32 ssd_config['shuffle_enable'] = True ssd_config['shuffle_manifest'] = True if inference: ssd_config['batch_size'] = 1 ssd_config['block_size'] = 50 ssd_config['cache_directory'] = get_data_cache_or_nothing( subdir='pascalvoc_cache') ssd_config["etl"] = [{ "type": "localization_ssd", "height": img_reshape[0], "width": img_reshape[1], "max_gt_boxes": 500, "class_names": [ "__background__", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor" ] }, { "type": "image", "height": img_reshape[0], "width": img_reshape[1], "channels": 3 }] if not inference: ssd_config["augmentation"] = [{ "type": "image", "crop_enable": False, "flip_enable": True, "expand_ratio": [1., 4.], "expand_probability": 0.5, # "emit_constraint_type": "center", TODO: enable when adds support for no gt boxes "brightness": [0.9, 1.1], "hue": [-18, 18], "saturation": [0.9, 1.1], "contrast": [0.9, 1.1], "batch_samplers": [{ "max_sample": 1, "max_trials": 1 }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "min_jaccard_overlap": 0.1 } }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "min_jaccard_overlap": 0.3 } }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "min_jaccard_overlap": 0.5 } }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "min_jaccard_overlap": 0.7 } }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "min_jaccard_overlap": 0.9 } }, { "max_sample": 1, "max_trials": 50, "sampler": { "scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0] }, "sample_constraint": { "max_jaccard_overlap": 1.0, "min_jaccard_overlap": 0.1 } }] }] if img_reshape == (300, 300): ssd_config['ssd_config'] = OrderedDict([('conv4_3', { 'min_sizes': 30.0, 'max_sizes': 60.0, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True }), ('fc7', { 'min_sizes': 60.0, 'max_sizes': 111.0, 'aspect_ratios': (2.0, 3.0), 'step': 16 }), ('conv6_2', { 'min_sizes': 111.0, 'max_sizes': 162.0, 'aspect_ratios': (2.0, 3.0), 'step': 32 }), ('conv7_2', { 'min_sizes': 162.0, 'max_sizes': 213.0, 'aspect_ratios': (2.0, 3.0), 'step': 64 }), ('conv8_2', { 'min_sizes': 213.0, 'max_sizes': 264.0, 'aspect_ratios': 2.0, 'step': 100 }), ('conv9_2', { 'min_sizes': 264.0, 'max_sizes': 315.0, 'aspect_ratios': 2.0, 'step': 300 })]) elif img_reshape == (512, 512): ssd_config['ssd_config'] = OrderedDict([('conv4_3', { 'min_sizes': 35.84, 'max_sizes': 76.80, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True }), ('fc7', { 'min_sizes': 76.80, 'max_sizes': 153.6, 'aspect_ratios': (2.0, 3.0), 'step': 16 }), ('conv6_2', { 'min_sizes': 153.6, 'max_sizes': 230.4, 'aspect_ratios': (2.0, 3.0), 'step': 32 }), ('conv7_2', { 'min_sizes': 230.4, 'max_sizes': 307.2, 'aspect_ratios': (2.0, 3.0), 'step': 64 }), ('conv8_2', { 'min_sizes': 307.2, 'max_sizes': 384.0, 'aspect_ratios': 2.0, 'step': 128 }), ('conv9_2', { 'min_sizes': 384.0, 'max_sizes': 460.8, 'aspect_ratios': 2.0, 'step': 256 }), ('conv10_2', { 'min_sizes': 460.8, 'max_sizes': 537.8, 'aspect_ratios': 2.0, 'step': 512 })]) else: raise ValueError( "Image shape of {} not supported.".format(img_reshape)) return ssd_config
def get_ssd_config(img_reshape, inference=False): ssd_config = OrderedDict() ssd_config['batch_size'] = 32 if inference: ssd_config['batch_size'] = 1 ssd_config['block_size'] = 50 ssd_config['cache_directory'] = get_data_cache_or_nothing(subdir='kitti_cache') ssd_config["etl"] = [{ "type": "localization_ssd", "height": img_reshape[0], "width": img_reshape[1], "max_gt_boxes": 500, "class_names": ['__background__', 'Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram', 'Misc', 'DontCare'] }, { "type": "image", "height": img_reshape[0], "width": img_reshape[1], "channels": 3 }] if not inference: ssd_config["augmentation"] = [{ "type": "image", "batch_samplers": [ { "max_sample": 1, "max_trials": 1 }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.1} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.3} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.5} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.7} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.9} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"max_jaccard_overlap": 1.0, "min_jaccard_overlap": 0.1} } ] }] ssd_config['ssd_config'] = OrderedDict( [('conv4_3', {'min_sizes': 30.0, 'max_sizes': 60.0, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True}), ('fc7', {'min_sizes': 60.0, 'max_sizes': 111.0, 'aspect_ratios': (2.0, 3.0), 'step': 16}), ('conv6_2', {'min_sizes': 111.0, 'max_sizes': 162.0, 'aspect_ratios': (2.0, 3.0), 'step': 32}), ('conv7_2', {'min_sizes': 162.0, 'max_sizes': 213.0, 'aspect_ratios': (2.0, 3.0), 'step': 64}), ('conv8_2', {'min_sizes': 213.0, 'max_sizes': 264.0, 'aspect_ratios': 2.0, 'step': 100}), ('conv9_2', {'min_sizes': 264.0, 'max_sizes': 315.0, 'aspect_ratios': 2.0, 'step': {'step_h': 300, 'step_w': 100}})]) return ssd_config
def get_ssd_config(img_reshape, inference=False): ssd_config = OrderedDict() ssd_config['batch_size'] = 32 ssd_config['shuffle_enable'] = True ssd_config['shuffle_manifest'] = True if inference: ssd_config['batch_size'] = 1 ssd_config['block_size'] = 50 ssd_config['cache_directory'] = get_data_cache_or_nothing(subdir='pascalvoc_cache') ssd_config["etl"] = [{ "type": "localization_ssd", "height": img_reshape[0], "width": img_reshape[1], "max_gt_boxes": 500, "class_names": ["__background__", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"] }, { "type": "image", "height": img_reshape[0], "width": img_reshape[1], "channels": 3 }] if not inference: ssd_config["augmentation"] = [{ "type": "image", "crop_enable": False, "flip_enable": True, "expand_ratio": [1., 4.], "expand_probability": 0.5, # "emit_constraint_type": "center", TODO: enable when adds support for no gt boxes "brightness": [0.9, 1.1], "hue": [-18, 18], "saturation": [0.9, 1.1], "contrast": [0.9, 1.1], "batch_samplers": [ { "max_sample": 1, "max_trials": 1 }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.1} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.3} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.5} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.7} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.9} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"max_jaccard_overlap": 1.0, "min_jaccard_overlap": 0.1} } ] }] if img_reshape == (300, 300): ssd_config['ssd_config'] = OrderedDict( [('conv4_3', {'min_sizes': 30.0, 'max_sizes': 60.0, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True}), ('fc7', {'min_sizes': 60.0, 'max_sizes': 111.0, 'aspect_ratios': (2.0, 3.0), 'step': 16}), ('conv6_2', {'min_sizes': 111.0, 'max_sizes': 162.0, 'aspect_ratios': (2.0, 3.0), 'step': 32}), ('conv7_2', {'min_sizes': 162.0, 'max_sizes': 213.0, 'aspect_ratios': (2.0, 3.0), 'step': 64}), ('conv8_2', {'min_sizes': 213.0, 'max_sizes': 264.0, 'aspect_ratios': 2.0, 'step': 100}), ('conv9_2', {'min_sizes': 264.0, 'max_sizes': 315.0, 'aspect_ratios': 2.0, 'step': 300})]) elif img_reshape == (512, 512): ssd_config['ssd_config'] = OrderedDict( [('conv4_3', {'min_sizes': 35.84, 'max_sizes': 76.80, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True}), ('fc7', {'min_sizes': 76.80, 'max_sizes': 153.6, 'aspect_ratios': (2.0, 3.0), 'step': 16}), ('conv6_2', {'min_sizes': 153.6, 'max_sizes': 230.4, 'aspect_ratios': (2.0, 3.0), 'step': 32}), ('conv7_2', {'min_sizes': 230.4, 'max_sizes': 307.2, 'aspect_ratios': (2.0, 3.0), 'step': 64}), ('conv8_2', {'min_sizes': 307.2, 'max_sizes': 384.0, 'aspect_ratios': 2.0, 'step': 128}), ('conv9_2', {'min_sizes': 384.0, 'max_sizes': 460.8, 'aspect_ratios': 2.0, 'step': 256}), ('conv10_2', {'min_sizes': 460.8, 'max_sizes': 537.8, 'aspect_ratios': 2.0, 'step': 512})]) else: raise ValueError("Image shape of {} not supported.".format(img_reshape)) return ssd_config
def get_ssd_config(img_reshape, inference=False): ssd_config = OrderedDict() ssd_config['batch_size'] = 32 if inference: ssd_config['batch_size'] = 1 ssd_config['block_size'] = 50 ssd_config['cache_directory'] = get_data_cache_or_nothing(subdir='spacenet_cache') ssd_config["etl"] = [{ "type": "localization_ssd", "height": img_reshape[0], "width": img_reshape[1], "max_gt_boxes": 500, "class_names": ['__background__', 'building'] }, { "type": "image", "height": img_reshape[0], "width": img_reshape[1], "channels": 3 }] if not inference: ssd_config["augmentation"] = [{ "type": "image", "batch_samplers": [ { "max_sample": 1, "max_trials": 1 }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.1} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.3} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.5} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.7} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"min_jaccard_overlap": 0.9} }, { "max_sample": 1, "max_trials": 50, "sampler": {"scale": [0.3, 1.0], "aspect_ratio": [0.5, 2.0]}, "sample_constraint": {"max_jaccard_overlap": 1.0, "min_jaccard_overlap": 0.1} } ] }] ssd_config['ssd_config'] = OrderedDict( [('conv4_3', {'min_sizes': 35.84, 'max_sizes': 76.80, 'aspect_ratios': 2.0, 'step': 8, 'normalize': True}), ('fc7', {'min_sizes': 76.80, 'max_sizes': 153.6, 'aspect_ratios': (2.0, 3.0), 'step': 16}), ('conv6_2', {'min_sizes': 153.6, 'max_sizes': 230.4, 'aspect_ratios': (2.0, 3.0), 'step': 32}), ('conv7_2', {'min_sizes': 230.4, 'max_sizes': 307.2, 'aspect_ratios': (2.0, 3.0), 'step': 64}), ('conv8_2', {'min_sizes': 307.2, 'max_sizes': 384.0, 'aspect_ratios': 2.0, 'step': 128}), ('conv9_2', {'min_sizes': 384.0, 'max_sizes': 460.8, 'aspect_ratios': 2.0, 'step': 256}), ('conv10_2', {'min_sizes': 460.8, 'max_sizes': 537.8, 'aspect_ratios': 2.0, 'step': 512})]) return ssd_config
def common_config(manifest_file, batch_size, valid_set=False): if(dataset == "cifar10"): # Define Cache cache_root = get_data_cache_or_nothing('cifar10-cache/') # Define image properties image_config = {"type": "image", "height": 32, "width": 32} # Define label properties label_config = {"type": "label", "binary": False} # Define Augmentations augmentation = {"type": "image", "padding": 4, "crop_enable": False, "flip_enable": True} # Don't enable augmentations if it is test set if(valid_set): return {'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config]} return {'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]} elif(dataset == "i1k"): # Define cache cache_root = get_data_cache_or_nothing("i1k-cache/") # Define image properties image_config = {"type": "image", "height": 224, "width": 224} # Define label properties label_config = {"type": "label", "binary": False} # Define Augmentations augmentation = {"type": "image", "center": False, "flip_enable": True, "scale": [0.08, 1.0], "do_area_scale": True, "horizontal_distortion": [0.75, 1.33], "lighting": [0.0, 0.01], "contrast": [0.9, 1.1], "brightness": [0.9, 1.1], "saturation": [0.9, 1.1] } # Dont do augemtations on test set if(valid_set): return{'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config]} # Do augmentations on training set return{'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]} elif(dataset == "cifar100"): # Define Cache cache_root = get_data_cache_or_nothing('cifar100-cache/') # Define image properties image_config = {"type": "image", "height": 32, "width": 32} # Define label properties label_config = {"type": "label", "binary": False} # Define Augmentations augmentation = {"type": "image", "padding": 4, "crop_enable": False, "flip_enable": True} # Don't enable augmentations if it is test set if(valid_set): return {'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config]} return {'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]} elif(dataset == "i1k100"): # Define cache cache_root = get_data_cache_or_nothing("i1k-cache/") # Define image properties image_config = {"type": "image", "height": 224, "width": 224} # Define label properties label_config = {"type": "label", "binary": False} # Define Augmentations augmentation = {"type": "image", "center": False, "flip_enable": True, "scale": [0.08, 1.0], "do_area_scale": True, "horizontal_distortion": [0.75, 1.33], "lighting": [0.0, 0.01], "contrast": [0.9, 1.1], "brightness": [0.9, 1.1], "saturation": [0.9, 1.1] } # Dont do augemtations on test set if(valid_set): return{'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config]} # Do augmentations on training set return{'manifest_filename': manifest_file, 'manifest_root': os.path.dirname(manifest_file), 'batch_size': batch_size, 'block_size': 5000, 'cache_directory': cache_root, 'etl': [image_config, label_config], 'augmentation': [augmentation]} else: raise NameError("Unkown dataset.Choose correct dataset")