本文整理匯總了Python中maskrcnn_benchmark.layers.ROIAlign方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.ROIAlign方法的具體用法?Python layers.ROIAlign怎麽用?Python layers.ROIAlign使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maskrcnn_benchmark.layers
的用法示例。
在下文中一共展示了layers.ROIAlign方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ROIAlign [as 別名]
def __init__(self, output_size, scales, sampling_ratio):
"""
Arguments:
output_size (list[tuple[int]] or list[int]): output size for the pooled region
scales (list[float]): scales for each Pooler
sampling_ratio (int): sampling ratio for ROIAlign
"""
super(Pooler, self).__init__()
poolers = []
for scale in scales:
poolers.append(
ROIAlign(
output_size, spatial_scale=scale, sampling_ratio=sampling_ratio
)
)
self.poolers = nn.ModuleList(poolers)
self.output_size = output_size
# get the levels in the feature map by leveraging the fact that the network always
# downsamples by a factor of 2 at each level.
lvl_min = -torch.log2(torch.tensor(scales[0], dtype=torch.float32)).item()
lvl_max = -torch.log2(torch.tensor(scales[-1], dtype=torch.float32)).item()
self.map_levels = LevelMapper(lvl_min, lvl_max)
示例2: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ROIAlign [as 別名]
def __init__(self, output_size, scales):
"""
Arguments:
output_size (list[tuple[int]] or list[int]): output size for the pooled region
scales (list[float]): scales for each Pooler
sampling_ratio (int): sampling ratio for ROIAlign
"""
super(PyramidRROIAlign, self).__init__()
poolers = []
for scale in scales:
poolers.append(
RROIAlign(
output_size, spatial_scale=scale
)
)
self.poolers = nn.ModuleList(poolers)
self.output_size = output_size
# get the levels in the feature map by leveraging the fact that the network always
# downsamples by a factor of 2 at each level.
lvl_min = -torch.log2(torch.tensor(scales[0], dtype=torch.float32)).item()
lvl_max = -torch.log2(torch.tensor(scales[-1], dtype=torch.float32)).item()
self.map_levels = LevelMapper(lvl_min, lvl_max)
示例3: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ROIAlign [as 別名]
def __init__(self, output_size, scales, sampling_ratio, drop_last):
"""
Arguments:
output_size (list[tuple[int]] or list[int]): output size for the pooled region
scales (list[flaot]): scales for each Pooler
sampling_ratio (int): sampling ratio for ROIAlign
drop_last (bool): if passed, drop the last feature map
"""
super(Pooler, self).__init__()
poolers = []
for scale in scales:
poolers.append(
ROIAlign(
output_size, spatial_scale=scale, sampling_ratio=sampling_ratio
)
)
self.poolers = nn.ModuleList(poolers)
self.drop_last = drop_last
示例4: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ROIAlign [as 別名]
def __init__(self, output_size, scales, sampling_ratio, canonical_level=4):
"""
Arguments:
output_size (list[tuple[int]] or list[int]): output size for the pooled region
scales (list[float]): scales for each Pooler
sampling_ratio (int): sampling ratio for ROIAlign
"""
super(Pooler, self).__init__()
poolers = []
for scale in scales:
poolers.append(
ROIAlign(
output_size, spatial_scale=scale, sampling_ratio=sampling_ratio
)
)
self.poolers = nn.ModuleList(poolers)
self.output_size = output_size
# get the levels in the feature map by leveraging the fact that the network always
# downsamples by a factor of 2 at each level.
lvl_min = -torch.log2(torch.tensor(scales[0], dtype=torch.float32)).item()
lvl_max = -torch.log2(torch.tensor(scales[-1], dtype=torch.float32)).item()
self.map_levels = LevelMapper(
lvl_min, lvl_max, canonical_level=canonical_level
)
示例5: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ROIAlign [as 別名]
def __init__(self, output_size, scales, sampling_ratio,
level_map='scale', level_map_kwargs=None): # add by hui
"""
Arguments:
output_size (list[tuple[int]] or list[int]): output size for the pooled region
scales (list[float]): scales for each Pooler
sampling_ratio (int): sampling ratio for ROIAlign
# add by hui
level_map: 'scale' mean origin FPN map;
'fixed' will use given 'level_min' and 'level_max' in level_map_kwargs, such as, 2, 5 mean use P2~P5
"""
super(Pooler, self).__init__()
poolers = []
for scale in scales:
poolers.append(
ROIAlign(
output_size, spatial_scale=scale, sampling_ratio=sampling_ratio
)
)
self.poolers = nn.ModuleList(poolers)
self.output_size = output_size
# get the levels in the feature map by leveraging the fact that the network always
# downsamples by a factor of 2 at each level.
# ######################## changed by hui ################################################
if level_map == 'scale':
lvl_min = -torch.log2(torch.tensor(scales[0], dtype=torch.float32)).item()
lvl_max = -torch.log2(torch.tensor(scales[-1], dtype=torch.float32)).item()
self.map_levels = LevelMapper(lvl_min, lvl_max)
elif level_map == 'fixed':
lvl_min, lvl_max = level_map_kwargs.LEVEL_MIN, level_map_kwargs.LEVEL_MAX
self.map_levels = LevelMapper(lvl_min, lvl_max)
# #########################################################################################