microsoft / microsoft/onnxruntime

Dubious implementation of ROIAlign in 'max' mode

Open
#6,146 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contributions welcome core runtime
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

There are cases, when the results of ROIAlign may be significally different from expected.

Implementation of ROIAlign runs questionably in MAX mode.
https://github.com/microsoft/onnxruntime/blob/7f9d9557b1f4a427dbffa7265af2f478034bcc2f/onnxruntime/core/providers/cpu/object_detection/roialign.cc#L216
I.e., when weighed data feature_map is collected, we commit MAX - operation to all collected data.
So, we return one of weighed value (by [0, 1] - coefficient), which is assuredly less, then all interpolated values.
In the case of centered coordinates of sampling point, nearly 1/4 from expected value is returned.
We need instead, at first, commit interpolation, and afterwards given type of operation (AVG or MAX).
Suggested algorithm is similar to Caffe implementation.

![image](https://user-images.githubusercontent.com/57213286/102330641-dc643400-3f9a-11eb-961f-2dfe4cba37cc.png)
![image](https://user-images.githubusercontent.com/57213286/102331251-a70c1600-3f9b-11eb-9390-72cf6291b989.png)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in onnxruntime/core/providers/cpu/object_detection/roialign.cc around line 216 and inspect how sampled feature-map values are combined in MAX mode. Compare the behavior with the Caffe implementation referenced in the issue, focusing on interpolation before the reduction. Done means MAX mode returns the expected maximum of interpolated values rather than a weighted input value.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.