Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created September 8, 2025 18:27
Show Gist options
  • Select an option

  • Save dontpaniclabsgists/51b52145d0e759afbb937ce020300326 to your computer and use it in GitHub Desktop.

Select an option

Save dontpaniclabsgists/51b52145d0e759afbb937ce020300326 to your computer and use it in GitHub Desktop.
def search_faces(self, request: SearchFacesRequest) -> SearchFacesResponse:
all_results = []
for query_face in request.query_faces:
for model_name in query_face.model_names:
collection_name = f"face_embeddings_{model_name.lower()}"
# Perform vector similarity search
search_results = self._client.search(
collection_name=collection_name,
query_vector=query_face.embeddings[model_name],
limit=request.max_results,
with_payload=True
)
# Convert results to our format
for scored_point in search_results:
face_record = self._point_to_face_record(scored_point)
search_result = SearchResult(
face_record=face_record,
similarity_score=scored_point.score,
model_used=model_name,
query_face_id=query_face.face_id
)
all_results.append(search_result)
# Sort by similarity score and return top results
all_results.sort(key=lambda x: x.similarity_score, reverse=True)
return SearchFacesResponse(success=True, results=all_results[:request.max_results])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment