Repository navigation
perf: Vectorize anchor generation, detector postprocessing, and elliptical blur - #169
Merged
Merged
Conversation
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
Vectorizes hot NumPy/OpenCV paths and avoids redundant full-frame allocations without changing outputs:
EllipticalBlur(uniface/privacy/blur.py): Crop Gaussian feathering, image blur, and alpha blending to each face's bounded ROI instead of blurring and blending the full(H, W, 3)image per face (529.8 ms -> 38.9 ms, 13.6x faster on 1080p with 8 faces; skips zero-area/inverted/off-screen boxes safely).uniface/common.py): Vectorizegenerate_anchors(52.88 ms -> 0.93 ms, 56.9x faster at 1080p), replacenp.repeat5x allocations indecode_landmarkswith broadcasting, and vectorizedistance2kps.RetinaFace(uniface/detection/retinaface.py): Cache dynamic-size anchors by(height, width)across video frames, filter byconfidence_thresholdandpre_nms_topkbeforedecode_boxes/decode_landmarks, and keep_scale_detectionsinfloat32(2.34 ms -> 0.48 ms, 4.9x faster at 640x640).SimilarityTransforminstantiations inbbox_center_alignmentwith the closed-form 2x3 affine (25.5 us -> 1.7 us, 14.7x faster), batch edges viacv2.polylinesindraw_mesh, and resize beforecvtColorwith contiguousfloat32NCHW outputs inMobileGazeandHeadPose.Testing
tests/test_privacy.pyandtests/test_perf_equivalents.py.ruffpass.