当前位置: 首页>>代码示例>>Python>>正文


Python MemoryDescriptorIndex.iterkeys方法代码示例

本文整理汇总了Python中smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex.iterkeys方法的典型用法代码示例。如果您正苦于以下问题:Python MemoryDescriptorIndex.iterkeys方法的具体用法?Python MemoryDescriptorIndex.iterkeys怎么用?Python MemoryDescriptorIndex.iterkeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex的用法示例。


在下文中一共展示了MemoryDescriptorIndex.iterkeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_iterkeys

# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import iterkeys [as 别名]
 def test_iterkeys(self):
     i = MemoryDescriptorIndex()
     descrs = [random_descriptor() for _ in xrange(100)]
     i.add_many_descriptors(descrs)
     ntools.assert_equal(set(i.iterkeys()),
                         set(d.uuid() for d in descrs))
开发者ID:dhandeo,项目名称:SMQTK,代码行数:8,代码来源:test_DI_memory.py

示例2: MemoryDescriptorIndex

# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import iterkeys [as 别名]
    log.info("Loading plugins")
    descriptor_index = MemoryDescriptorIndex(file_cache=DESCRIPTOR_INDEX_FILE_CACHE)
    #: :type: smqtk.algorithms.Classifier
    classifier = from_plugin_config(classifier_config['plugins']['classifier'],
                                    get_classifier_impls())
    c_factory = ClassificationElementFactory(MemoryClassificationElement, {})

    #: :type: dict[str, list[str]]
    phone2shas = json.load(open(PHONE_SHA1_JSON))
    #: :type: dict[str, float]
    phone2score = {}

    log.info("Classifying phone imagery descriptors")
    i = 0
    descriptor_index_shas = set(descriptor_index.iterkeys())
    for p in phone2shas:
        log.info('%s (%d / %d)', p, i + 1, len(phone2shas))
        # Not all source "images" have descriptors since some URLs returned
        # non-image files. Intersect phone sha's with what was actually
        # computed. Warn if this reduces descriptors for classification to zero.
        indexed_shas = set(phone2shas[p]) & descriptor_index_shas
        if not indexed_shas:
            raise RuntimeError(
                "Phone number '%s' has no valid images associated "
                "with it.\nBefore:\n%s\n\nAfter:\n%s"
                % (p, phone2shas[p], indexed_shas))

        descriptor_elems = descriptor_index.get_many_descriptors(*indexed_shas)
        e2c = classifier.classify_async(descriptor_elems, c_factory,
                                        use_multiprocessing=True, ri=1.)
开发者ID:Kitware,项目名称:SMQTK,代码行数:32,代码来源:score_phone_numbers.py


注:本文中的smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex.iterkeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。