This project leverages the DeepFace library to perform face detection and recognition. The repository demonstrates how to query an image and find matching faces from a specified image database.
This project utilizes the DeepFace library to find and display images from a database that match a given query image. It includes:
- A function to detect faces in a database and return matching image paths.
- A visualization tool using Matplotlib to display the query image alongside matching results.
- Face Verification: Verify if two images are of the same person.
- Face Detection: Search for matching faces in a given image database.
- Visualization: Display the query image and matched images using Matplotlib.
-
Clone the repository:
git clone https://github.com/Ritikyadav1/face-detection-deepface.git cd face-detection-deepface
-
Install the required packages:
pip install -r requirements.txt
-
Ensure you have the
DeepFace
library installed:pip install deepface
-
Prepare an image database by storing images in a folder (e.g.,
/content/database
). -
Run the script to detect and visualize results:
python main.py
-
Modify the
image_path
anddb_path
variables in the script as needed to test with different images.
def detect_faces(image_path, db_path):
dfs = DeepFace.find(img_path=image_path, db_path=db_path)
data = dfs[0]
imgs = data['identity'].tolist()
return imgs
import matplotlib.pyplot as plt
# Display the query and found images
plt.figure(figsize=(10, 5))
plt.imshow(query_img)
plt.title('Query Image')
plt.axis('off')
- Python 3.x
- DeepFace
- Matplotlib
- OpenCV
- TensorFlow
This project outputs a list of image paths matching the query and displays them using Matplotlib. The detected images are shown side-by-side with the original query image for easy comparison.
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
RITIK YADAV