Repository navigation
fix: Harden crop bounds and edge cases across landmark, attribute, matting, and store modules - #171
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
Hardens crop bounds, input validation, and edge cases across matting, landmark, attribute, spoofing, recognition, vector store, and CLI modules:
MODNet&PPMatting: Validateinput_size >= 32/max_short >= 32, validate input images viavalidate_image, and reject images with a side< 32px inMODNet.preprocessinstead of crashingcv2.resizewithnew_h == 0whenmin(H, W) < 32 <= input_size <= max(H, W).FaceMesh: Fall back to axis-aligned ROIs whenFace.landmarksis empty (supports_landmarks = False), support single 1D(4,)bboxesarrays, reject zero/inverted boxes inroi_from_box, and clip logits beforeexpinpostprocess.PIPNet,FairFace&MiniFASNet: Validate box ordering and image overlap to prevent Python negative-slice background cropping and OpenCV!ssize.empty()crashes (including valid bottom-edge faces inPIPNetand sub-pixel boxes inMiniFASNet).Landmark106: Avoid mutating callerpredictionsarrays in-place insidepostprocess, and validate positive box dimensions and input images.Emotion: Add optionaldeviceoverride, fix(H, W)vs(W, H)cv2.resizeorientation on custominput_size, skip redundant resize at(112, 112), and call.detach()inpostprocess.BaseRecognizer&face_utils: HandlePreprocessConfig(input_mean=[...], input_std=float)without crashingblobFromImage, defaultlandmarks=Noneonget_normalized_embeddingand__call__, raiseValueErrorinstead of internalskimageFailedEstimationAccessErrorinestimate_norm, and remove the unconditional+ 1e-5denominator bias incompute_similarity.FAISS.load& CLI crops: Logmodel={model_name}instead ofmodel_name.namebeforeverify_model_weightsso invalid string identifiers raiseValueErrorrather thanAttributeError; verify dimension and metadata count inFAISS.load(); clamp negative detector box coordinates before slicing intools/gaze.pyandtools/headpose.py.Testing
tests/test_edge_cases.pycovering all 14 regression scenarios.