Utils faster rcnn
RoiPoolingLayer
Bases: Layer
Layer selecting a zone from a ROI in a features map and resize it
Input shape
List of two 4D tensors [X_img, X_roi] with shape:
X_img : list of images
(batch_size, cols, rows, channels)
X_roi : list of ROI with 4 coordinates (x, y, w, h)
(batch_size, nb_rois, 4)
Output shape
5D tensor with shape:
(batch_size, nb_rois, pool_size, pool_size, channels)
pool_size is a parameter of resizing of the features map
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
__init__(pool_size, **kwargs)
Initialization of the layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pool_size |
int
|
Output size of the layer |
required |
call(x, mask=None)
Call to the layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
list
|
List of two tensors 0 -> features maps # Shape (batch_size, cols, rows, channels) 1 -> rois # Shape (batch_size, nb_rois, 4) |
required |
Returns: tensor: images (features maps) cut with the ROIs # Shape (batch_size, nb_rois, cols, rows, nb_channel)
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
cut_feature_map(feature_map, roi)
Cuts a features map with a ROI
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature_map |
input features map Shape : (cols, rows, channels) |
required | |
roi |
input ROI Shape : (4,) |
required |
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
class_loss_cls(y_true, y_pred)
Calculates the classifier classification loss (Cross entropy)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_true |
Model's target. Shape (batch_size, nb_bboxes, nb_classes) |
required | |
y_pred |
Outputs of the model. Shape (batch_size, nb_bboxes, nb_classes) |
required |
Returns: float: Calculated loss
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
get_class_loss_regr(nb_classes)
Gets the classifier regression loss depending on the number of classes of the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb_classes |
int
|
Number of classes of the model |
required |
Returns: Callable: Classifier regression loss
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
get_custom_objects_faster_rcnn(nb_anchors, nb_classes)
Gets the keras custom_objects depending of the number of anchors and of classes of a model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb_anchors |
int
|
Number of anchors of the model |
required |
nb_classes |
int
|
Number of classes of the model |
required |
Returns: dict: Set of customs objects
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
get_rpn_loss_cls(nb_anchors)
Gets the RPN classification loss depending on the number of anchor of the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb_anchors |
int
|
Number of anchors of the model |
required |
Returns: Callable: RPN classification loss
Source code in template_vision/models_training/object_detectors/utils_faster_rcnn.py
get_rpn_loss_regr(nb_anchors)
Gets the RPN regression loss depending on the number of anchor of the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb_anchors |
int
|
Number of anchors of the model |
required |
Returns: Callable: RPN regression loss