ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

SSD postprocessing layer

Open krgor opened this issue 6 years ago • 8 comments

ACL version: 20.02.1 OS: Android 8.1

I am trying to implement SSD MobilenetV3 small downloaded from here [tensorflow model zoo] on ACL Graph APIs.

I managed to get all the layers working till last but one layer (before PostProcessing Layer). I have tried to implement post processing layer by 2 different methods available with Graph APIs. But I am struggling to get the correct results.

  1. Using "DetectionPostProcessLayer":
    const int   max_detections            = 100;
    const int   max_classes_per_detection = 1;
    const float nms_score_threshold       = 0.30000001192092896f;
    const float nms_iou_threshold         = 0.2;//0.6000000238418579f;
    const int   num_classes               = 90;
    const float x_scale                   = 10.f;
    const float y_scale                   = 10.f;
    const float h_scale                   = 5.f;
    const float w_scale                   = 5.f;
    std::array<float, 4> scales = { y_scale, x_scale, w_scale, h_scale };

    out_final << DetectionPostProcessLayer(
                    std::move(out_conf),
                    DetectionPostProcessLayerInfo(max_detections, max_classes_per_detection, nms_score_threshold,
                        nms_iou_threshold, num_classes, scales, false, 100, true),
                        get_weights_accessor(data_path, "anchors_t.npy", DataLayout::NCHW)).set_name("DetectionPostProcess");
  1. Using "DetectionOutputLayer":
    const int                          num_classes         = 91;
    const bool                         share_location      = true;
    const DetectionOutputLayerCodeType detection_type      = DetectionOutputLayerCodeType::CENTER_SIZE;
    const int                          keep_top_k          = 100;
    const float                        nms_threshold       = 0.6f;
    const int                          label_id_background = 0;
    const float                        conf_thrs           = 0.15f;
    const int                          top_k               = 100;

    detection_ouput << DetectionOutputLayer(std::move(out_conf), std::move(out_prior),
                                DetectionOutputLayerInfo(num_classes, share_location, detection_type, keep_top_k,
                                    nms_threshold, top_k, label_id_background, conf_thrs));

Both the methods are not giving correct results. I compared the output till last but one layer with Tensorflow output and it is matching. Probably I am doing something wrong.

Can you please help me to define the last layer of SSD MobilenetV3 Small network? Any hint/advise would be of very much help.

Thanks, krgor

krgor avatar Jul 28 '20 15:07 krgor

@morgolock , I have tried with ACL 20.08 and seeing the same issue as previous versions. As you have put v20.08 as milestone; is the mentioned issue fixed with ACL 20.08?

Can you please advise? Thanks, krgor

krgor avatar Sep 05 '20 08:09 krgor

Hi @krgor

I've updated the tag to 20.11, we'll look into this in the next few days.

morgolock avatar Sep 07 '20 07:09 morgolock

@morgolock, Is there any update on this issue? Is it covered in ACL 20.11?

krgor avatar Jan 02 '21 05:01 krgor

Hi @krgor

Please take a look at our example https://github.com/ARM-software/ComputeLibrary/blob/master/examples/graph_ssd_mobilenet.cpp#L680 to see how we configure the DetectionPostProcessLayer in SSD Mobilinet V1.

It's likely the configuration you shared above is not correct.

Hope this helps.

morgolock avatar Jan 04 '21 11:01 morgolock

Hi @krgor

image

Could you please double check making the following changes:

const float nms_score_threshold       = 9.99999993922529e-9;
const float nms_iou_threshold         = 0.6000000238418579;

Hope this helps.

morgolock avatar Jan 05 '21 11:01 morgolock

Thanks @morgolock . I will try this and get back to you.

krgor avatar Jan 06 '21 16:01 krgor

I have tried with mentioned values but it didn't help. Now it just works on all the boxes having confidence more than 9.99999993922529e-9 (very small number).

I have also tried playing with exact same values as "DetectionOutputLayer" of "https://github.com/ARM-software/ComputeLibrary/blob/master/examples/graph_ssd_mobilenet.cpp#L680"; but that also didn't help. Looks like some bug in calculation. Can you please point out the implementation of these layers? I will try to explore more on that.

krgor avatar Feb 04 '21 15:02 krgor

Hi @krgor

You can look at the implementation here:

https://github.com/ARM-software/ComputeLibrary/blob/master/src/runtime/NEON/functions/NEDetectionPostProcessLayer.cpp

Please reopen if you still need support.

morgolock avatar May 10 '21 10:05 morgolock