experiencor / keras-yolo3

Training and Detecting Objects with YOLO3
MIT License
1.6k stars 861 forks source link

Lots of 0 confidence boxes in prediction #80

Open RichardSieg opened 6 years ago

RichardSieg commented 6 years ago

I noticed, that generally way more boxes are predicted than in the version before. But nearly all of them have confidence (score) 0, although this should be filtered out in decode_netout: if(objectness <= obj_thresh): continue. I looked through the code and couldn't find the reason.

RichardSieg commented 6 years ago

It seems like, the 0 comes from the get_score function from the BoundBox class:

def get_score(self):
        if self.score == -1:
            self.score = self.classes[self.get_label()]

        return self.score      

Why is the class returned in this case? What is the difference between c and score? The parameter score is never set to a given value in BoundBox:

def __init__(self, xmin, ymin, xmax, ymax, c = None, classes = None):
        self.xmin = xmin
        self.ymin = ymin
        self.xmax = xmax
        self.ymax = ymax

        self.c       = c
        self.classes = classes

        self.label = -1
        self.score = -1
darjoo commented 6 years ago

c is the objectness score. Used to tell whether the bounding box contains anything, if the score is below the object threshold, ignore the box itself. score is used to tell what is the probability it is this class. This will always be the highest class probability.

The names could definitely be better imo.

The reason why there are so many boxes being predicted, is because there are 3 prediction layers (The FPN implementation at 3 scales). The number of box predictions are 3 * N * N * 3 or N * N * 3 (I'm not sure on this part atm which is the correct one but I'll explain both) 3 * N * N * 3 = 3 for the scales, N N for the scale size, 3 for the anchors `N N 3` = N N for the scale size, 3 for the scales

So because of the number of predictions being done, I'm not surprised that that there are plenty of 0 class probability (objectness/c)

RichardSieg commented 6 years ago

Ah thanks for the clarification. That makes total sense. I always forget about the multiple output layers. But it would be a nice enhancement, if boxes with score 0 would not be predicted at all @experiencor (if you have time for that of course ;) ) currently I'm throwing them away in my postprocessing step. I will leave this issue open for now, so @experiencor can see it.