Esempio n. 1
0
def _add_fast_rcnn_head(model, add_roi_box_head_func, blob_in, dim_in,
                        spatial_scale_in):
    """
    blob_in:
        [BlobReference("gpu_0/fpn_res5_2_sum"),
         BlobReference("gpu_0/fpn_res4_22_sum"),
         BlobReference("gpu_0/fpn_res3_3_sum"),
         BlobReference("gpu_0/fpn_res2_2_sum")]
    spatial_scale_in:
        [0.03125, 0.0625, 0.125, 0.25]
    dim_in:
        256
    """
    """Add a Fast R-CNN head to the model."""
    # 对fpn中的每一层提取特征图
    blob_frcn, dim_frcn = add_roi_box_head_func(model, blob_in, dim_in,
                                                spatial_scale_in)

    # 添加输出
    fast_rcnn_heads.add_fast_rcnn_outputs(model, blob_frcn, dim_frcn)

    if model.train:
        # 添加损失,梯度以及度量方法
        loss_gradients = fast_rcnn_heads.add_fast_rcnn_losses(model)
    else:
        loss_gradients = None
    return loss_gradients
Esempio n. 2
0
 def _single_gpu_build_func(model):
     """Builds the model on a single GPU. Can be called in a loop over GPUs
     with name and device scoping to create a data parallel model."""
     blob, dim, spatial_scale = add_conv_body_func(model)
     if not model.train:
         model.conv_body_net = model.net.Clone('conv_body_net')
     rfcn_heads.add_rfcn_outputs(model, blob, dim, dim_reduce, spatial_scale)
     if model.train:
         loss_gradients = fast_rcnn_heads.add_fast_rcnn_losses(model)
     return loss_gradients if model.train else None
Esempio n. 3
0
 def _single_gpu_build_func(model):
     """Builds the model on a single GPU. Can be called in a loop over GPUs
     with name and device scoping to create a data parallel model."""
     blob, dim, spatial_scale = add_conv_body_func(model)
     if not model.train:
         model.conv_body_net = model.net.Clone('conv_body_net')
     rfcn_heads.add_rfcn_outputs(model, blob, dim, dim_reduce, spatial_scale)
     if model.train:
         loss_gradients = fast_rcnn_heads.add_fast_rcnn_losses(model)
     return loss_gradients if model.train else None
Esempio n. 4
0
def _add_fast_rcnn_head(model, add_roi_box_head_func, blob_in, dim_in,
                        spatial_scale_in):
    """Add a Fast R-CNN head to the model."""
    blob_frcn, dim_frcn = add_roi_box_head_func(model, blob_in, dim_in,
                                                spatial_scale_in)
    fast_rcnn_heads.add_fast_rcnn_outputs(model, blob_frcn, dim_frcn)
    if model.train:
        loss_gradients = fast_rcnn_heads.add_fast_rcnn_losses(model)
    else:
        loss_gradients = None
    return loss_gradients
Esempio n. 5
0
def _add_fast_rcnn_head(
    model, add_roi_box_head_func, blob_in, dim_in, spatial_scale_in
):
    """Add a Fast R-CNN head to the model."""
    blob_frcn, dim_frcn = add_roi_box_head_func(
        model, blob_in, dim_in, spatial_scale_in
    )
    fast_rcnn_heads.add_fast_rcnn_outputs(model, blob_frcn, dim_frcn)
    if model.train:
        loss_gradients = fast_rcnn_heads.add_fast_rcnn_losses(model)
    else:
        loss_gradients = None
    return loss_gradients