pytorch / android-demo-app

PyTorch android examples of usage in applications
1.47k stars 606 forks source link

object_detection demo the argsort is wrong #258

Open delongwu opened 2 years ago

delongwu commented 2 years ago

hi, the comparator in [nonMaxSuppression] function of pytorch/demo/objectdetection)/PrePostProcessor.java is asc order, not desc order. it is just oppositive than swift comparator. the right one in java is :

  // Do an argsort on the confidence scores, from high to low.
    Collections.sort(boxes,
            new Comparator<Result>() {
                @Override
                public int compare(Result o1, Result o2) {
                    return o2.score.compareTo(o1.score);
                }
            });
FabrizioPe commented 1 year ago

Hi, that seems to be the case! We were experiencing much lower confidence scores in the mobile app with respect to GPU. This fix apparently did the trick.