objectscope.anchor_bbox_utils

Classes

AnchorMiner

Functions

boxes2wh(boxes)

wh2ratio(wh)

best_ratio(ac_wh, gt_wh)

fitness(ac_wh, gt_wh[, EDGE_RATIO_THRESHOLD])

best_recall(ac_wh, gt_wh[, EDGE_RATIO_THRESHOLD])

estimate_clusters(values, num_clusters[, iter])

visualize_clusters(values, centers)

evolve(sizes, ratios, gt_wh[, iterations, ...])

generate_cell_anchors([sizes, aspect_ratios])

Generate a tensor storing canonical anchor boxes, which are all anchor

_wh2size(gt_wh)

_boxes2wh(boxes)

get_size_ratio_fitness_score(sizes, ratios, gt_wh)

coco_annotation_to_df(coco_annotation_file)

Module Contents

objectscope.anchor_bbox_utils.boxes2wh(boxes)[source]
objectscope.anchor_bbox_utils.wh2ratio(wh)[source]
objectscope.anchor_bbox_utils.best_ratio(ac_wh, gt_wh)[source]
objectscope.anchor_bbox_utils.fitness(ac_wh, gt_wh, EDGE_RATIO_THRESHOLD=0.25)[source]
objectscope.anchor_bbox_utils.best_recall(ac_wh, gt_wh, EDGE_RATIO_THRESHOLD=0.25)[source]
objectscope.anchor_bbox_utils.estimate_clusters(values, num_clusters, iter=100)[source]
objectscope.anchor_bbox_utils.visualize_clusters(values, centers)[source]
objectscope.anchor_bbox_utils.evolve(sizes, ratios, gt_wh, iterations=10000, probability=0.9, muy=1, sigma=0.05, fit_fn=fitness, verbose=False)[source]
objectscope.anchor_bbox_utils.generate_cell_anchors(sizes=(32, 64, 128, 256, 512), aspect_ratios=(0.5, 1, 2))[source]

Generate a tensor storing canonical anchor boxes, which are all anchor boxes of different sizes and aspect_ratios centered at (0, 0). We can later build the set of anchors for a full feature map by shifting and tiling these tensors (see meth:_grid_anchors).

Parameters:
  • sizes (tuple[float])

  • aspect_ratios (tuple[float]])

Returns:

Array of shape (len(sizes) * len(aspect_ratios), 4) storing anchor boxes

in XYXY format.

objectscope.anchor_bbox_utils._wh2size(gt_wh)[source]
objectscope.anchor_bbox_utils._boxes2wh(boxes)[source]
objectscope.anchor_bbox_utils.get_size_ratio_fitness_score(sizes, ratios, gt_wh)[source]
objectscope.anchor_bbox_utils.coco_annotation_to_df(coco_annotation_file)[source]
class objectscope.anchor_bbox_utils.AnchorMiner(coco_annotation_file: str)[source]

Bases: object

coco_annotation_file
annotations_df
get_sizes_ratios(num_sizes=5, num_ratios=3)[source]
tune_sizes_ratios(sizes: None | List = None, ratios: None | List = None, iterations=10000, include_fitness_score=True)[source]