本文整理匯總了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)