Face recognition - find_similar operation on PersistedFaceId

Ofir Liba 0 Reputation points
2023-07-26T11:32:47.4166667+00:00

For face recognition task I need to use find_similar operation on 2 collections.

I would like to merge them before searching the face.

I merged the PersistedFaceIds of the two collections into one list and them transfer it to "find_similar" method but got and error.

Does "find_similar" method can work on list of PersistedFaceIds? If not , there is a workaround to search in 2 collections in one call?

Azure Face
Azure Face
An Azure service that provides artificial intelligence algorithms that detect, recognize, and analyze human faces in images.
163 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ofir Liba 0 Reputation points
    2023-07-27T10:30:23.8633333+00:00

    this one works well-

            matched_faces = face_client.face.find_similar(
    
                face_id=face_id_source,
    
                face_list_id=collection_id,
    
                max_num_of_candidates_returned=5,
    
                recognition_model="recognition_04",
    
                detection_model="detection_03",
    
            )
    
    
    

    But if I use this one

       # collection_face_ids is a list of all persisted_face_id in collection_id
    
         matched_faces = face_client.face.find_similar(
                face_id=face_id_source,
                face_ids=collection_face_ids,
                max_num_of_candidates_returned=5,
                recognition_model="recognition_04",
                detection_model="detection_03",
            )
    
    
    

    I get following error

      File "C:\Anaconda3\envs\face_recognition\lib\site-packages\azure\cognitiveservices\vision\face\operations\_face_operations.py", line 136, in find_similar
        raise models.APIErrorException(self._deserialize, response)
    azure.cognitiveservices.vision.face.models._models_py3.APIErrorException: (FaceNotFound) Face is not found.
    
    
    

    What I want to do is to search face_id_source in collection_id1and collection_id2 in one call so I tried to do

    combined_face_ids = collection1_face_ids + collection2_face_ids
    
    matched_faces = face_client.face.find_similar(
    face_ids=combined_face_ids,   
     max_num_of_candidates_returned=5,    
    recognition_model="recognition_04",    
    detection_model="detection_03",)
    
    
    

    and get the above error

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.