本文整理匯總了Python中utils.boxes.boxes_area方法的典型用法代碼示例。如果您正苦於以下問題:Python boxes.boxes_area方法的具體用法?Python boxes.boxes_area怎麽用?Python boxes.boxes_area使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.boxes
的用法示例。
在下文中一共展示了boxes.boxes_area方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: map_rois_to_fpn_levels
# 需要導入模塊: from utils import boxes [as 別名]
# 或者: from utils.boxes import boxes_area [as 別名]
def map_rois_to_fpn_levels(rois, k_min, k_max):
"""Determine which FPN level each RoI in a set of RoIs should map to based
on the heuristic in the FPN paper.
"""
# Compute level ids
areas, neg_idx = box_utils.boxes_area(rois)
areas[neg_idx] = 0 # np.sqrt will remove the entries with negative value
s = np.sqrt(areas)
s0 = cfg.FPN.ROI_CANONICAL_SCALE # default: 224
lvl0 = cfg.FPN.ROI_CANONICAL_LEVEL # default: 4
# Eqn.(1) in FPN paper
target_lvls = np.floor(lvl0 + np.log2(s / s0 + 1e-6))
target_lvls = np.clip(target_lvls, k_min, k_max)
# Mark to discard negative area roi. See utils.fpn.add_multilevel_roi_blobs
# target_lvls[neg_idx] = -1
return target_lvls
示例2: combine_heatmaps_size_dep
# 需要導入模塊: from utils import boxes [as 別名]
# 或者: from utils.boxes import boxes_area [as 別名]
def combine_heatmaps_size_dep(hms_ts, ds_ts, us_ts, boxes, heur_f):
"""Combines heatmaps while taking object sizes into account."""
assert len(hms_ts) == len(ds_ts) and len(ds_ts) == len(us_ts), \
'All sets of hms must be tagged with downscaling and upscaling flags'
# Classify objects into small+medium and large based on their box areas
areas = box_utils.boxes_area(boxes)
sm_objs = areas < cfg.TEST.KPS_AUG.AREA_TH
l_objs = areas >= cfg.TEST.KPS_AUG.AREA_TH
# Combine heatmaps computed under different transformations for each object
hms_c = np.zeros_like(hms_ts[0])
for i in range(hms_c.shape[0]):
hms_to_combine = []
for hms_t, ds_t, us_t in zip(hms_ts, ds_ts, us_ts):
# Discard downscaling predictions for small and medium objects
if sm_objs[i] and ds_t:
continue
# Discard upscaling predictions for large objects
if l_objs[i] and us_t:
continue
hms_to_combine.append(hms_t[i])
hms_c[i] = heur_f(hms_to_combine)
return hms_c
示例3: map_rois_to_fpn_levels
# 需要導入模塊: from utils import boxes [as 別名]
# 或者: from utils.boxes import boxes_area [as 別名]
def map_rois_to_fpn_levels(rois, k_min, k_max):
"""Determine which FPN level each RoI in a set of RoIs should map to based
on the heuristic in the FPN paper.
"""
# Compute level ids
s = np.sqrt(box_utils.boxes_area(rois))
s0 = cfg.FPN.ROI_CANONICAL_SCALE # default: 224
lvl0 = cfg.FPN.ROI_CANONICAL_LEVEL # default: 4
# Eqn.(1) in FPN paper
target_lvls = np.floor(lvl0 + np.log2(s / s0 + 1e-6))
target_lvls = np.clip(target_lvls, k_min, k_max)
return target_lvls
示例4: map_rois_to_fpn_levels
# 需要導入模塊: from utils import boxes [as 別名]
# 或者: from utils.boxes import boxes_area [as 別名]
def map_rois_to_fpn_levels(rois, k_min, k_max):
# Compute level ids
s = np.sqrt(box_utils.boxes_area(rois))
s0 = cfg.FPN.ROI_CANONICAL_SCALE # default: 224
lvl0 = cfg.FPN.ROI_CANONICAL_LEVEL # default: 4
lvls = np.floor(lvl0 + np.log2(s / s0 + 1e-6)) # Eqn.(1) in FPN paper
lvls = np.clip(lvls, k_min, k_max)
# lvls is a list of length len(rois) with a ID from k_min to k_max, as to
# where it maps to. This might lead to some levels from k_min to k_max not
# getting any rois mapped to them.
return lvls