Mukh
Mukh (मुख, meaning "face" in Sanskrit) is a comprehensive face analysis library that provides unified APIs for various face-related tasks. It simplifies the process of working with multiple face analysis models through a consistent interface.
Features
- 🎯 Unified API: Single, consistent interface for multiple face analysis tasks
- 🔄 Model Flexibility: Support for multiple models per task
- 🛠️ Custom Pipelines: Optimized preprocessing and model combinations
- 🚀 Easy to Use: Simple, intuitive APIs for quick integration
Documentation
The library is documented in detail, click here to view the documentation.
Currently Supported Tasks
- Face Detection
- Face Reenactment
- Deepfake Detection using a Single Model
- Deepfake Detection Pipeline - Ensemble of multiple models
Installation
conda create -n mukh-dev python=3.10 -y
pip install mukh==0.1.14
Usage
Face Detection
from mukh.face_detection import FaceDetector
# Initialize detector
detection_model = "mediapipe" # Other models: "blazeface", "ultralight"
detector = FaceDetector.create(detection_model)
# Detect faces
detections = detector.detect(
image_path="assets/images/img1.jpg", # Path to the image to detect faces in
save_csv=True, # Save the detections to a CSV file
csv_path=f"output/{detection_model}/detections.csv", # Path to save the CSV file
save_annotated=True, # Save the annotated image
output_folder=f"output/detection_model", # Path to save the annotated image
)
Example
python examples/face_detection/basic_detection.py --detection_model mediapipe
Face Reenactment
from mukh.face_reenactment import FaceReenactor
# Initialize reenactor
reenactor_model = "tps" # Available models: "tps"
reenactor = FaceReenactor.create(reenactor_model)
# Reenact face
result_path = reenactor.reenact_from_video(
source_path="assets/images/img1.jpg", # Path to the source image
driving_video_path="assets/videos/video.mp4", # Path to the driving video
output_path=f"output/{reenactor_model}", # Path to save the reenacted video
save_comparison=True, # Save the comparison video
resize_to_image_resolution=False, # Resize the reenacted video to the image resolution
)
Example
python examples/reenactment/basic_reenactment.py \
--reenactor_model tps \
--source_path assets/images/img1.jpg \
--driving_video_path assets/videos/video_1sec.mp4 \
--output_folder output
Deepfake Detection
Images
import torch
from mukh.deepfake_detection import DeepfakeDetector
# Initialize detector
detection_model = "efficientnet" # Other models "resnet_inception"
detector = DeepfakeDetector(
model_name=detection_model,
confidence_threshold=0.5,
device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)
# Detect deepfakes in Images
media_path = "assets/images/img1.jpg"
detections, final_result = detector.detect(
media_path=media_path, # Path to the media file (image/video)
save_csv=True, # Save the detections to a CSV file
csv_path=f"output/{detection_model}/deepfake_detections.csv", # Path to save the CSV file
save_annotated=True, # Save the annotated media
output_folder=f"output/{args.detection_model}", # Path to save the annotated media
)
Example
python examples/deepfake_detection/detection.py \
--detection_model resnet_inception \
--media_path assets/images/img1.jpg \
--confidence_threshold 0.5 \
Videos
import torch
from mukh.deepfake_detection import DeepfakeDetector
# Initialize detector
detection_model = "efficientnet" # Other models "resnet_inception"
detector = DeepfakeDetector(
model_name=detection_model,
confidence_threshold=0.5,
device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)
# Detect deepfakes in Videos
media_path = "assets/videos/deepfake_elon_musk.mp4"
detections, final_result = detector.detect(
media_path=media_path, # Path to the media file (image/video)
save_csv=True, # Save the detections to a CSV file
csv_path=f"output/{detection_model}/deepfake_detections.csv", # Path to save the CSV file
save_annotated=True, # Save the annotated media
output_folder=f"output/{args.detection_model}", # Path to save the annotated media
num_frames=11, # Number of equally spaced frames for video analysis
)
Example
python examples/deepfake_detection/detection.py \
--detection_model resnet_inception \
--media_path assets/videos/deepfake_elon_musk.mp4 \
--confidence_threshold 0.5 \
--num_frames 11
Deepfake Detection Pipeline
from mukh.pipelines.deepfake_detection import PipelineDeepfakeDetection
# Define model configurations with weights
model_configs = {
"resnet_inception": 0.5,
"efficientnet": 0.5
}
# Create ensemble detector
detector = PipelineDeepfakeDetection(model_configs)
media_path = "assets/videos/deepfake_elon_musk.mp4" # Or pass an image path
# Detect deepfakes
result = pipeline.detect(
media_path=media_path,
output_folder="output/deepfake_detection_pipeline,
save_csv=True,
num_frames=11, # Number of equally spaced video frames for analysis
)
Example
python examples/pipelines/deepfake_detection.py \
--media_path assets/videos/deepfake_elon_musk.mp4 \
--output_folder output/deepfake_detection_pipeline
Contact
For questions and feedback, please open an issue on GitHub.
Metadata
Release files for mukh 0.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mukh-0.1.14.tar.gz | 86.5 kB | Without provenance | Details for mukh-0.1.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mukh-0.1.14-py3-none-any.whl | Python 3 | none | any | Details for mukh-0.1.14-py3-none-any.whl |
Total release size: 197.1 kB
Release files / mukh-0.1.14.tar.gz
| Download URL | mukh-0.1.14.tar.gz |
|---|---|
| Size | 86.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d61c845aa627e52cddb4d163792b0849e94297053dcd6baa9daddb8c39a5c4ae
|
|
BLAKE2b-256 checksum How to use checksums |
f067f0d74b44a655113f69421ad7b0403fb6345d819b0d36b19c49008604425b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / mukh-0.1.14-py3-none-any.whl
| Download URL | mukh-0.1.14-py3-none-any.whl |
|---|---|
| Size | 110.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2855e90442a787b716cb8a0c396fe5e23e84d028691a20c180386ec1541c270
|
|
BLAKE2b-256 checksum How to use checksums |
65ee5b65e0e82d0cbc904ad9db4845bb14d62d9525d5c06b35b110e9fc0d0481
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Security for mukh 0.1.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.