davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.43k stars 3.37k forks source link

about the score of detector #761

Closed hnsywangxin closed 7 years ago

hnsywangxin commented 7 years ago

Hello: When I looked at the documenttation,the sentence which is" for each detection. The score is bigger for more confident detections",now,I have a question ,what is the scope of score,What is the maximum score?and What is the minimum score? Thank you !

e-fominov commented 7 years ago

And what is the detector you are using?

Lower bound is normally limited by detector threshold (argument passed to detector function when detecting). Upper bound is not limited and depends on detector's structure

If you need to normalize the range - run detector on some dataset and find min/max values

hnsywangxin commented 7 years ago

@e-fominov Thank you very much ! I used the detector is "get_frontal_face_detector()",and I can't find the threshold.What you mean is that I can only define thresholds by myself?

e-fominov commented 7 years ago

you can call detector with setting the threshold - check the docs:

https://github.com/davisking/dlib/blob/master/dlib/image_processing/object_detector_abstract.h#L220-L226

template <
            typename image_type
            >
        void operator() (
            const image_type& img,
            std::vector<rect_detection>& dets,
            double adjust_threshold = 0
        );

so default adjust_threshold (i.e. minimal detection confidence) is zero. i can recommend you to use adjust_threshold in range -1..1 Negative values will make it detect more faces, but producing some false detections. Zero is good for most situations. Positive values will make it detect only high-confidence faces

And the upper bound of score is not high. It is not defined somewhere in code, so better run some detections and see them. As I remember, i never saw detection confidence higher than +3.5

hnsywangxin commented 7 years ago

@e-fominov I see ,thank you very much!

PapaMadeleine2022 commented 5 years ago

@hnsywangxin @e-fominov I change the adjust_threshold to -0.5, -1 or -3, but the detector of get_frontal_face_detector() still can not detect more faces.

PapaMadeleine2022 commented 5 years ago

@ is there way to change the threshold in some cpp file for the get_frontal_face_detector()?

davisking commented 5 years ago

Yes, if you read the documentation for the class it tells you all about it.

stalagmite7 commented 5 years ago

similar to the original question regarding confidence, the "confidence" part of an mmod detection object seems to not be bounded between [0, 1] as expected from a neural net ..? What would I have to do to obtain normalized values of confidence for the neural net mmod face detections? Or is that also going to have to be averaged over the ratings on a given dataset?

davisking commented 5 years ago

Why do you need the values to be in the range [0,1]? Unless you are putting them into something like a Bayesian filter or similar construct this kind of scaling should not be required. Most networks are also not setup to produce correctly calibrated class conditional probabilities, but yield a relatively crude scaling to [0,1] by passing the number through a sigmoid. You can perform a good calibration using something like isotonic regression or Platt scaling, both of which are in dlib. But very few users have need of such things.

stalagmite7 commented 5 years ago

I needed it because I wanted a "confidence" metric of a given face detection, so I that I donot proceed with the ones that have a too-low confidence, but since I didn't know what the upper bound is, for new incoming images that are different from my dataset, I can't really perform an averaging over all the entries to obtain a reasonable upper bound. Ok, I'll look into those approaches, thanks!

davisking commented 5 years ago

All of these methods to obtain a number in the range [0,1] just monotonically scale the output. This mean that, for any threshold in the scaled output, there is a corresponding unique threshold in the unscaled version which gives all the same decisions. For example, if the scaling turns out to be that you divide the unscaled number by 100, to get it to be in the range [0,1] and you use the threshold of 0.75, you might as well not bother with the scaling step and just use a threshold of 75. This is why I'm saying you don't want to do this. It's code and complexity that is not changing the behavior of the software, and is therefor not needed.

TLDR: if you are just going to threshold the output to make a decision, you never ever need to scale outputs.

hafiz031 commented 2 years ago

How the score of dlib.fhog_object_detector() is calculated? Any formulation?

davisking commented 2 years ago

It is the dot product between the weight vector and the HOG features.