Object detectors like Faster R-CNN and SSD generate a dense set of predefined bounding boxes called anchors at every position on a feature grid. Each anchor serves as an initial guess that the network refines during training.
Given a square feature grid size, the original image size, a list of scales, and a list of aspect ratios, generate all anchor boxes in image coordinates.
Iterate over grid cells in row-major order (i then j), and for each cell iterate over scales then aspect ratios.
Input:
feature_size = 1, image_size = 8, scales = [4], aspect_ratios = [1.0]
Output:
[[2.0, 2.0, 6.0, 6.0]]
stride = 8, center = (4, 4), w = 4, h = 4. Box = [4-2, 4-2, 4+2, 4+2].
Input:
feature_size = 2, image_size = 8, scales = [2], aspect_ratios = [1.0]
Output:
[[1.0, 1.0, 3.0, 3.0], [5.0, 1.0, 7.0, 3.0], [1.0, 5.0, 3.0, 7.0], [5.0, 5.0, 7.0, 7.0]]
stride = 4. The four centers are (2,2), (6,2), (2,6), (6,6). Each box has w = 2, h = 2.
The stride tells you how many image pixels each feature cell spans. The center of cell (i, j) is at ((j + 0.5) * stride, (i + 0.5) * stride).
For a given scale s and aspect ratio r, width = s * sqrt(r) and height = s / sqrt(r). This keeps the anchor area close to s * s regardless of aspect ratio.
Sign in to take notes on this problem
Accepts: number
Accepts: number
Accepts: array
Accepts: array
Object detectors like Faster R-CNN and SSD generate a dense set of predefined bounding boxes called anchors at every position on a feature grid. Each anchor serves as an initial guess that the network refines during training.
Given a square feature grid size, the original image size, a list of scales, and a list of aspect ratios, generate all anchor boxes in image coordinates.
Iterate over grid cells in row-major order (i then j), and for each cell iterate over scales then aspect ratios.
Input:
feature_size = 1, image_size = 8, scales = [4], aspect_ratios = [1.0]
Output:
[[2.0, 2.0, 6.0, 6.0]]
stride = 8, center = (4, 4), w = 4, h = 4. Box = [4-2, 4-2, 4+2, 4+2].
Input:
feature_size = 2, image_size = 8, scales = [2], aspect_ratios = [1.0]
Output:
[[1.0, 1.0, 3.0, 3.0], [5.0, 1.0, 7.0, 3.0], [1.0, 5.0, 3.0, 7.0], [5.0, 5.0, 7.0, 7.0]]
stride = 4. The four centers are (2,2), (6,2), (2,6), (6,6). Each box has w = 2, h = 2.
The stride tells you how many image pixels each feature cell spans. The center of cell (i, j) is at ((j + 0.5) * stride, (i + 0.5) * stride).
For a given scale s and aspect ratio r, width = s * sqrt(r) and height = s / sqrt(r). This keeps the anchor area close to s * s regardless of aspect ratio.
Sign in to take notes on this problem
Accepts: number
Accepts: number
Accepts: array
Accepts: array