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


Python cityscapes.coco_to_cityscapes_id方法代码示例

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


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

示例1: convert_coco_blob_to_cityscapes_blob

# 需要导入模块: from datasets import cityscapes [as 别名]
# 或者: from datasets.cityscapes import coco_to_cityscapes_id [as 别名]
def convert_coco_blob_to_cityscapes_blob(coco_blob, convert_func):
    # coco blob (81, ...) or (81*4, ...)
    coco_shape = coco_blob.shape
    leading_factor = int(coco_shape[0] / NUM_COCO_CLS)
    tail_shape = list(coco_shape[1:])
    assert leading_factor == 1 or leading_factor == 4

    # Reshape in [num_classes, ...] form for easier manipulations
    coco_blob = coco_blob.reshape([NUM_COCO_CLS, -1] + tail_shape)
    # Default initialization uses Gaussian with mean and std to match the
    # existing parameters
    std = coco_blob.std()
    mean = coco_blob.mean()
    cs_shape = [NUM_CS_CLS] + list(coco_blob.shape[1:])
    cs_blob = (np.random.randn(*cs_shape) * std + mean).astype(np.float32)

    # Replace random parameters with COCO parameters if class mapping exists
    for i in range(NUM_CS_CLS):
        coco_cls_id = getattr(cs, convert_func)(i)
        if coco_cls_id >= 0:  # otherwise ignore (rand init)
            cs_blob[i] = coco_blob[coco_cls_id]

    cs_shape = [NUM_CS_CLS * leading_factor] + tail_shape
    return cs_blob.reshape(cs_shape) 
开发者ID:roytseng-tw,项目名称:Detectron.pytorch,代码行数:26,代码来源:convert_coco_model_to_cityscapes.py


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