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


Python MemoryDescriptorIndex.get_many_descriptors方法代码示例

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


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

示例1: test_get_descriptors

# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import get_many_descriptors [as 别名]
    def test_get_descriptors(self):
        descrs = [
            random_descriptor(),   # [0]
            random_descriptor(),   # [1]
            random_descriptor(),   # [2]
            random_descriptor(),   # [3]
            random_descriptor(),   # [4]
        ]
        index = MemoryDescriptorIndex()
        index.add_many_descriptors(descrs)

        # single descriptor reference
        r = index.get_descriptor(descrs[1].uuid())
        ntools.assert_equal(r, descrs[1])

        # multiple descriptor reference
        r = list(index.get_many_descriptors([descrs[0].uuid(),
                                             descrs[3].uuid()]))
        ntools.assert_equal(len(r), 2)
        ntools.assert_equal(set(r),
                            {descrs[0], descrs[3]})
开发者ID:dhandeo,项目名称:SMQTK,代码行数:23,代码来源:test_DI_memory.py

示例2: set

# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import get_many_descriptors [as 别名]
    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.)
        pos_scores = [c['positive'] for c in e2c.values()]

        # Max of pool
        phone2score[p] = max(pos_scores)

        i += 1

    log.info("Saving score map")
    csv.writer(open(PHONE2SCORE_OUTPUT_FILEPATH, 'w')) \
        .writerows(sorted(phone2score.iteritems()))


log.info("Done")
开发者ID:Kitware,项目名称:SMQTK,代码行数:33,代码来源:score_phone_numbers.py


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