本文整理汇总了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)
# #########################################################################################