Skip to content

feat: add validate_landmarks() for JSON and CSV landmark file validation#407

Closed
P-r-e-m-i-u-m wants to merge 1 commit intodreamlessx:mainfrom
P-r-e-m-i-u-m:feat/validate-landmarks
Closed

feat: add validate_landmarks() for JSON and CSV landmark file validation#407
P-r-e-m-i-u-m wants to merge 1 commit intodreamlessx:mainfrom
P-r-e-m-i-u-m:feat/validate-landmarks

Conversation

@P-r-e-m-i-u-m
Copy link
Contributor

Closes #402

Adds validate_landmarks() utility to check landmark files before processing.

Changes

landmarkdiff/validation.py

  • Added validate_landmarks(path) function supporting .json and .csv formats
  • Added ValidationResult dataclass with valid, errors, warnings, landmark_count, dimensions
  • Validates:
    • File exists and is readable
    • Valid JSON/CSV format with clear parse errors
    • Expected landmark count (478 MediaPipe, 68 dlib)
    • 2D or 3D coordinates
    • No NaN or infinite values
    • Coordinate bounds: [0, 1] normalized or [0, image_size] pixel
    • Confidence scores below threshold (if present)
  • JSON schema: {"landmarks": [[x, y, z], ...], "confidence": [...]} or bare list
  • CSV schema: x,y or x,y,z columns with optional header row

Usage

from landmarkdiff.validation import validate_landmarks

result = validate_landmarks("face.json")
if not result.valid:
    print(result)  # shows all errors clearly

Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ <amanbaba9404522@gmail.com>
@dreamlessx
Copy link
Owner

Nice implementation @P-r-e-m-i-u-m — the validate_landmarks() function is thorough with good JSON/CSV parsing, bounds checking, and confidence filtering.

This PR has a merge conflict though — likely from the other PRs that just merged. Can you rebase on latest main?

git fetch origin
git rebase origin/main
# resolve any conflicts
git push --force-with-lease

Once the conflict is resolved and CI passes, I'll merge it.

@dreamlessx
Copy link
Owner

Closing — superseded by #420 which is a clean fresh PR. Thanks!

@dreamlessx dreamlessx closed this Mar 21, 2026
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.

Add data validation for landmark file formats

2 participants