Skip to content

Feat/group photo processor worker#37

Draft
maya-ots wants to merge 19 commits intodevelopfrom
feat/group-photo-processor-worker
Draft

Feat/group photo processor worker#37
maya-ots wants to merge 19 commits intodevelopfrom
feat/group-photo-processor-worker

Conversation

@maya-ots
Copy link
Copy Markdown
Collaborator

summary

implements a JetStream worker that processes group photos , detects all faces, matches them against enrolled users, and creates PhotoFace and PhotoApproval records for each match.

technical implementation

  • added PHOTO_GROUP_PROCESS subject to NatsSubjects.
  • created db/generated/photo_faces.py querier for creating PhotoFace records.
  • created db/generated/photo_approvals.py querier for creating PhotoApproval records.
  • added list_users_with_embedding() query to db/generated/user.py.
  • created app/worker/photo_processor/schema/event.py Pydantic model for the JetStream event payload.
  • created app/worker/photo_processor/main.py worker that:
    • fetches photo from MinIO.
    • detects all faces in the photo and computes embeddings.
    • compares each embedding against all enrolled users using cosine similarity.
    • creates a PhotoFace record per detected face.
    • creates a PhotoApproval record with decision=pending for each matched user.

testing

  • Added unit tests for PhotoGroupProcessWorker :
    • handles no faces detected (exits early).
    • creates PhotoFace and PhotoApproval for matched users.
    • does not create PhotoApproval for unmatched users.

@maya-ots maya-ots requested a review from wailbentafat March 26, 2026 02:40
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test have to be in test folder if it doesnt exist create it and for the images dont do tis image_path = r"C:\Users\Lenovo\OneDrive\Desktop\MultiAI\multAI-back\app\images\image1.png" add iamge to the test file and test with it

# 4. process each detected face
for face_index, face_embedding in enumerate(face_embeddings):

# create PhotoFace record
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noo this is wrong logique here for each face_embedding search about the user tht have the face get his id and then use in the phoot_face record creation and dont creaet bbox=none fix it

logger.warning("Failed to create photo face %s for photo %s", face_index, event.photo_id)
continue

# 5. compare against all enrolled users
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logiue must be in the db not in the service level so we can ensure durabilite

SELECT id, face_embedding
FROM users
WHERE face_embedding IS NOT NULL
AND deleted_at IS NULL; No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refacotr this to use pgvector features

INSERT INTO photo_approvals (
photo_id,
user_id,
decision
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here just make sure tht decsision is enum in the service level

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