def get_fps(detector, i, fileobj, size): ag.info('{0} Initial processing {1}'.format(i, fileobj.img_id)) gen = generate_random_patches([fileobj.path], size, per_image=PER_IMAGE) neg_feats = [] radii = detector.settings['spread_radii'] psize = detector.settings['subsample_size'] rotspread = detector.settings.get('rotation_spreading_radius', 0) cb = detector.settings.get('crop_border') setts = dict(spread_radii=radii, subsample_size=psize, rotation_spreading_radius=rotspread, crop_border=cb) for neg in itr.islice(gen, PER_IMAGE): #images.append(neg) feat = detector.descriptor.extract_features(neg, settings=setts) neg_feats.append(feat) return neg_feats
import os.path import glob import numpy as np import amitgroup as ag import itertools from scipy.stats import mstats from train_superimposed import generate_random_patches from settings import load_settings settings = load_settings(settings_file) descriptor = gv.load_descriptor(settings) path = os.path.expandvars(settings['detector']['neg_dir']) files = sorted(glob.glob(path)) gen = generate_random_patches(files, (100, 100), seed=0, per_image=5) cut = 4 radii = settings['detector']['spread_radii'] psize = settings['detector']['subsample_size'] mm = [] for i, im in itertools.islice(enumerate(gen), limit): print 'Processing {}'.format(i) feats = descriptor.extract_features(im, settings=dict(spread_radii=radii, subsample_size=psize, crop_border=cut)) m = feats.mean() mm.append(m) import matplotlib.pylab as plt