Repository navigation
fix: Correct detector preprocessing, postprocessing, and resize edge cases - #168
Merged
Merged
Conversation
yakhyo
force-pushed
the
fix/detector-bugs
branch
from
November 28, 2026 13:59
2888959 to
7e03b0c
Compare
Owner
|
Thanks for the fixes! I kept the SCRFD colour and 16:9 fixes, the YOLOv8 float32 and warning fixes, and the thin-image guard, and dropped the other changes to stay close to the original code. |
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes preprocessing, postprocessing, and aspect-ratio resize bugs across
SCRFD,CenterFace,YOLOv5Face,YOLOv8Face, and shared resize helpers:SCRFD:swapRB=True) and scale by1 / 128.0inpreprocessto match InsightFace's SCRFD training pipeline.math.ceil(dim / stride)instead of floor division (// stride), fixingValueErrorshape mismatches on non-multiple-of-32 resolutions such as 720p(1280, 720)and(640, 360).input_sizedimensions are positive multiples of 8, slicepos_indicesbefore anchor decoding, and validate input images before unpackingimage.shape[:2].CenterFace:x2, y2and 5-point landmarks from unclippedraw_x1, raw_y1before clamping box edges to[0, width]/[0, height], preventing rightward/downward shifts on border faces.YOLOv8Face&YOLOv5Face:float32detectionsandlandmarksconsistently (and(0, 5)/(0, 5, 2)float32on empty frames), clipcls_confbeforeexpinYOLOv8Face, filter by confidence before DFL softmax (6.4x fasterYOLOv8Face.postprocess), and runvalidate_imagebefore unpackingimage.shape[:2].resize_image&letterbox_resize:>= 1pixel on extreme aspect ratios / thin crops and deriveresize_factorfrom the active constrained axis.Testing
tests/test_scrfd.py,tests/test_centerface.py, andtests/test_yolo.py.ruffpass.