question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC] NMS API Change

See original GitHub issue

To support gluoncv object detection model, nms operator api needs to be changed. While the old api is nms(data, valid_count, overlap_threshold, force_suppress, topk), new api is non_max_suppression(data, valid_count, return_indices, iou_threshold, force_suppress, topk, id_axis, invalid_to_bottom).

  • overlap_threshold is changed to iou_threshold to align with intersection over union(IoU) in object detection context.
  • id_axis is the axis of class categories
  • invalid_to_bottom is to decide whether to move invalid boxes to the bottom.
  • return_indices indicating whether to return box or box indices.

This new api can support both mxnet legacy ssd model and gluoncv box_nms op.

Some investigation for nms implementation in other frameworks:

Tensorflow and Pytorch:
non_max_suppression(
    boxes,
    scores,
    max_output_size,
    iou_threshold=0.5,
    score_threshold=float('-inf'),
)
Note that this nms is for single instance and boxes/scores doesn't include batch axis: 
boxes: A 2-D float Tensor of shape [num_boxes, 4].
scores: A 1-D float Tensor of shape [num_boxes] representing a single score corresponding to each box (each row of boxes).
The output is selected indices which has variable length depending on the input data:
selected_indices: A 1-D integer Tensor of shape [M] representing the selected indices from the boxes tensor, where M <= max_output_size.

Keras:
DecodeDetections Layer(
    confidence_thresh=0.01,
    iou_threshold=0.45,
    top_k=200,
    nms_max_output_size=400,
    coords='centroids',
    normalize_coords=True,
    img_height=None,
    img_width=None,
)
Input shape:
    3D tensor of shape (batch_size, n_boxes, n_classes + 12).
Output shape:
    3D tensor of shape (batch_size, top_k, 6).
This doesn't only contains nms but some other preprocessing steps.

Proposed TVM non_max_suppression(
    data,
    valid_counts,
    max_output_size=-1,
    iou_threshold=0.5,
    force_suppress=False,
    top_k=-1,
    id_index=0,
    return_indices=True,
    invalid_to_bottom=True,
)
data : tvm.Tensor
    3-D tensor with shape [batch_size, num_anchors, 6].
    The last dimension should be in format of  
    [class_id, score, box_left, box_top, box_right,  box_bottom].
valid_count : tvm.Tensor
    1-D tensor for valid number of boxes.
out : tvm.Tensor
    3-D tensor with shape [batch_size, num_anchors, 6].

One key difference between tvm implementation and tf/pt implementation is tvm always returns a fixed shape output and pad invalid boxed with -1, while tf/pt returns a variable shape tensor denpending on input data values.

@zhreshold @tqchen @Laurawly @vinx13 Do you have concerns about naming or other aspects?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:42 (42 by maintainers)

github_iconTop GitHub Comments

1reaction
tqchencommented, Feb 22, 2019

As long as the default behavior is the most common one(as in Tf pt) it is fine

1reaction
zhresholdcommented, Feb 15, 2019

@Laurawly Actually TF always return selected_indices, and they expect users to tf.gather boxes by these returned indices. I suppose @kevinthesun is going to support both behavior, either return boxes or indices by flag return_indices

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 2614: An API for Service Location
RFC 2614 Service Location API June 1999 only change the property values in the running agent program and do not affect the values...
Read more >
RFC 9196 - YANG Modules Describing Capabilities for ...
YANG Modules Describing Capabilities for Systems and Datastore Update Notifications (RFC 9196, February 2022)
Read more >
OpenNMS Release Notes
Remote Poller API Change: Due to internal API changes, the Remote Poller API has changed in OpenNMS 17. If you upgrade to OpenNMS...
Read more >
RFC 2544 Testing Overview - TechLibrary - Juniper Networks
The RFC 2544 test methodology defines specific set of tests that operator can use to measure and report the performance characteristics of network...
Read more >
Introduction to NETCONF - API Reference - Huawei Support
NETCONF was defined in RFC 4741 by the Internet Engineering Task Force (IETF) and revised in RFC 6241. NETCONF provides a standard framework...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found