8.1.2.7. blueoil.post_processor
¶
8.1.2.7.1. Module Contents¶
8.1.2.7.1.1. Classes¶
Yolov2 postprocess. |
|
Non Maximum Suppression |
|
Bilinear |
|
GaussianHeatmapToJoints |
8.1.2.7.1.2. Functions¶
|
|
|
|
-
blueoil.post_processor.
_softmax
(x)¶
-
class
blueoil.post_processor.
FormatYoloV2
(image_size, classes, anchors, data_format)¶ Bases:
blueoil.data_processor.Processor
Yolov2 postprocess. Format outputs of yolov2 last convolution to object detection style.
-
property
num_cell
(self)¶
-
static
sigmoid
(x)¶
-
_split_prediction
(self, outputs)¶ Separate combined final convolution outputs to predictions.
- Parameters
outputs – combined final convolution outputs 4D Tensor. shape is [batch_size, num_cell[0], num_cell[1], (num_classes + 5) * boxes_per_cell]
- Returns
[batch_size, num_cell[0], num_cell[1], boxes_per_cell, num_classes] Tensor: [batch_size, num_cell[0], num_cell[1], boxes_per_cell, 1] Tensor: [batch_size, num_cell[0], num_cell[1], boxes_per_cell, 4(center_x, center_y, w, h)]
- Return type
Tensor
-
_offset_boxes
(self, batch_size, num_cell_y, num_cell_x)¶ Numpy implementing of offset_boxes. Return yolo space offset of x and y and w and h.
- Parameters
batch_size (int) – batch size
num_cell_y – Number of cell y. The spatial dimension of the final convolutional features.
num_cell_x – Number of cell x. The spatial dimension of the final convolutional features.
-
_convert_boxes_space_from_yolo_to_real
(self, predict_boxes)¶ Convert predict boxes space size from yolo to real.
Real space boxes coordinates are in the interval [0, image_size]. Yolo space boxes x,y are in the interval [-1, 1]. w,h are in the interval [-inf, +inf].
- Parameters
predict_boxes – 5D np.ndarray. shape is [batch_size, num_cell, num_cell, boxes_per_cell, 4(center_x, center_y, w, h)].
- Returns
- 5D np.ndarray,
shape is [batch_size, num_cell, num_cell, boxes_per_cell, 4(center_x, center_y, w, h)].
- Return type
resized_boxes
-
__call__
(self, outputs, **kwargs)¶ - Parameters
outputs (np.ndarray) –
Outputs of yolov2 last convolution. When data_format is NHWC shape is [
batch_size, num_cell[0], num_cell[1], (num_classes + 5(x, y ,w, h, confidence)) * boxes_per_cell(length of anchors),
]
When data_format is NCHW shape is [
batch_size, (num_classes + 5(x, y ,w, h, confidence)) * boxes_per_cell(length of anchors), num_cell[0], num_cell[1],
]
- Returns
- Contains processed outputs.
outputs: Object detection formatted list op np.ndarray. List is [predict_boxes(np.ndarray), predict_boxes(np.ndarray), …] which length is batch size. Each predict_boxes shape is [num_predict_boxes, 6(x(left), y(top), w, h, class_id, score)]
- Return type
dict
-
property
-
class
blueoil.post_processor.
ExcludeLowScoreBox
(threshold)¶ Bases:
blueoil.data_processor.Processor
-
__call__
(self, outputs, **kwargs)¶ Call processor method for each a element of data.
Return image and labels etc.
-
-
class
blueoil.post_processor.
NMS
(classes, iou_threshold, max_output_size=100, per_class=True)¶ Bases:
blueoil.data_processor.Processor
Non Maximum Suppression
-
_nms
(self, boxes)¶
-
__call__
(self, outputs, **kwargs)¶ - Parameters
outputs – The boxes list of predict boxes for each image. The format is [boxes, boxes, boxes, …]. len(boxes) == batch_size. boxes[image_id] is np.array, the shape is (num_boxes, 6[x(left), y(top), h, w, class_id, sore])
- Returns
- Contains boxes list (list).
- outputs: The boxes list of predict boxes for each image.
The format is [boxes, boxes, boxes, …]. len(boxes) == batch_size. boxes[image_id] is np.array, the shape is (num_boxes, 6[x(left), y(top), h, w, class_id, sore])
- Return type
dict
-
-
class
blueoil.post_processor.
Bilinear
(size, data_format='NHWC', compatible_tensorflow_v1=True)¶ Bases:
blueoil.data_processor.Processor
Bilinear
Change feature map spatial size with bilinear method, currently support only up-sampling.
-
__call__
(self, outputs, **kwargs)¶ - Parameters
outputs (numpy.ndarray) – 4-D ndarray of network outputs to be resized channel-wise.
- Returns
outputs (numpy.ndarray): resized outputs. 4-D ndarray.
- Return type
dict
-
static
_bilinear
(inputs, size, compatible_tensorflow_v1=True)¶
-
-
class
blueoil.post_processor.
Softmax
¶ Bases:
blueoil.data_processor.Processor
-
__call__
(self, outputs, **kwargs)¶ Call processor method for each a element of data.
Return image and labels etc.
-
-
class
blueoil.post_processor.
GaussianHeatmapToJoints
(num_dimensions=2, stride=2, confidence_threshold=0.1)¶ Bases:
blueoil.data_processor.Processor
GaussianHeatmapToJoints
Extract joints from gaussian heatmap. Current version only supports 2D pose estimation.
-
__call__
(self, outputs, *args, **kwargs)¶ Extract joints from gaussian heatmap. Current version only supports 2D pose estimation. :param outputs: output heatmaps, a numpy array of shape (batch_size, height, width, num_joints).
- Returns
outputs: joints, a numpy array of shape (batch_size, num_joints, num_dimensions + 1).
- Return type
all args (dict)
-
-
blueoil.post_processor.
gaussian_heatmap_to_joints
(heatmap, num_dimensions=2, stride=2, confidence_threshold=0.1)¶ - Parameters
heatmap – a numpy array of shape (height, width, num_joints).
num_dimensions – int, it only supports 2 for now.
stride – int, stride = image_height / heatmap_height.
confidence_threshold – float, value range is [0, 1].
- Returns
a numpy array of shape (num_joints, num_dimensions + 1).
- Return type
joints