Fix missing normalization when skipping face detection #889
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the
DeepFace.represent
function wheredetector_backend=skip
, the image is not properly normalized.In particular, digging around the repo I found that this bug was introduced in 8f667ee: the line that divides the image's pixels by 255 is moved inside
functions.extract_faces
, which is skipped with the above mentioned keyword argument.Therefore, the model's input image (in particular, I tried with ArcFace) has a distribution which is significantly different than the one used in training; as a consequence, the model has a significantly lower performance than advertised when tested on LFW (~64.5% with cosine distance).
On the contrary, when the image is manually normalized in the [0, 1] range, this accuracy is around ~91%.
I used DeepFace 0.0.79.
While waiting for this PR to be merged, I suggest anyone in the same situation to manually normalize your images converting them from BGR to RGB and manually normalizing them so that the pixels' range is [0, 1].