def run(self, options): labeler = None if options.labeler is None else labelers.registry[ options.labeler] # Wait to instantiate the corpus writer until we know the dimensionality of the descriptors we'll be writing writer = None log.info('Writing SAM corpus to %s' % options.dest_corpus) filenames = open(options.file_list).readlines() for i, filename in enumerate(filenames): filename = filename.strip() log.info('Processing image %d/%d' % (i + 1, len(filenames))) descriptor = color_gist( filename) if options.color else grayscale_gist(filename) if writer is None: dim = descriptor.size writer = CorpusWriter(options.dest_corpus, data_series='sam', dim=dim) normalized_descriptor = l2_normalize(descriptor) doc_label = labeler(filename) if labeler else None writer.write_doc(ascolvector(normalized_descriptor), name=filename, label=doc_label) writer.close()
def run(self, options): labeler = labelers.registry[options.labeler] # Wait to instantiate the corpus writer until we know the dimensionality of the descriptors we'll be writing filenames = open(options.file_list).readlines() labels = [labeler(each) for each in filenames] class_list = sorted(set(labels)) writer = ArffWriter(options.dest, class_list=class_list) log.info('Writing GIST data to %s' % options.dest) for i, (filename, label) in enumerate(izip(filenames, labels)): filename = filename.strip() log.info('Processing image %d/%d' % (i+1, len(filenames))) descriptor = color_gist(filename) if options.color else grayscale_gist(filename) if options.normalize: descriptor = l2_normalize(descriptor) writer.write_example(descriptor, label) writer.close()
def run(self, options): labeler = labelers.registry[options.labeler] # Wait to instantiate the corpus writer until we know the dimensionality of the descriptors we'll be writing filenames = open(options.file_list).readlines() labels = [labeler(each) for each in filenames] class_list = sorted(set(labels)) writer = ArffWriter(options.dest, class_list=class_list) log.info('Writing GIST data to %s' % options.dest) for i, (filename, label) in enumerate(izip(filenames, labels)): filename = filename.strip() log.info('Processing image %d/%d' % (i + 1, len(filenames))) descriptor = color_gist( filename) if options.color else grayscale_gist(filename) if options.normalize: descriptor = l2_normalize(descriptor) writer.write_example(descriptor, label) writer.close()
def run(self, options): labeler = None if options.labeler is None else labelers.registry[options.labeler] # Wait to instantiate the corpus writer until we know the dimensionality of the descriptors we'll be writing writer = None log.info('Writing SAM corpus to %s' % options.dest_corpus) filenames = open(options.file_list).readlines() for i, filename in enumerate(filenames): filename = filename.strip() log.info('Processing image %d/%d' % (i+1, len(filenames))) descriptor = color_gist(filename) if options.color else grayscale_gist(filename) if writer is None: dim = descriptor.size writer = CorpusWriter(options.dest_corpus, data_series='sam', dim=dim) normalized_descriptor = l2_normalize(descriptor) doc_label = labeler(filename) if labeler else None writer.write_doc(ascolvector(normalized_descriptor), name=filename, label=doc_label) writer.close()