Пример #1
0
def main(sname, iteration, cropped, full, flipped, force, dataset, storage_name):
    new_name = '%s-%d' % (sname, iteration)
    if dataset == 'segmented':
        cub = CUB_200_2011_Segmented(settings.CUB_ROOT, full=full)
    elif dataset == 'part-head':
        cub = CUB_200_2011_Parts_Head(settings.CUB_ROOT, full=full)
    elif dataset == 'part-body':
        cub = CUB_200_2011_Parts_Body(settings.CUB_ROOT, full=full)
    elif dataset == 'part-head-rf-new':
        cub = CUB_200_2011(settings.CUB_ROOT, 'images_head_rf_new')
    elif dataset == 'part-body-rf-new':
        cub = CUB_200_2011(settings.CUB_ROOT, 'images_body_rf_new')
    else:
        cub = CUB_200_2011(settings.CUB_ROOT, images_folder_name=dataset, full=full)
    if not storage_name:
        ft_storage = datastore(settings.storage(new_name))
    else:
        ft_storage = datastore(settings.storage(storage_name))
    ft_extractor = CNN_Features_CAFFE_REFERENCE(ft_storage, model_file=settings.model(new_name), pretrained_file=settings.pretrained(new_name), full=full, crop_index=0)
    number_of_images_in_dataset = sum(1 for _ in cub.get_all_images())
    bar = pyprind.ProgBar(number_of_images_in_dataset, width=80)
    for t, des in ft_extractor.extract_all(cub.get_all_images(), flip=flipped, crop=cropped, bbox=cub.get_bbox(), force=force):
        bar.update()
    print 'DONE'
Пример #2
0
def main(sname, iteration, cropped, full, flipped, force, dataset,
         storage_name):
    new_name = '%s-%d' % (sname, iteration)
    if dataset == 'segmented':
        cub = CUB_200_2011_Segmented(settings.CUB_ROOT, full=full)
    elif dataset == 'part-head':
        cub = CUB_200_2011_Parts_Head(settings.CUB_ROOT, full=full)
    elif dataset == 'part-body':
        cub = CUB_200_2011_Parts_Body(settings.CUB_ROOT, full=full)
    elif dataset == 'part-head-rf-new':
        cub = CUB_200_2011(settings.CUB_ROOT, 'images_head_rf_new')
    elif dataset == 'part-body-rf-new':
        cub = CUB_200_2011(settings.CUB_ROOT, 'images_body_rf_new')
    else:
        cub = CUB_200_2011(settings.CUB_ROOT,
                           images_folder_name=dataset,
                           full=full)
    if not storage_name:
        ft_storage = datastore(settings.storage(new_name))
    else:
        ft_storage = datastore(settings.storage(storage_name))
    ft_extractor = CNN_Features_CAFFE_REFERENCE(
        ft_storage,
        model_file=settings.model(new_name),
        pretrained_file=settings.pretrained(new_name),
        full=full,
        crop_index=0)
    number_of_images_in_dataset = sum(1 for _ in cub.get_all_images())
    bar = pyprind.ProgBar(number_of_images_in_dataset, width=80)
    for t, des in ft_extractor.extract_all(cub.get_all_images(),
                                           flip=flipped,
                                           crop=cropped,
                                           bbox=cub.get_bbox(),
                                           force=force):
        bar.update()
    print 'DONE'
Пример #3
0
features_storage_part_head = datastore(settings.storage('ccphead'))
feature_extractor_part_head = CNN_Features_CAFFE_REFERENCE(
    features_storage_part_head, full=False)

features_storage_part_body = datastore(settings.storage('ccpbody'))
feature_extractor_part_body = CNN_Features_CAFFE_REFERENCE(
    features_storage_part_body, full=False)

number_of_images_in_dataset = sum(1 for _ in cub.get_all_images())

print 'cub, regular'
bar = pyprind.ProgBar(number_of_images_in_dataset, width=100)
for t, des in feature_extractor.extract_all(cub.get_all_images(),
                                            flip=False,
                                            crop=False,
                                            bbox=None,
                                            force=False):
    bar.update()
print '----------------------'

print 'cub, regular, ft'
bar = pyprind.ProgBar(number_of_images_in_dataset, width=100)
for t, des in feature_extractor_ft.extract_all(cub.get_all_images(),
                                               flip=False,
                                               crop=False,
                                               bbox=None,
                                               force=False):
    bar.update()
print '----------------------'
Пример #4
0
feature_extractor_flipped_cropped = CNN_Features_CAFFE_REFERENCE(features_storage_flipped_cropped, full=False)

features_storage_flipped_cropped_ft = datastore(settings.storage('ccfcft'))
feature_extractor_flipped_cropped_ft = CNN_Features_CAFFE_REFERENCE(features_storage_flipped_cropped_ft, full=True)

features_storage_part_head = datastore(settings.storage('ccphead'))
feature_extractor_part_head = CNN_Features_CAFFE_REFERENCE(features_storage_part_head, full=False)

features_storage_part_body = datastore(settings.storage('ccpbody'))
feature_extractor_part_body = CNN_Features_CAFFE_REFERENCE(features_storage_part_body, full=False)

number_of_images_in_dataset = sum(1 for _ in cub.get_all_images())

print 'cub, regular'
bar = pyprind.ProgBar(number_of_images_in_dataset, width=100)
for t, des in feature_extractor.extract_all(cub.get_all_images(), flip=False, crop=False, bbox=None, force=False):
    bar.update()
print '----------------------'

print 'cub, regular, ft'
bar = pyprind.ProgBar(number_of_images_in_dataset, width=100)
for t, des in feature_extractor_ft.extract_all(cub.get_all_images(), flip=False, crop=False, bbox=None, force=False):
    bar.update()
print '----------------------'

print 'cub, flipped'
bar = pyprind.ProgBar(number_of_images_in_dataset, width=100)
for t, des in feature_extractor_flipped.extract_all(cub.get_all_images(), flip=True, crop=False, bbox=None, force=False):
    bar.update()
print '----------------------'