A comprehensive Python package for advanced face recognition, anti-spoofing, deepfake detection, emotion analysis, and face mask detection. Offers robust analysis to distinguish real faces from printed images, replay attacks, and presentation attacks, alongside precise age, gender, emotion, mask status, and genuine vs. AI-generated face predictions. Ideal for secure authentication and identity verification systems.
Project description
DeepFace Anti-Spoofing
The DeepFace Anti-Spoofing package enables users to perform advanced face recognition, anti-spoofing, deepfake detection, emotion analysis, and face mask detection on images. It provides comprehensive predictions for age, gender, emotions, mask status, and determines whether an image contains a real face, a printed photo, a presentation attack, or an AI-generated deepfake. This package is designed for secure authentication, identity verification, and seamless integration into Python applications, ensuring reliable and efficient image analysis.
Features
- Face Analysis: Predict age and gender from uploaded images using the
analyze_imagemethod. - Anti-Spoofing Detection: Determine whether a face is real or part of a spoofing attack (e.g., printed photo, or presentation attack) using the
analyze_deepfacemethod. - Deepfake Detection: Detect AI-generated faces or deepfakes with high accuracy via the
analyze_imagemethod. - Emotion Analysis: Analyze seven basic emotions (angry, disgust, fear, happy, neutral, sad, surprise) using the
analyze_emotionmethod. - Face Mask Detection: Detect whether a person is wearing a face mask using the
analyze_face_maskmethod. - Comprehensive Analysis: Get all analysis results in a single call using the
analyze_comprehensivemethod. - Simple Integration: Easily integrate into Python applications for robust image analysis.
Documentation
Comprehensive documentation, guidance, and code examples, including a web interface for testing, are provided at the DeepFace Anti-Spoofing Documentation.
Installation
To use the DeepFace Anti-Spoofing and Deepfake Analysis package in your Python application, install the required package:
pip install deepface-antispoofing
Usage Examples
Example 1: Face Analysis with Age, Gender, and Deepfake Detection
The analyze_image method predicts age, gender, and whether the image contains a real or AI-generated face.
from deepface_antispoofing import DeepFaceAntiSpoofing
file_path = "path_to_image.jpg"
deepface = DeepFaceAntiSpoofing()
response = deepface.analyze_image(file_path)
print(response)
Sample Response:
{
"id": 1,
"age": 30,
"gender": {
"Male": 0.85,
"Female": 0.15
},
"dominant_gender": "Male",
"spoof": {
"Fake": 0.02,
"Real": 0.98
},
"dominant_spoof": "Real",
"timestamp": "2025-04-18 12:34:56"
}
Example 2: Anti-Spoofing Detection for Printed, or Presentation Attacks
The analyze_deepface method determines whether the face is real or part of a spoofing attack, such as a printed photo, or presentation attack.
from deepface_antispoofing import DeepFaceAntiSpoofing
file_path = "path_to_image.jpg"
deepface = DeepFaceAntiSpoofing()
response = deepface.analyze_deepface(file_path)
print(response)
Sample Response:
{
"confidence": 1.0,
"is_real": "True",
"processing_time": 1.03,
"spoof_type": "Real Face",
"success": "True"
}
Example 3: Emotion Analysis
The analyze_emotion method analyzes seven basic emotions from the facial expression.
from deepface_antispoofing import DeepFaceAntiSpoofing
file_path = "path_to_image.jpg"
deepface = DeepFaceAntiSpoofing()
response = deepface.analyze_emotion(file_path)
print(response)
Sample Response:
{
"emotions": {
"angry": 2.2382489987649024e-05,
"disgust": 6.113571515697913e-08,
"fear": 4.268830161890946e-05,
"happy": 0.9963662624359131,
"neutral": 0.0030167356599122286,
"sad": 3.199426646460779e-05,
"surprise": 0.0005198476719669998
},
"dominant_emotion": "happy",
"confidence": 0.9963662624359131,
"predicted_label": 3,
"timestamp": "2025-11-05 23:24:02"
}
Example 4: Face Mask Detection
The analyze_face_mask method detects whether a person is wearing a face mask.
from deepface_antispoofing import DeepFaceAntiSpoofing
file_path = "path_to_image.jpg"
deepface = DeepFaceAntiSpoofing()
response = deepface.analyze_face_mask(file_path)
print(response)
Sample Response:
{
"has_mask": false,
"with_mask_prob": 0.34883034229278564,
"without_mask_prob": 0.6511696577072144,
"confidence": 0.6511696577072144,
"mask_status": "Without Mask",
"timestamp": "2025-11-05 23:24:52"
}
Example 5: Comprehensive Analysis
The analyze_comprehensive method provides all analysis results in a single call.
from deepface_antispoofing import DeepFaceAntiSpoofing
file_path = "path_to_image.jpg"
deepface = DeepFaceAntiSpoofing()
response = deepface.analyze_comprehensive(file_path)
print(response)
Sample Response:
{
"age_gender": {
"age": 25,
"gender": {
"Male": 5.152494122739881e-05,
"Female": 0.9999485015869141
},
"dominant_gender": "Female",
"spoof": {
"Fake": 7.748603820800781e-07,
"Real": 0.9999992251396179
},
"dominant_spoof": "Real",
"timestamp": "2025-11-05 23:25:17"
},
"printed_detection": {
"printed_analysis": {
"Printed": 0.10731140524148941,
"Real": 0.8926885947585106
},
"dominant_printed": "Real",
"confidence": 0.8926885947585106,
"timestamp": "2025-11-05 23:25:18"
},
"emotion": {
"emotions": {
"angry": 2.2382489987649024e-05,
"disgust": 6.113571515697913e-08,
"fear": 4.268830161890946e-05,
"happy": 0.9963662624359131,
"neutral": 0.0030167356599122286,
"sad": 3.199426646460779e-05,
"surprise": 0.0005198476719669998
},
"dominant_emotion": "happy",
"confidence": 0.9963662624359131,
"predicted_label": 3,
"timestamp": "2025-11-05 23:25:19"
},
"face_mask": {
"has_mask": false,
"with_mask_prob": 0.34883034229278564,
"without_mask_prob": 0.6511696577072144,
"confidence": 0.6511696577072144,
"mask_status": "Without Mask",
"timestamp": "2025-11-05 23:25:20"
},
"timestamp": "2025-11-05 23:25:20"
}
Key Points
- Ensure the uploaded image contains a clear face for accurate analysis.
- Use analyze_image for age, gender, and deepfake detection.
- Use analyze_deepface for detecting spoofing attacks like printed photos, or presentation attacks.
- Use analyze_emotion for emotion analysis across seven basic emotions.
- Use analyze_face_mask for detecting whether a person is wearing a face mask.
- Use analyze_comprehensive for getting all analysis results in a single call.
- Refer to the official documentation for detailed endpoint specifications, advanced features, and web interface usage.
Support
For any issues or questions, please contact ipsoftechsolutions@gmail.com.
Thank you for choosing DeepFace Anti-Spoofing for your face recognition, anti-spoofing, and deepfake detection needs!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepface_antispoofing-1.1.3.tar.gz.
File metadata
- Download URL: deepface_antispoofing-1.1.3.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2ecc17e6df12ed8da44d32127aeac6c4c9f43b2177bd17b725455271f9787b5
|
|
| MD5 |
1375ef9b1f9a99affc85224e52e4b233
|
|
| BLAKE2b-256 |
1a7a4eea4fc267c9c9d03ce0eeb9a0081135ba490d014c56ad6188bafb47b616
|
File details
Details for the file deepface_antispoofing-1.1.3-py3-none-any.whl.
File metadata
- Download URL: deepface_antispoofing-1.1.3-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0a9b96c29a97a7b23b23932add519532b930cb9013418e6ce5c86e5ece06a02
|
|
| MD5 |
b9d914481a6ecd6645ac3a76eab9f713
|
|
| BLAKE2b-256 |
f05197a866faced7e513e4259fed912bad91d8d4d14fe3a2ad521dd8a656a0d9
|