Skip to content

feat(ai-vision): add min_face_size_pixels filter before laplacian check - #4332

Merged
ildyria merged 2 commits into
assisted-visionfrom
copilot/add-face-size-filter
May 4, 2026
Merged

ildyria merged 2 commits into
assisted-visionfrom
copilot/add-face-size-filter

Conversation

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

Adds a configurable minimum face bounding-box size filter to the Python face-recognition service. Faces whose longest side (width or height, in pixels) does not strictly exceed the threshold are discarded before the Laplacian/blur check runs.

Changes

app/config.py

  • New min_face_size_pixels: int = 0 setting (VISION_FACE_MIN_FACE_SIZE_PIXELS env var). 0 = disabled (default, no behaviour change).
  • Included in to_diagnostics_payload() → appears in GET /config response and the AiVisionServiceConfigCheck PHP diagnostic pipe.

app/detection/detector.py

  • New min_face_size_pixels constructor param on FaceDetector.
  • Size filter inserted between the confidence check and the Laplacian computation:
    if self._min_face_size_pixels > 0:
        longest_side = max(float(area["w"]), float(area["h"]))
        if longest_side <= self._min_face_size_pixels:
            filtered_by_size += 1
            continue   # dropped before any blur computation
  • Filter summary log extended with filtered_by_size count.

app/main.py

  • Passes min_face_size_pixels=settings.min_face_size_pixels to FaceDetector.

tests/test_detection.py

  • 5 new test cases: filter by width, filter by height, pass when above threshold, no-op when zero, and ordering assertion (size filter fires before blur filter).

Copilot AI and others added 2 commits May 1, 2026 13:22
@ildyria
ildyria marked this pull request as ready for review May 1, 2026 21:19
@ildyria
ildyria requested a review from a team as a code owner May 1, 2026 21:19
@ildyria
ildyria merged commit dac77c8 into assisted-vision May 4, 2026
4 of 5 checks passed
@ildyria
ildyria deleted the copilot/add-face-size-filter branch May 4, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants