Package: face-tagger
Face TaggerFace Tagger is a Python library designed to classify photos containing specific individuals from a collection of images.FeaturesFace Recognition: Identify and differentiate faces in multiple images.Photo Classification: Group photos based on the identified individual.GPU Acceleration: Optimized performance using GPU, if available.Easy Integration: Simple APIs for seamless integration into various applications.InstallationTo install Face Tagger, you can use pip:pipinstallface-taggerDependenciesFace Tagger relies on several key libraries to function effectively. Understanding these dependencies can provide insights into the library's internal workings and can be beneficial for troubleshooting. Here are the primary dependencies:OpenCV (cv2): Used for image processing tasks like reading and preprocessing images.Torch (torch): The primary deep learning framework employed for face embedding.MTCNN: Essential for the detection of faces within images.Make sure to have these dependencies properly installed or ensure they are present in your environment when working with Face Tagger. For a comprehensive list and exact versions, please refer to therequirements.txtfile.How it WorksFace Tagger follows a systematic process to classify images:Image LoadingUses standard Python libraries, typically OpenCV (cv2), to read and preprocess images.Face DetectionUtilizes the MTCNN (Multi-task Cascaded Convolutional Networks) library for detecting faces in images.Embedding ComputationEmploys the FaceNet model, often via thetorchlibrary, to compute a vector (embedding) for each
detected face.Face ClassificationUses a HDBSCAN clustering algorithm to group similar face embeddings together.Result CompilationOnce the faces are classified, the result is compiled and presented in a structured format that informs which
images contain which individual(s).UsageTo utilize the Face Tagger library, follow these steps:Load image with functions defined in utils module:
The generator function allows you to loop through all images in a specified directory and createImageObjectinstances for each one.fromface_tagger.utilsimport*image_objects=load_images_from_directory("path_to_images_directory")Replacepath_to_images_directorywith the path to your image directory.(Note: You don't necessarily need to use a generator for image_objects. You can also create ImageObject list from loaded
images in an array and pass them.)Here is the representation of theImageObjectclass:Attributes:image_id: A unique identifier for the image.image_data: Actual image data, loaded using OpenCV.Example:img_obj=ImageObject(image_id="unique_id_123",image_data=loaded_image_data)Initialize the Face Tagger:
Here, you can set various parameters likeuse_gpu,image_resize_factor,min_faces_to_identify_human,
andmin_similarity_face_count.min_faces_to_identify_human: Minimum number of faces required to be classified as a human.min_similarity_face_count: Minimum number of similar faces required to be included in a group.fromface_taggerimportFaceTaggerface_tagger=FaceTagger(use_gpu=False,image_resize_factor=1.0,min_faces_to_identify_human=4,min_similarity_face_count=3)Classify images by person:
Now, use theclassify_images_by_personmethod of theface_taggerinstance and pass theimage_objectsfrom the
generator function to classify the images.result=face_tagger.classify_images_by_person(image_objects=image_objects)print(result)With these steps, you can effectively utilize the Face Tagger library to classify images based on the individuals they
contain.ContributingPull requests are welcome. For major changes, please open anissuefirst to discuss what you would like to change.LicenseMIT