Age & Gender Detection
Accurately predicts age range and classifies gender with deep learning models.
- Age range prediction
- Gender classification
- Confidence scoring
STUDIO · DIGITAL LAB
The deepface-antispoofing package is a comprehensive Python library for advanced facial analysis. Version 1.1.3 introduces enhanced capabilities including emotion detection, face mask detection, presentation attack detection, and comprehensive multi-model analysis.
This powerful package uses deep learning models for age/gender prediction, anti-spoofing detection, emotion analysis, face mask detection, and presentation attack detection, combined with Haar Cascade for robust real-time face detection.
Watch this demonstration to see the Deepface-Antispoofing package in action, analyzing live video streams and uploaded images for deepfakes, presentation attacks, emotions, and demographic attributes:
Version 1.1.3 provides comprehensive facial analysis with six specialized detection capabilities:
Accurately predicts age range and classifies gender with deep learning models.
Flags faces generated or altered by AI models (GANs, diffusion models, synthetic media).
Detects spoofing attempts using printed photos, digital screens, paper masks, or video replays.
Recognizes seven universal emotions with probability distributions for affective analysis.
Identifies whether subjects are wearing masks for health compliance and secure surveillance.
Combines all models into a single inference pipeline for unified identity assessment.
The package provides versatile input ingestion options for static processing and real-time streaming environments:
Pass local image paths (JPEG, PNG, WebP) or NumPy arrays directly for deep forensic analysis, replay attack checks, and demographic extraction.
Ingest frames continuously via OpenCV (cv2.VideoCapture) for continuous live verification, interactive kiosk authentication, and video surveillance.
Install the official package from PyPI using pip:
pip install deepface-antispoofing
v1.1.3) to avoid compatibility issues.The package automatically installs the following core libraries:
tensorflow — Neural network runtimeopencv-python — Image matrix processing and Haar Cascade executionnumpy — Numerical array computingrequests — Automated model and weights downloadflask & flask-cors — Web interface and API servertf-keras — Keras model architecture compatibilityWhen you run the package for the first time, it automatically verifies and downloads the required pre-trained weights and Haar Cascade files if they are not already cached in your working directory:
age_gender_model.h5): Downloaded to ./models/age_gender_model.h5. Used for predicting age range and gender.
anti_spoofing_model.h5): Downloaded to ./models/anti_spoofing_model.h5. Used for detecting real vs. fake faces.
emotion_model.h5): Downloaded to ./models/emotion_model.h5. Used for multi-class emotional state classification.
face_mask_model.keras): Downloaded to ./models/face_mask_model.keras. Used for mask usage detection.
printed_detection_model_1.keras): Downloaded to ./models/printed_detection_model_1.keras. Used for presentation attack detection.
haarcascade_frontalface_default.xml): Downloaded to ./data/haarcascade_frontalface_default.xml. Used for initial face bounding box detection.
models and data directories created automatically in the current working directory. An active internet connection is required only on the very first execution.
After the initial run, your project workspace will contain the organized directories for models, Haar Cascade definitions, and web interface assets:
./
├── data/
│ └── haarcascade_frontalface_default.xml
├── models/
│ ├── age_gender_model.h5
│ ├── anti_spoofing_model.h5
│ ├── emotion_model.h5
│ ├── face_mask_model.keras
│ └── printed_detection_model_1.keras
├── templates/
│ └── deepface.html
├── static/
│ └── style.css
└── app.py
The DeepFaceAntiSpoofing class exposes five specialized member methods:
Analyzes an image for age estimation, apparent gender classification, and deepfake verification (AI-generated vs real faces).
Parameters:image_input (str path or np.ndarray) • Returns: dict
Detects presentation attacks — identifies if the face is live/physical or from printed media, screens, or replay attacks.
Parameters:image_input (str path or np.ndarray) • Returns: dict
Detects seven universal emotional states: angry, disgust, fear, happy, neutral, sad, surprise.
image_input (str path or np.ndarray) • Returns: dict
Evaluates whether the person in the image is wearing a face mask or not, returning confidence probabilities.
Parameters:image_input (str path or np.ndarray) • Returns: dict
Executes all specialized models in an optimized single-call pipeline and returns a unified JSON payload.
Parameters:image_input (str path or np.ndarray) • Returns: dict
The analyze_image method predicts age, gender, and whether the image contains a real or AI-generated face:
from deepface_antispoofing import DeepFaceAntiSpoofing
# Initialize the analyzer
deepface = DeepFaceAntiSpoofing()
# Analyze an image
result = deepface.analyze_image("path_to_image.jpg")
print(result)
Sample Response Payload:
{
"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:22:38"
}
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
# Initialize the analyzer
deepface = DeepFaceAntiSpoofing()
# Analyze an image
result = deepface.analyze_deepface("path_to_image.jpg")
print(result)
Sample Response Payload:
{
"printed_analysis": {
"Printed": 0.10731140524148941,
"Real": 0.8926885947585106
},
"dominant_printed": "Real",
"confidence": 0.8926885947585106,
"timestamp": "2025-11-05 23:23:34"
}
The analyze_emotion method detects seven different emotional states from facial expressions:
from deepface_antispoofing import DeepFaceAntiSpoofing
# Initialize the analyzer
deepface = DeepFaceAntiSpoofing()
# Analyze an image
result = deepface.analyze_emotion("path_to_image.jpg")
print(result)
Sample Response Payload:
{
"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"
}
The analyze_face_mask method detects whether the person in the image is wearing a face mask:
from deepface_antispoofing import DeepFaceAntiSpoofing
# Initialize the analyzer
deepface = DeepFaceAntiSpoofing()
# Analyze an image
result = deepface.analyze_face_mask("path_to_image.jpg")
print(result)
Sample Response Payload:
{
"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"
}
The analyze_comprehensive method provides complete facial analysis by combining all models in a single call:
from deepface_antispoofing import DeepFaceAntiSpoofing
# Initialize the analyzer
deepface = DeepFaceAntiSpoofing()
# Analyze an image
result = deepface.analyze_comprehensive("path_to_image.jpg")
print(result)
Sample Response Payload:
{
"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"
}
Try the package by building an end-to-end web demo. This implementation pairs a Flask backend with a responsive web interface. Below you will find the complete, unmodified source code for the backend (app.py) and the frontend interface (deepface.html, style.css, deepface.js).
app.py)
import os
import cv2
from flask import Flask, render_template, request, jsonify, Response
from flask_cors import CORS
from deepface_antispoofing import DeepFaceAntiSpoofing
import datetime
app = Flask(__name__)
CORS(app) # Enable CORS for all routes
# Config for anti-spoofing
UPLOAD_FOLDER = "static/uploads"
TEMP_FOLDER = "static/temp"
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
os.makedirs(TEMP_FOLDER, exist_ok=True)
camera = cv2.VideoCapture(0)
# Initialize DeepFaceAntiSpoofing for deepfake analysis
try:
deepface_analyzer = DeepFaceAntiSpoofing()
except Exception as e:
print(f"Failed to initialize DeepFaceAntiSpoofing: {str(e)}")
deepface_analyzer = None
def generate_frames():
while True:
success, frame = camera.read()
if not success:
break
ret, buffer = cv2.imencode(".jpg", frame)
frame = buffer.tobytes()
yield (b"--frame\r\n"
b"Content-Type: image/jpeg\r\n\r\n" + frame + b"\r\n")
@app.route("/")
def index():
return render_template("deepface.html")
@app.route("/video_feed")
def video_feed():
return Response(generate_frames(), mimetype="multipart/x-mixed-replace; boundary=frame")
@app.route("/analyze_frame", methods=["POST"])
def analyze_frame():
"""Capture current webcam frame and analyze using DeepFaceAntiSpoofing."""
if deepface_analyzer is None:
return jsonify({"success": False, "error": "DeepFaceAntiSpoofing not initialized"})
success, frame = camera.read()
if not success:
return jsonify({"success": False, "error": "Failed to capture frame"})
temp_path = os.path.join(TEMP_FOLDER, "capture.jpg")
cv2.imwrite(temp_path, frame)
result = deepface_analyzer.analyze_deepface(temp_path)
return jsonify(result)
@app.route("/upload_anti", methods=["POST"])
def upload_anti_file():
if deepface_analyzer is None:
return jsonify({"success": False, "error": "DeepFaceAntiSpoofing not initialized"})
if "file" not in request.files:
return jsonify({"success": False, "error": "No file uploaded"})
file = request.files["file"]
if file.filename == "":
return jsonify({"success": False, "error": "Empty filename"})
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
result = deepface_analyzer.analyze_deepface(path)
print(result)
return jsonify(result)
@app.route("/upload_deep", methods=["POST"])
def upload_deep_image():
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized", "success": False}), 500
if 'image' not in request.files:
return jsonify({"error": "No image uploaded", "success": False}), 400
file = request.files['image']
if file.filename == '':
return jsonify({"error": "No image selected", "success": False}), 400
image_path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(image_path)
try:
result = deepface_analyzer.analyze_image(image_path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Analysis failed: {str(e)}", "success": False}), 500
@app.route("/analyze_face_mask", methods=["POST"])
def analyze_face_mask():
"""Analyze image for face mask detection."""
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
success, frame = camera.read()
if not success:
return jsonify({"error": "Failed to capture frame"})
try:
# Enhance the captured frame
frame = cv2.convertScaleAbs(frame, alpha=1.3, beta=15)
# Save the enhanced frame
temp_path = os.path.join(TEMP_FOLDER, "mask_capture.jpg")
cv2.imwrite(temp_path, frame, [cv2.IMWRITE_JPEG_QUALITY, 95])
# CORRECTED: Use analyze_face_mask method instead of analyze_image
result = deepface_analyzer.analyze_face_mask(temp_path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Face mask analysis failed: {str(e)}"})
@app.route("/upload_face_mask", methods=["POST"])
def upload_face_mask_file():
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
if "file" not in request.files:
return jsonify({"error": "No file uploaded"})
file = request.files["file"]
if file.filename == "":
return jsonify({"error": "Empty filename"})
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
# CORRECTED: Use analyze_face_mask method
result = deepface_analyzer.analyze_face_mask(path)
print(result)
return jsonify(result)
# Emotion Analysis Endpoints
@app.route("/analyze_emotion", methods=["POST"])
def analyze_emotion():
"""Analyze webcam frame for emotion detection."""
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
success, frame = camera.read()
if not success:
return jsonify({"error": "Failed to capture frame"})
try:
temp_path = os.path.join(TEMP_FOLDER, "emotion_capture.jpg")
cv2.imwrite(temp_path, frame)
# CORRECTED: Use analyze_emotion method instead of analyze_image
result = deepface_analyzer.analyze_emotion(temp_path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Emotion analysis failed: {str(e)}"})
@app.route("/upload_emotion", methods=["POST"])
def upload_emotion_file():
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
if "file" not in request.files:
return jsonify({"error": "No file uploaded"})
file = request.files["file"]
if file.filename == "":
return jsonify({"error": "Empty filename"})
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
try:
# CORRECTED: Use analyze_emotion method
result = deepface_analyzer.analyze_emotion(path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Emotion analysis failed: {str(e)}"})
# Comprehensive Analysis Endpoints
@app.route("/comprehensive_analysis_capture", methods=["POST"])
def comprehensive_analysis_capture():
"""Comprehensive analysis from webcam."""
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
success, frame = camera.read()
if not success:
return jsonify({"error": "Failed to capture frame"})
try:
temp_path = os.path.join(TEMP_FOLDER, "comprehensive_capture.jpg")
cv2.imwrite(temp_path, frame)
# CORRECTED: Use analyze_comprehensive method
result = deepface_analyzer.analyze_comprehensive(temp_path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Comprehensive analysis failed: {str(e)}"})
@app.route("/comprehensive_analysis", methods=["POST"])
def comprehensive_analysis():
"""Comprehensive analysis from uploaded file."""
if deepface_analyzer is None:
return jsonify({"error": "DeepFaceAntiSpoofing not initialized"})
if "file" not in request.files:
return jsonify({"error": "No file uploaded"})
file = request.files["file"]
if file.filename == "":
return jsonify({"error": "Empty filename"})
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
try:
# CORRECTED: Use analyze_comprehensive method
result = deepface_analyzer.analyze_comprehensive(path)
return jsonify(result)
except Exception as e:
return jsonify({"error": f"Comprehensive analysis failed: {str(e)}"})
if __name__ == "__main__":
try:
app.run(debug=True)
except Exception as e:
print(f"Failed to start main Flask app: {str(e)}")
raise
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Face Analysis System</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
/* CSS content is displayed in the CSS tab */
</style>
</head>
<body>
<div class="app-container">
<header>
<div class="header-content">
<div class="logo">
<i class="fas fa-shield-alt logo-icon"></i>
<h1 class="logo-text">Advanced Face Analysis System</h1>
</div>
</div>
</header>
<div class="tabs-container">
<div class="tabs">
<button class="tab-btn active" data-tab="deep">
<i class="fas fa-robot"></i> Deepfake Analysis
</button>
<button class="tab-btn" data-tab="anti">
<i class="fas fa-print"></i> Anti-Spoofing
</button>
<button class="tab-btn" data-tab="emotion">
<i class="fas fa-smile"></i> Emotion Analysis
</button>
<button class="tab-btn" data-tab="mask">
<i class="fas fa-head-side-mask"></i> Face Mask Detection
</button>
<button class="tab-btn" data-tab="comprehensive">
<i class="fas fa-brain"></i> Comprehensive Analysis
</button>
</div>
</div>
<main>
<!-- Deepfake Tab -->
<div id="deep-tab" class="tab-content active">
<div class="dashboard-deep">
<!-- Upload Area -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-cloud-upload-alt card-icon"></i>
Image Upload
</h2>
</div>
<div class="card-body">
<div class="upload-area" id="uploadAreaDeep">
<i class="fas fa-cloud-upload-alt upload-icon"></i>
<p class="upload-text">Drag & Drop your image here or click to browse</p>
<input type="file" id="imageInputDeep" accept="image/*" class="file-input">
</div>
<img id="uploadedImageDeep" class="image-preview" alt="Uploaded Image Preview">
<div class="action-buttons">
<button id="analyzeBtnDeep" class="btn btn-primary" disabled>
<i class="fas fa-search"></i> Analyze Image
</button>
<button id="resetBtnDeep" class="btn btn-outline">
<i class="fas fa-redo"></i> Reset
</button>
</div>
<div class="error-message" id="errorMessageDeep"></div>
<!-- REMOVED: <div class="result" id="resultDeep"></div> FROM HERE -->
</div>
</div>
<!-- Result Area -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-chart-bar card-icon"></i>
Analysis Results
</h2>
</div>
<div class="card-body">
<div id="initialMessageDeep">
<p>Upload an image to analyze for deepfake detection, age, gender, and other facial attributes.</p>
</div>
<div class="loading" id="loadingResultsDeep" style="display: none;">
<div class="spinner"></div>
<p class="loading-text">Analyzing...</p>
</div>
<div class="error-message" id="errorMessageResultsDeep" style="display: none;"></div>
<div class="result" id="resultDeep"></div> <!-- MOVED RESULTS HERE -->
</div>
</div>
</div>
</div>
<!-- Anti-Spoofing Tab -->
<div id="anti-tab" class="tab-content">
<div class="dashboard">
<!-- Webcam Card -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-video card-icon"></i>
Live Printed Detection
</h2>
<div class="status-indicator">
<i class="fas fa-circle" style="color: var(--success);"></i>
<span>Camera Active</span>
</div>
</div>
<div class="card-body">
<div class="webcam-container">
<img id="videoFeed" src="/video_feed" alt="Webcam Feed" style="transform: scaleX(-1); width: 100%; height: 100%;">
</div>
<div class="webcam-button-container">
<button id="captureBtn" class="btn btn-primary btn-lg">
<i class="fas fa-camera"></i>
Capture & Analyze
</button>
</div>
<div class="loading" id="loadingCam">
<div class="spinner"></div>
<p class="loading-text">Analyzing for printed images...</p>
</div>
<div class="result" id="camResult"></div>
</div>
</div>
<!-- Upload Card for Anti-Spoofing -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-cloud-upload-alt card-icon"></i>
Image Analysis
</h2>
</div>
<div class="card-body">
<div class="upload-area" id="uploadAreaAnti">
<i class="fas fa-file-upload upload-icon"></i>
<p class="upload-text">Drag & drop an image or click to browse</p>
<input type="file" id="fileInputAnti" accept="image/*" class="file-input">
</div>
<img id="uploadedImageAnti" class="image-preview" alt="Uploaded Image Preview">
<div class="action-buttons">
<button id="analyzeBtnAnti" class="btn btn-primary" disabled>
<i class="fas fa-search"></i> Analyze Image
</button>
<button id="resetBtnAnti" class="btn btn-outline">
<i class="fas fa-redo"></i> Reset
</button>
</div>
<div class="loading" id="loadingUploadAnti">
<div class="spinner"></div>
<p class="loading-text">Processing uploaded image...</p>
</div>
<div class="result" id="uploadResultAnti"></div>
</div>
</div>
</div>
</div>
<!-- Emotion Analysis Tab -->
<div id="emotion-tab" class="tab-content">
<div class="dashboard">
<!-- Webcam Card for Emotion -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-smile card-icon"></i>
Live Emotion Detection
</h2>
<div class="status-indicator">
<i class="fas fa-circle" style="color: var(--success);"></i>
<span>Camera Active</span>
</div>
</div>
<div class="card-body">
<div class="webcam-container">
<img id="videoFeedEmotion" src="/video_feed" alt="Webcam Feed" style="transform: scaleX(-1); width: 100%; height: 100%;">
</div>
<div class="webcam-button-container">
<button id="captureBtnEmotion" class="btn btn-primary btn-lg">
<i class="fas fa-camera"></i>
Capture & Analyze Emotions
</button>
</div>
<div class="loading" id="loadingCamEmotion">
<div class="spinner"></div>
<p class="loading-text">Analyzing facial emotions...</p>
</div>
<div class="result" id="camResultEmotion"></div>
</div>
</div>
<!-- Upload Card for Emotion -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-cloud-upload-alt card-icon"></i>
Image Emotion Analysis
</h2>
</div>
<div class="card-body">
<div class="upload-area" id="uploadAreaEmotion">
<i class="fas fa-file-upload upload-icon"></i>
<p class="upload-text">Drag & drop an image or click to browse</p>
<input type="file" id="fileInputEmotion" accept="image/*" class="file-input">
</div>
<img id="uploadedImageEmotion" class="image-preview" alt="Uploaded Image Preview">
<div class="action-buttons">
<button id="analyzeBtnEmotion" class="btn btn-primary" disabled>
<i class="fas fa-search"></i> Analyze Emotions
</button>
<button id="resetBtnEmotion" class="btn btn-outline">
<i class="fas fa-redo"></i> Reset
</button>
</div>
<div class="loading" id="loadingUploadEmotion">
<div class="spinner"></div>
<p class="loading-text">Processing emotions...</p>
</div>
<div class="result" id="uploadResultEmotion"></div>
</div>
</div>
</div>
</div>
<!-- Face Mask Detection Tab -->
<div id="mask-tab" class="tab-content">
<div class="dashboard">
<!-- Webcam Card for Mask -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-head-side-mask card-icon"></i>
Live Mask Detection
</h2>
<div class="status-indicator">
<i class="fas fa-circle" style="color: var(--success);"></i>
<span>Camera Active</span>
</div>
</div>
<div class="card-body">
<div class="webcam-container">
<img id="videoFeedMask" src="/video_feed" alt="Webcam Feed" style="transform: scaleX(-1); width: 100%; height: 100%;">
</div>
<div class="webcam-button-container">
<button id="captureBtnMask" class="btn btn-primary btn-lg">
<i class="fas fa-camera"></i>
Capture & Analyze Mask
</button>
</div>
<div class="loading" id="loadingCamMask">
<div class="spinner"></div>
<p class="loading-text">Analyzing for face mask...</p>
</div>
<div class="result" id="camResultMask"></div>
</div>
</div>
<!-- Upload Card for Mask -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-cloud-upload-alt card-icon"></i>
Image Mask Detection
</h2>
</div>
<div class="card-body">
<div class="upload-area" id="uploadAreaMask">
<i class="fas fa-file-upload upload-icon"></i>
<p class="upload-text">Drag & drop an image or click to browse</p>
<input type="file" id="fileInputMask" accept="image/*" class="file-input">
</div>
<img id="uploadedImageMask" class="image-preview" alt="Uploaded Image Preview">
<div class="action-buttons">
<button id="analyzeBtnMask" class="btn btn-primary" disabled>
<i class="fas fa-search"></i> Analyze Mask
</button>
<button id="resetBtnMask" class="btn btn-outline">
<i class="fas fa-redo"></i> Reset
</button>
</div>
<div class="loading" id="loadingUploadMask">
<div class="spinner"></div>
<p class="loading-text">Processing mask detection...</p>
</div>
<div class="result" id="uploadResultMask"></div>
</div>
</div>
</div>
</div>
<!-- Comprehensive Analysis Tab -->
<div id="comprehensive-tab" class="tab-content">
<div class="dashboard">
<!-- Webcam Card for Comprehensive -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-brain card-icon"></i>
Live Comprehensive Analysis
</h2>
<div class="status-indicator">
<i class="fas fa-circle" style="color: var(--success);"></i>
<span>Camera Active</span>
</div>
</div>
<div class="card-body">
<div class="webcam-container">
<img id="videoFeedComprehensive" src="/video_feed" alt="Webcam Feed" style="transform: scaleX(-1); width: 100%; height: 100%;">
</div>
<div class="webcam-button-container">
<button id="captureBtnComprehensive" class="btn btn-primary btn-lg">
<i class="fas fa-camera"></i>
Complete Analysis
</button>
</div>
<div class="loading" id="loadingCamComprehensive">
<div class="spinner"></div>
<p class="loading-text">Running comprehensive analysis...</p>
</div>
<div class="result" id="camResultComprehensive"></div>
</div>
</div>
<!-- Upload Card for Comprehensive -->
<div class="card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-cloud-upload-alt card-icon"></i>
Comprehensive Image Analysis
</h2>
</div>
<div class="card-body">
<div class="upload-area" id="uploadAreaComprehensive">
<i class="fas fa-file-upload upload-icon"></i>
<p class="upload-text">Drag & drop an image or click to browse</p>
<input type="file" id="fileInputComprehensive" accept="image/*" class="file-input">
</div>
<img id="uploadedImageComprehensive" class="image-preview" alt="Uploaded Image Preview">
<div class="action-buttons">
<button id="analyzeBtnComprehensive" class="btn btn-primary" disabled>
<i class="fas fa-search"></i> Complete Analysis
</button>
<button id="resetBtnComprehensive" class="btn btn-outline">
<i class="fas fa-redo"></i> Reset
</button>
</div>
<div class="loading" id="loadingUploadComprehensive">
<div class="spinner"></div>
<p class="loading-text">Running all analyses...</p>
</div>
<div class="result" id="uploadResultComprehensive"></div>
</div>
</div>
</div>
</div>
</main>
</div>
<script>
/* JavaScript content is displayed in the JavaScript tab */
</script>
</body>
</html>
/* Your existing CSS remains exactly the same */
:root {
--primary: #2563eb;
--primary-dark: #1d4ed8;
--primary-light: #dbeafe;
--secondary: #7e22ce;
--success: #22c55e;
--success-light: #dcfce7;
--danger: #ef4444;
--danger-light: #fee2e2;
--warning: #f59e0b;
--warning-light: #fef3c7;
--info: #3b82f6;
--info-light: #dbeafe;
--purple: #8b5cf6;
--pink: #ec4899;
--gray-50: #f9fafb;
--gray-100: #f3f4f6;
--gray-200: #e5e7eb;
--gray-300: #d1d5db;
--gray-400: #9ca3af;
--gray-500: #6b7280;
--gray-600: #4b5563;
--gray-700: #374151;
--gray-800: #1f2937;
--gray-900: #111827;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--radius: 16px;
--radius-sm: 8px;
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', sans-serif;
background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
color: var(--gray-800);
line-height: 1.6;
min-height: 100vh;
}
.app-container {
max-width: 1600px;
margin: 0 auto;
padding: 1.5rem;
}
/* Header Styles */
header {
background: linear-gradient(120deg, var(--primary) 0%, var(--secondary) 100%);
color: white;
border-radius: var(--radius);
padding: 2rem 2.5rem;
margin-bottom: 2rem;
box-shadow: var(--shadow-lg);
animation: slideDown 0.5s ease;
position: relative;
overflow: hidden;
}
header::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
z-index: 1;
}
.header-content {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
position: relative;
z-index: 2;
}
.logo {
display: flex;
align-items: center;
gap: 1rem;
}
.logo-icon {
font-size: 2.5rem;
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}
.logo-text {
font-size: 1.75rem;
font-weight: 700;
letter-spacing: -0.025em;
}
/* Tabs Styles */
.tabs-container {
background: white;
border-radius: var(--radius);
padding: 1.5rem;
margin-bottom: 2rem;
box-shadow: var(--shadow);
animation: fadeIn 0.5s ease;
}
.tabs {
display: flex;
gap: 0.5rem;
justify-content: center;
flex-wrap: wrap;
}
.tab-btn {
padding: 0.875rem 1.75rem;
border-radius: var(--radius-sm);
background: var(--gray-100);
color: var(--gray-600);
font-weight: 500;
cursor: pointer;
transition: var(--transition);
border: none;
box-shadow: var(--shadow-sm);
font-size: 0.95rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.tab-btn:hover {
background: var(--gray-200);
transform: translateY(-2px);
box-shadow: var(--shadow);
}
.tab-btn.active {
background: var(--primary);
color: white;
box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
transform: translateY(-2px);
}
.tab-content {
display: none;
animation: fadeIn 0.5s ease;
}
.tab-content.active {
display: block;
}
/* Main Content */
.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
gap: 2rem;
margin-bottom: 2rem;
}
.dashboard-deep {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
margin-bottom: 2rem;
}
.card {
background: white;
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
transition: var(--transition);
animation: fadeIn 0.5s ease;
position: relative;
}
.card:hover {
box-shadow: var(--shadow-lg);
transform: translateY(-5px);
}
.card-header {
padding: 1.5rem 1.75rem;
border-bottom: 1px solid var(--gray-200);
display: flex;
align-items: center;
justify-content: space-between;
background: linear-gradient(90deg, var(--gray-50) 0%, white 100%);
}
.card-title {
font-size: 1.25rem;
font-weight: 600;
color: var(--gray-800);
display: flex;
align-items: center;
gap: 0.75rem;
}
.card-icon {
color: var(--primary);
font-size: 1.25rem;
}
.card-body {
padding: 1.75rem;
}
/* Webcam Styles */
.webcam-container {
position: relative;
width: 100%;
height: 350px;
border-radius: var(--radius-sm);
overflow: hidden;
background: var(--gray-100);
margin-bottom: 1.5rem;
box-shadow: var(--shadow-sm);
}
#videoFeed {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: var(--radius-sm);
}
.webcam-button-container {
display: flex;
justify-content: center;
margin-bottom: 1.5rem;
}
/* Upload Styles */
.upload-area {
border: 2px dashed var(--gray-300);
border-radius: var(--radius-sm);
padding: 2.5rem;
text-align: center;
cursor: pointer;
transition: var(--transition);
margin-bottom: 1.5rem;
position: relative;
height: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: var(--gray-50);
}
.upload-area:hover {
border-color: var(--primary);
background: var(--primary-light);
}
.upload-icon {
font-size: 3.5rem;
color: var(--gray-400);
margin-bottom: 1rem;
transition: var(--transition);
}
.upload-area:hover .upload-icon {
color: var(--primary);
transform: scale(1.1);
}
.upload-text {
color: var(--gray-600);
margin-bottom: 1rem;
font-size: 1.1rem;
}
.file-input {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
/* Button Styles */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.875rem 1.75rem;
font-weight: 500;
border-radius: var(--radius-sm);
cursor: pointer;
transition: var(--transition);
border: none;
font-size: 1rem;
box-shadow: var(--shadow-sm);
}
.btn-primary {
background: var(--primary);
color: white;
box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
background: var(--primary-dark);
transform: translateY(-2px);
box-shadow: 0 6px 10px rgba(37, 99, 235, 0.3);
}
.btn-outline {
background: white;
border: 1px solid var(--primary);
color: var(--primary);
box-shadow: var(--shadow-sm);
}
.btn-outline:hover {
background: var(--gray-100);
transform: translateY(-2px);
}
.btn-lg {
padding: 1rem 2rem;
font-size: 1.1rem;
}
/* Loading Animation */
.loading {
text-align: center;
padding: 2.5rem;
display: none;
}
.spinner {
width: 50px;
height: 50px;
border: 4px solid rgba(37, 99, 235, 0.2);
border-radius: 50%;
border-top-color: var(--primary);
animation: spin 1s linear infinite;
margin: 0 auto 1rem;
}
.loading-text {
color: var(--gray-600);
font-weight: 500;
}
/* Result Styles */
.result {
padding: 1.75rem;
border-radius: var(--radius-sm);
margin-top: 1.5rem;
animation: fadeIn 0.5s ease;
display: none;
}
.result-real {
background: var(--success-light);
border-left: 4px solid var(--success);
}
.result-fake {
background: var(--danger-light);
border-left: 4px solid var(--danger);
}
.result-error {
background: var(--warning-light);
border-left: 4px solid var(--warning);
}
.result-info {
background: var(--info-light);
border-left: 4px solid var(--info);
}
.result-emotion {
background: rgba(139, 92, 246, 0.1);
border-left: 4px solid var(--purple);
}
.result-mask {
background: rgba(59, 130, 246, 0.1);
border-left: 4px solid var(--info);
}
.result-header {
display: flex;
align-items: center;
margin-bottom: 1rem;
gap: 0.75rem;
}
.result-icon {
font-size: 1.5rem;
}
.result-real .result-icon {
color: var(--success);
}
.result-fake .result-icon {
color: var(--danger);
}
.result-error .result-icon {
color: var(--warning);
}
.result-info .result-icon {
color: var(--info);
}
.result-emotion .result-icon {
color: var(--purple);
}
.result-mask .result-icon {
color: var(--info);
}
.result-title {
font-size: 1.25rem;
font-weight: 600;
}
.result-details {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.result-detail {
background: white;
padding: 1rem;
border-radius: var(--radius-sm);
box-shadow: var(--shadow-sm);
border-left: 3px solid var(--primary);
}
.detail-label {
font-size: 0.875rem;
color: var(--gray-500);
margin-bottom: 0.25rem;
}
.detail-value {
font-weight: 600;
color: var(--gray-800);
}
/* Confidence Meter */
.confidence-meter {
height: 10px;
background: var(--gray-200);
border-radius: 5px;
overflow: hidden;
margin: 1rem 0;
}
.confidence-level {
height: 100%;
border-radius: 5px;
transition: width 1s ease;
}
.meter-real {
background: var(--success);
}
.meter-fake {
background: var(--danger);
}
.meter-emotion {
background: var(--purple);
}
.meter-mask {
background: var(--info);
}
/* Emotion Progress Bars */
.emotion-progress {
margin: 0.5rem 0;
}
.emotion-row {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
gap: 1rem;
}
.emotion-label {
width: 80px;
font-size: 0.875rem;
font-weight: 500;
}
.emotion-bar-container {
flex: 1;
height: 8px;
background: var(--gray-200);
border-radius: 4px;
overflow: hidden;
}
.emotion-bar {
height: 100%;
border-radius: 4px;
transition: width 1s ease;
}
.emotion-value {
width: 50px;
text-align: right;
font-size: 0.875rem;
font-weight: 600;
}
/* Comprehensive Analysis Grid */
.analysis-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.analysis-section {
background: white;
padding: 1.5rem;
border-radius: var(--radius-sm);
box-shadow: var(--shadow-sm);
border-left: 4px solid var(--primary);
}
.section-title {
font-size: 1.1rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--gray-800);
display: flex;
align-items: center;
gap: 0.5rem;
}
/* Image Preview Styles */
.image-preview {
width: 100%;
max-height: 300px;
object-fit: contain;
border-radius: var(--radius-sm);
display: none;
box-shadow: var(--shadow-md);
margin-bottom: 1.5rem;
}
.action-buttons {
display: flex;
gap: 1rem;
margin-top: 1rem;
}
.error-message {
color: var(--danger);
margin-top: 1rem;
display: none;
text-align: center;
padding: 1rem;
background: var(--danger-light);
border-radius: var(--radius-sm);
}
/* Status Indicator */
.status-indicator {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.875rem;
color: var(--gray-600);
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
/* Responsive Design */
@media (max-width: 1200px) {
.dashboard, .dashboard-deep {
grid-template-columns: 1fr;
}
.tabs {
flex-direction: row;
overflow-x: auto;
justify-content: flex-start;
}
.tab-btn {
white-space: nowrap;
}
}
@media (max-width: 768px) {
.app-container {
padding: 1rem;
}
.header-content {
flex-direction: column;
gap: 1rem;
text-align: center;
}
.card {
min-width: auto;
}
.webcam-container {
height: 280px;
}
.upload-area {
height: 250px;
padding: 1.5rem;
}
.analysis-grid {
grid-template-columns: 1fr;
}
.action-buttons {
flex-direction: column;
}
.btn {
width: 100%;
}
}
@media (max-width: 480px) {
.app-container {
padding: 0.75rem;
}
.card-body {
padding: 1rem;
}
.result-details {
grid-template-columns: 1fr;
}
.tabs {
flex-direction: column;
}
.tab-btn {
width: 100%;
justify-content: center;
}
.logo-text {
font-size: 1.5rem;
}
}
// Tab Switching
const tabBtns = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
// Set Deepfake tab as active by default
tabBtns.forEach(btn => {
if (btn.dataset.tab === 'deep') {
btn.classList.add('active');
} else {
btn.classList.remove('active');
}
});
tabContents.forEach(content => {
if (content.id === 'deep-tab') {
content.classList.add('active');
} else {
content.classList.remove('active');
}
});
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
tabBtns.forEach(b => b.classList.remove('active'));
tabContents.forEach(c => c.classList.remove('active'));
btn.classList.add('active');
document.getElementById(`${btn.dataset.tab}-tab`).classList.add('active');
});
});
// ========== DEEPFAKE TAB ==========
const uploadAreaDeep = document.getElementById('uploadAreaDeep');
const fileInputDeep = document.getElementById('imageInputDeep');
const analyzeBtnDeep = document.getElementById('analyzeBtnDeep');
const resetBtnDeep = document.getElementById('resetBtnDeep');
const uploadedImageDeep = document.getElementById('uploadedImageDeep');
const resultDeep = document.getElementById('resultDeep');
const errorMessageDeep = document.getElementById('errorMessageDeep');
const loadingDeep = document.getElementById('loadingDeep');
const initialMessageDeep = document.getElementById('initialMessageDeep');
const loadingResultsDeep = document.getElementById('loadingResultsDeep');
const errorMessageResultsDeep = document.getElementById('errorMessageResultsDeep');
let currentFileDeep = null; // Store the current file
uploadAreaDeep.addEventListener('click', () => {
fileInputDeep.click();
});
// Drag and drop for deep
uploadAreaDeep.addEventListener('dragover', (e) => {
e.preventDefault();
uploadAreaDeep.style.borderColor = 'var(--primary)';
uploadAreaDeep.style.backgroundColor = 'var(--primary-light)';
});
uploadAreaDeep.addEventListener('dragleave', () => {
uploadAreaDeep.style.borderColor = 'var(--gray-300)';
uploadAreaDeep.style.backgroundColor = 'var(--gray-50)';
});
uploadAreaDeep.addEventListener('drop', (e) => {
e.preventDefault();
uploadAreaDeep.style.borderColor = 'var(--gray-300)';
uploadAreaDeep.style.backgroundColor = 'var(--gray-50)';
if (e.dataTransfer.files.length) {
const file = e.dataTransfer.files[0];
if (file.type.match('image.*')) {
currentFileDeep = file;
handleDeepFileSelect(file);
} else {
showDeepError('Please select a valid image file (JPEG, PNG, etc.)');
}
}
});
fileInputDeep.addEventListener('change', function(e) {
if (this.files.length > 0) {
const file = this.files[0];
if (file.type.match('image.*')) {
currentFileDeep = file;
handleDeepFileSelect(file);
} else {
showDeepError('Please select a valid image file (JPEG, PNG, etc.)');
}
}
});
analyzeBtnDeep.addEventListener('click', analyzeDeepImage);
resetBtnDeep.addEventListener('click', resetDeep);
function handleDeepFileSelect(file) {
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageDeep.src = e.target.result;
uploadedImageDeep.style.display = 'block';
uploadAreaDeep.style.display = 'none';
analyzeBtnDeep.disabled = false;
hideDeepError();
// Reset results area when new image is selected
resetResultsArea();
};
reader.readAsDataURL(file);
}
function analyzeDeepImage() {
if (!currentFileDeep) {
showDeepError('Please select an image first');
return;
}
errorMessageDeep.style.display = 'none';
loadingDeep.style.display = 'block';
analyzeBtnDeep.disabled = true;
// Show loading in results area
initialMessageDeep.style.display = 'none';
loadingResultsDeep.style.display = 'block';
errorMessageResultsDeep.style.display = 'none';
resultDeep.style.display = 'none';
const formData = new FormData();
formData.append('image', currentFileDeep);
console.log('Sending request to /upload_deep...');
fetch('/upload_deep', {
method: 'POST',
body: formData
})
.then(response => {
console.log('Response status:', response.status);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Received data:', data);
loadingDeep.style.display = 'none';
loadingResultsDeep.style.display = 'none';
analyzeBtnDeep.disabled = false;
// Check if there's an error in the response
if (data.error) {
showResultsError(data.error || 'Analysis failed');
return;
}
// If we have age data, then the analysis was successful
if (!data.age) {
showResultsError('No face detected or analysis failed');
return;
}
// Determine if real or fake based on dominant_spoof
const isReal = data.dominant_spoof === 'Real';
resultDeep.className = `result ${isReal ? "result-real" : "result-fake"}`;
// Safely access nested properties with fallbacks
const spoofConfidence = data.spoof && data.dominant_spoof ?
(data.spoof[data.dominant_spoof] * 100).toFixed(1) : '0';
const genderConfidence = data.gender && data.dominant_gender ?
Math.round(data.gender[data.dominant_gender] * 100) : '0';
resultDeep.innerHTML = `
<div class="result-header">
<i class="fas ${isReal ? "fa-check-circle" : "fa-exclamation-triangle"} result-icon"></i>
<h3 class="result-title">${isReal ? "Genuine Face Detected" : "Deepfake Detected"}</h3>
</div>
<p>${isReal ? "The system has verified this as a real face." : "Warning: This appears to be a deepfake."}</p>
<div class="confidence-meter">
<div class="confidence-level ${isReal ? "meter-real" : "meter-fake"}" style="width: ${spoofConfidence}%"></div>
</div>
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Age</div>
<div class="detail-value">${data.age || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Dominant Gender</div>
<div class="detail-value">${data.dominant_gender || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Gender Confidence</div>
<div class="detail-value">${genderConfidence}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Face Type</div>
<div class="detail-value">${data.dominant_spoof || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Spoof Confidence</div>
<div class="detail-value">${spoofConfidence}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Timestamp</div>
<div class="detail-value">${data.timestamp || new Date().toLocaleString()}</div>
</div>
</div>
`;
resultDeep.style.display = 'block';
})
.catch(err => {
console.error('Fetch error:', err);
loadingDeep.style.display = 'none';
loadingResultsDeep.style.display = 'none';
analyzeBtnDeep.disabled = false;
showResultsError('An error occurred while processing the image: ' + err.message);
});
}
function resetDeep() {
fileInputDeep.value = '';
currentFileDeep = null;
uploadedImageDeep.style.display = 'none';
uploadAreaDeep.style.display = 'flex';
loadingDeep.style.display = 'none';
analyzeBtnDeep.disabled = true;
hideDeepError();
resetResultsArea();
}
function resetResultsArea() {
initialMessageDeep.style.display = 'block';
loadingResultsDeep.style.display = 'none';
errorMessageResultsDeep.style.display = 'none';
resultDeep.style.display = 'none';
}
function showDeepError(message) {
errorMessageDeep.textContent = message;
errorMessageDeep.style.display = 'block';
}
function showResultsError(message) {
errorMessageResultsDeep.textContent = message;
errorMessageResultsDeep.style.display = 'block';
resultDeep.style.display = 'none';
}
function hideDeepError() {
errorMessageDeep.style.display = 'none';
}
// ========== ANTI-SPOOFING TAB ==========
const captureBtn = document.getElementById("captureBtn");
const loadingCam = document.getElementById("loadingCam");
const camResult = document.getElementById("camResult");
const fileInputAnti = document.getElementById("fileInputAnti");
const uploadAreaAnti = document.getElementById("uploadAreaAnti");
const uploadedImageAnti = document.getElementById("uploadedImageAnti");
const analyzeBtnAnti = document.getElementById("analyzeBtnAnti");
const resetBtnAnti = document.getElementById("resetBtnAnti");
const loadingUploadAnti = document.getElementById("loadingUploadAnti");
const uploadResultAnti = document.getElementById("uploadResultAnti");
// Capture from webcam
captureBtn.addEventListener("click", () => {
loadingCam.style.display = "block";
camResult.style.display = "none";
captureBtn.style.animation = "pulse 0.5s";
setTimeout(() => {
captureBtn.style.animation = "";
}, 500);
fetch("/analyze_frame", { method: "POST" })
.then(response => response.json())
.then(data => {
loadingCam.style.display = "none";
showAntiResult(data, camResult);
})
.catch(err => {
loadingCam.style.display = "none";
showAntiError(err, camResult);
});
});
// Upload file handling for anti
fileInputAnti.addEventListener("change", () => {
const file = fileInputAnti.files[0];
if (!file) return;
if (!file.type.match('image.*')) {
showAntiError('Please select a valid image file (JPEG, PNG, etc.)', uploadResultAnti);
return;
}
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageAnti.src = e.target.result;
uploadedImageAnti.style.display = 'block';
uploadAreaAnti.style.display = 'none';
analyzeBtnAnti.disabled = false;
};
reader.readAsDataURL(file);
});
analyzeBtnAnti.addEventListener("click", () => {
const file = fileInputAnti.files[0];
if (!file) return;
const formData = new FormData();
formData.append("file", file);
loadingUploadAnti.style.display = "block";
uploadResultAnti.style.display = "none";
fetch("/upload_anti", { method: "POST", body: formData })
.then(response => response.json())
.then(data => {
loadingUploadAnti.style.display = "none";
showAntiResult(data, uploadResultAnti);
})
.catch(err => {
loadingUploadAnti.style.display = "none";
showAntiError(err, uploadResultAnti);
});
});
resetBtnAnti.addEventListener("click", () => {
fileInputAnti.value = '';
uploadedImageAnti.style.display = 'none';
uploadAreaAnti.style.display = 'flex';
uploadResultAnti.style.display = 'none';
loadingUploadAnti.style.display = 'none';
analyzeBtnAnti.disabled = true;
});
// Drag and drop for anti
uploadAreaAnti.addEventListener("dragover", (e) => {
e.preventDefault();
uploadAreaAnti.style.borderColor = "var(--primary)";
uploadAreaAnti.style.backgroundColor = "var(--primary-light)";
});
uploadAreaAnti.addEventListener("dragleave", () => {
uploadAreaAnti.style.borderColor = "var(--gray-300)";
uploadAreaAnti.style.backgroundColor = "var(--gray-50)";
});
uploadAreaAnti.addEventListener("drop", (e) => {
e.preventDefault();
uploadAreaAnti.style.borderColor = "var(--gray-300)";
uploadAreaAnti.style.backgroundColor = "var(--gray-50)";
if (e.dataTransfer.files.length) {
fileInputAnti.files = e.dataTransfer.files;
const event = new Event("change", { bubbles: true });
fileInputAnti.dispatchEvent(event);
}
});
function showAntiResult(data, container) {
if (!data.error) {
const isReal = data.dominant_printed === 'Real';
container.className = `result ${isReal ? "result-real" : "result-fake"}`;
container.innerHTML = `
<div class="result-header">
<i class="fas ${isReal ? "fa-check-circle" : "fa-exclamation-triangle"} result-icon"></i>
<h3 class="result-title">${isReal ? "Real Image Detected" : "Printed Image Detected"}</h3>
</div>
<p>${isReal ? "The system has verified this as a real (non-printed) image." : "Warning: This appears to be a printed image."}</p>
<div class="confidence-meter">
<div class="confidence-level ${isReal ? "meter-real" : "meter-fake"}" style="width: 0%"></div>
</div>
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${(data.confidence * 100).toFixed(1)}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Real Probability</div>
<div class="detail-value">${(data.printed_analysis.Real * 100).toFixed(1)}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Printed Probability</div>
<div class="detail-value">${(data.printed_analysis.Printed * 100).toFixed(1)}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Detection Type</div>
<div class="detail-value">Printed Image Detection</div>
</div>
<div class="result-detail">
<div class="detail-label">Timestamp</div>
<div class="detail-value">${data.timestamp}</div>
</div>
</div>
`;
setTimeout(() => {
const meter = container.querySelector(".confidence-level");
meter.style.width = `${data.confidence * 100}%`;
}, 100);
} else {
showAntiError(data.error, container);
}
container.style.display = "block";
}
function showAntiError(error, container) {
container.className = "result result-error";
container.innerHTML = `
<div class="result-header">
<i class="fas fa-exclamation-circle result-icon"></i>
<h3 class="result-title">Analysis Error</h3>
</div>
<p>${error.message || error.error || "An unexpected error occurred"}</p>
<p>Please try again or use a different image.</p>
`;
container.style.display = "block";
}
// ========== EMOTION ANALYSIS TAB ==========
const captureBtnEmotion = document.getElementById("captureBtnEmotion");
const loadingCamEmotion = document.getElementById("loadingCamEmotion");
const camResultEmotion = document.getElementById("camResultEmotion");
const fileInputEmotion = document.getElementById("fileInputEmotion");
const uploadAreaEmotion = document.getElementById("uploadAreaEmotion");
const uploadedImageEmotion = document.getElementById("uploadedImageEmotion");
const analyzeBtnEmotion = document.getElementById("analyzeBtnEmotion");
const resetBtnEmotion = document.getElementById("resetBtnEmotion");
const loadingUploadEmotion = document.getElementById("loadingUploadEmotion");
const uploadResultEmotion = document.getElementById("uploadResultEmotion");
captureBtnEmotion.addEventListener("click", () => {
loadingCamEmotion.style.display = "block";
camResultEmotion.style.display = "none";
fetch("/analyze_emotion", { method: "POST" })
.then(response => response.json())
.then(data => {
loadingCamEmotion.style.display = "none";
showEmotionResult(data, camResultEmotion);
})
.catch(err => {
loadingCamEmotion.style.display = "none";
showEmotionError(err, camResultEmotion);
});
});
fileInputEmotion.addEventListener("change", handleEmotionFileSelect);
analyzeBtnEmotion.addEventListener("click", analyzeEmotionImage);
resetBtnEmotion.addEventListener("click", resetEmotion);
function handleEmotionFileSelect() {
const file = fileInputEmotion.files[0];
if (!file) return;
if (!file.type.match('image.*')) {
showEmotionError('Please select a valid image file', uploadResultEmotion);
return;
}
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageEmotion.src = e.target.result;
uploadedImageEmotion.style.display = 'block';
uploadAreaEmotion.style.display = 'none';
analyzeBtnEmotion.disabled = false;
};
reader.readAsDataURL(file);
}
function analyzeEmotionImage() {
const file = fileInputEmotion.files[0];
if (!file) return;
const formData = new FormData();
formData.append("file", file);
loadingUploadEmotion.style.display = "block";
uploadResultEmotion.style.display = "none";
fetch("/upload_emotion", { method: "POST", body: formData })
.then(response => response.json())
.then(data => {
loadingUploadEmotion.style.display = "none";
showEmotionResult(data, uploadResultEmotion);
})
.catch(err => {
loadingUploadEmotion.style.display = "none";
showEmotionError(err, uploadResultEmotion);
});
}
function resetEmotion() {
fileInputEmotion.value = '';
uploadedImageEmotion.style.display = 'none';
uploadAreaEmotion.style.display = 'flex';
uploadResultEmotion.style.display = 'none';
loadingUploadEmotion.style.display = 'none';
analyzeBtnEmotion.disabled = true;
}
function showEmotionResult(data, container) {
if (!data.error) {
container.className = "result result-emotion";
const emotions = data.emotions || {};
const dominantEmotion = data.dominant_emotion || 'neutral';
const confidence = (data.confidence * 100).toFixed(1);
container.innerHTML = `
<div class="result-header">
<i class="fas fa-smile-beam result-icon"></i>
<h3 class="result-title">Emotion: ${dominantEmotion.charAt(0).toUpperCase() + dominantEmotion.slice(1)}</h3>
</div>
<p>Detected emotion with ${confidence}% confidence</p>
<div class="confidence-meter">
<div class="confidence-level meter-emotion" style="width: ${confidence}%"></div>
</div>
<div class="emotion-progress">
${Object.entries(emotions).map(([emotion, value]) => `
<div class="emotion-row">
<div class="emotion-label">${emotion.charAt(0).toUpperCase() + emotion.slice(1)}</div>
<div class="emotion-bar-container">
<div class="emotion-bar" style="width: ${value * 100}%; background: ${getEmotionColor(emotion)}"></div>
</div>
<div class="emotion-value">${(value * 100).toFixed(1)}%</div>
</div>
`).join('')}
</div>
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Dominant Emotion</div>
<div class="detail-value">${dominantEmotion}</div>
</div>
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${confidence}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Analysis Type</div>
<div class="detail-value">Emotion Detection</div>
</div>
<div class="result-detail">
<div class="detail-label">Timestamp</div>
<div class="detail-value">${data.timestamp}</div>
</div>
</div>
`;
} else {
showEmotionError(data.error, container);
}
container.style.display = "block";
}
function getEmotionColor(emotion) {
const colors = {
angry: '#ef4444',
disgust: '#8b5cf6',
fear: '#f59e0b',
happy: '#22c55e',
neutral: '#6b7280',
sad: '#3b82f6',
surprise: '#ec4899'
};
return colors[emotion] || '#6b7280';
}
function showEmotionError(error, container) {
container.className = "result result-error";
container.innerHTML = `
<div class="result-header">
<i class="fas fa-exclamation-circle result-icon"></i>
<h3 class="result-title">Emotion Analysis Error</h3>
</div>
<p>${error.message || error.error || "An unexpected error occurred"}</p>
<p>Please try again or use a different image.</p>
`;
container.style.display = "block";
}
// ========== FACE MASK DETECTION TAB ==========
const captureBtnMask = document.getElementById("captureBtnMask");
const loadingCamMask = document.getElementById("loadingCamMask");
const camResultMask = document.getElementById("camResultMask");
const fileInputMask = document.getElementById("fileInputMask");
const uploadAreaMask = document.getElementById("uploadAreaMask");
const uploadedImageMask = document.getElementById("uploadedImageMask");
const analyzeBtnMask = document.getElementById("analyzeBtnMask");
const resetBtnMask = document.getElementById("resetBtnMask");
const loadingUploadMask = document.getElementById("loadingUploadMask");
const uploadResultMask = document.getElementById("uploadResultMask");
captureBtnMask.addEventListener("click", () => {
loadingCamMask.style.display = "block";
camResultMask.style.display = "none";
fetch("/analyze_face_mask", { method: "POST" })
.then(response => response.json())
.then(data => {
loadingCamMask.style.display = "none";
showMaskResult(data, camResultMask);
})
.catch(err => {
loadingCamMask.style.display = "none";
showMaskError(err, camResultMask);
});
});
fileInputMask.addEventListener("change", handleMaskFileSelect);
analyzeBtnMask.addEventListener("click", analyzeMaskImage);
resetBtnMask.addEventListener("click", resetMask);
function handleMaskFileSelect() {
const file = fileInputMask.files[0];
if (!file) return;
if (!file.type.match('image.*')) {
showMaskError('Please select a valid image file', uploadResultMask);
return;
}
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageMask.src = e.target.result;
uploadedImageMask.style.display = 'block';
uploadAreaMask.style.display = 'none';
analyzeBtnMask.disabled = false;
};
reader.readAsDataURL(file);
}
function analyzeMaskImage() {
const file = fileInputMask.files[0];
if (!file) return;
const formData = new FormData();
formData.append("file", file);
loadingUploadMask.style.display = "block";
uploadResultMask.style.display = "none";
fetch("/upload_face_mask", { method: "POST", body: formData })
.then(response => response.json())
.then(data => {
loadingUploadMask.style.display = "none";
showMaskResult(data, uploadResultMask);
})
.catch(err => {
loadingUploadMask.style.display = "none";
showMaskError(err, uploadResultMask);
});
}
function resetMask() {
fileInputMask.value = '';
uploadedImageMask.style.display = 'none';
uploadAreaMask.style.display = 'flex';
uploadResultMask.style.display = 'none';
loadingUploadMask.style.display = 'none';
analyzeBtnMask.disabled = true;
}
function showMaskResult(data, container) {
if (!data.error) {
const hasMask = data.has_mask;
const maskStatus = data.mask_status;
const confidence = (data.confidence * 100).toFixed(1);
const withMaskProb = (data.with_mask_prob * 100).toFixed(1);
const withoutMaskProb = (data.without_mask_prob * 100).toFixed(1);
container.className = `result result-mask`;
container.innerHTML = `
<div class="result-header">
<i class="fas ${hasMask ? "fa-head-side-mask" : "fa-user"} result-icon"></i>
<h3 class="result-title">${maskStatus}</h3>
</div>
<p>${hasMask ? "Face mask detected." : "No face mask detected."}</p>
<div class="confidence-meter">
<div class="confidence-level meter-mask" style="width: ${confidence}%"></div>
</div>
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Mask Status</div>
<div class="detail-value">${maskStatus}</div>
</div>
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${confidence}%</div>
</div>
<div class="result-detail">
<div class="detail-label">With Mask Probability</div>
<div class="detail-value">${withMaskProb}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Without Mask Probability</div>
<div class="detail-value">${withoutMaskProb}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Detection Type</div>
<div class="detail-value">Face Mask Detection</div>
</div>
<div class="result-detail">
<div class="detail-label">Timestamp</div>
<div class="detail-value">${data.timestamp}</div>
</div>
</div>
`;
} else {
showMaskError(data.error, container);
}
container.style.display = "block";
}
function showMaskError(error, container) {
container.className = "result result-error";
container.innerHTML = `
<div class="result-header">
<i class="fas fa-exclamation-circle result-icon"></i>
<h3 class="result-title">Mask Detection Error</h3>
</div>
<p>${error.message || error.error || "An unexpected error occurred"}</p>
<p>Please try again or use a different image.</p>
`;
container.style.display = "block";
}
// ========== COMPREHENSIVE ANALYSIS TAB ==========
const captureBtnComprehensive = document.getElementById("captureBtnComprehensive");
const loadingCamComprehensive = document.getElementById("loadingCamComprehensive");
const camResultComprehensive = document.getElementById("camResultComprehensive");
const fileInputComprehensive = document.getElementById("fileInputComprehensive");
const uploadAreaComprehensive = document.getElementById("uploadAreaComprehensive");
const uploadedImageComprehensive = document.getElementById("uploadedImageComprehensive");
const analyzeBtnComprehensive = document.getElementById("analyzeBtnComprehensive");
const resetBtnComprehensive = document.getElementById("resetBtnComprehensive");
const loadingUploadComprehensive = document.getElementById("loadingUploadComprehensive");
const uploadResultComprehensive = document.getElementById("uploadResultComprehensive");
captureBtnComprehensive.addEventListener("click", () => {
loadingCamComprehensive.style.display = "block";
camResultComprehensive.style.display = "none";
fetch("/comprehensive_analysis_capture", { method: "POST" })
.then(response => response.json())
.then(data => {
loadingCamComprehensive.style.display = "none";
showComprehensiveResult(data, camResultComprehensive);
})
.catch(err => {
loadingCamComprehensive.style.display = "none";
showComprehensiveError(err, camResultComprehensive);
});
});
fileInputComprehensive.addEventListener("change", handleComprehensiveFileSelect);
analyzeBtnComprehensive.addEventListener("click", analyzeComprehensiveImage);
resetBtnComprehensive.addEventListener("click", resetComprehensive);
function handleComprehensiveFileSelect() {
const file = fileInputComprehensive.files[0];
if (!file) return;
if (!file.type.match('image.*')) {
showComprehensiveError('Please select a valid image file', uploadResultComprehensive);
return;
}
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageComprehensive.src = e.target.result;
uploadedImageComprehensive.style.display = 'block';
uploadAreaComprehensive.style.display = 'none';
analyzeBtnComprehensive.disabled = false;
};
reader.readAsDataURL(file);
}
function analyzeComprehensiveImage() {
const file = fileInputComprehensive.files[0];
if (!file) return;
const formData = new FormData();
formData.append("file", file);
loadingUploadComprehensive.style.display = "block";
uploadResultComprehensive.style.display = "none";
fetch("/comprehensive_analysis", { method: "POST", body: formData })
.then(response => response.json())
.then(data => {
loadingUploadComprehensive.style.display = "none";
showComprehensiveResult(data, uploadResultComprehensive);
})
.catch(err => {
loadingUploadComprehensive.style.display = "none";
showComprehensiveError(err, uploadResultComprehensive);
});
}
function resetComprehensive() {
fileInputComprehensive.value = '';
uploadedImageComprehensive.style.display = 'none';
uploadAreaComprehensive.style.display = 'flex';
uploadResultComprehensive.style.display = 'none';
loadingUploadComprehensive.style.display = 'none';
analyzeBtnComprehensive.disabled = true;
}
function showComprehensiveResult(data, container) {
if (!data.error) {
container.className = "result result-info";
const ageGender = data.age_gender || {};
const printed = data.printed_detection || {};
const emotion = data.emotion || {};
const mask = data.face_mask || {};
container.innerHTML = `
<div class="result-header">
<i class="fas fa-brain result-icon"></i>
<h3 class="result-title">Comprehensive Analysis Complete</h3>
</div>
<p>All analyses completed successfully</p>
<div class="analysis-grid">
<!-- Age & Gender Section -->
<div class="analysis-section">
<div class="section-title">
<i class="fas fa-user"></i>
Age & Gender
</div>
${!ageGender.error ? `
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Age</div>
<div class="detail-value">${ageGender.age || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Gender</div>
<div class="detail-value">${ageGender.dominant_gender || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Gender Confidence</div>
<div class="detail-value">${ageGender.gender ? Math.round(ageGender.gender[ageGender.dominant_gender] * 100) : 0}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Deepfake Status</div>
<div class="detail-value" style="color: ${ageGender.dominant_spoof === 'Real' ? 'var(--success)' : 'var(--danger)'}">
${ageGender.dominant_spoof || 'N/A'}
</div>
</div>
</div>
` : `<p style="color: var(--danger);">${ageGender.error}</p>`}
</div>
<!-- Printed Detection Section -->
<div class="analysis-section">
<div class="section-title">
<i class="fas fa-print"></i>
Printed Detection
</div>
${!printed.error ? `
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Result</div>
<div class="detail-value" style="color: ${printed.dominant_printed === 'Real' ? 'var(--success)' : 'var(--danger)'}">
${printed.dominant_printed || 'N/A'}
</div>
</div>
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${printed.confidence ? (printed.confidence * 100).toFixed(1) : 0}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Real Probability</div>
<div class="detail-value">${printed.printed_analysis ? (printed.printed_analysis.Real * 100).toFixed(1) : 0}%</div>
</div>
</div>
` : `<p style="color: var(--danger);">${printed.error}</p>`}
</div>
<!-- Emotion Analysis Section -->
<div class="analysis-section">
<div class="section-title">
<i class="fas fa-smile"></i>
Emotion Analysis
</div>
${!emotion.error ? `
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Dominant Emotion</div>
<div class="detail-value">${emotion.dominant_emotion || 'N/A'}</div>
</div>
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${emotion.confidence ? (emotion.confidence * 100).toFixed(1) : 0}%</div>
</div>
<div class="result-detail">
<div class="detail-label">Emotions Detected</div>
<div class="detail-value">${emotion.emotions ? Object.keys(emotion.emotions).length : 0}</div>
</div>
</div>
` : `<p style="color: var(--danger);">${emotion.error}</p>`}
</div>
<!-- Mask Detection Section -->
<div class="analysis-section">
<div class="section-title">
<i class="fas fa-head-side-mask"></i>
Mask Detection
</div>
${!mask.error ? `
<div class="result-details">
<div class="result-detail">
<div class="detail-label">Mask Status</div>
<div class="detail-value" style="color: ${mask.has_mask ? 'var(--info)' : 'var(--warning)'}">
${mask.mask_status || 'N/A'}
</div>
</div>
<div class="result-detail">
<div class="detail-label">Confidence</div>
<div class="detail-value">${mask.confidence ? (mask.confidence * 100).toFixed(1) : 0}%</div>
</div>
<div class="result-detail">
<div class="detail-label">With Mask Probability</div>
<div class="detail-value">${mask.with_mask_prob ? (mask.with_mask_prob * 100).toFixed(1) : 0}%</div>
</div>
</div>
` : `<p style="color: var(--danger);">${mask.error}</p>`}
</div>
</div>
<div class="result-details" style="margin-top: 1rem;">
<div class="result-detail">
<div class="detail-label">Overall Status</div>
<div class="detail-value" style="color: var(--success);">Complete</div>
</div>
<div class="result-detail">
<div class="detail-label">Analysis Type</div>
<div class="detail-value">Comprehensive</div>
</div>
<div class="result-detail">
<div class="detail-label">Timestamp</div>
<div class="detail-value">${data.timestamp}</div>
</div>
</div>
`;
} else {
showComprehensiveError(data.error, container);
}
container.style.display = "block";
}
function showComprehensiveError(error, container) {
container.className = "result result-error";
container.innerHTML = `
<div class="result-header">
<i class="fas fa-exclamation-circle result-icon"></i>
<h3 class="result-title">Comprehensive Analysis Error</h3>
</div>
<p>${error.message || error.error || "An unexpected error occurred"}</p>
<p>Please try again or use a different image.</p>
`;
container.style.display = "block";
}
// Initialize animations
document.addEventListener("DOMContentLoaded", () => {
const cards = document.querySelectorAll(".card");
cards.forEach((card, index) => {
card.style.animationDelay = `${index * 0.1}s`;
});
});
app.py in your project directory.templates folder and save the web interface code as templates/deepface.html.static folder for storing uploaded images and assets (e.g. static/style.css).pip install flask flask-cors deepface-antispoofing tf-keras.python app.py.http://localhost:5000 in your browser to test live inference.The package requires the following Python libraries, automatically resolved and installed via pip:
tensorflow — Deep learning model execution and inference pipeline.opencv-python — Computer vision matrix calculations, face cropping, and camera capture.numpy — High-performance numerical computations.requests — Automated retrieval of deep neural network weights and Haar Cascade models.flask — Lightweight WSGI web framework for the interactive demo interface.pillow — Image manipulation and format compatibility layer.tf-keras — Backward compatibility layer for Keras model serialization.Reference solutions for common installation, execution, and model evaluation scenarios:
python --version and upgrade if necessary.
pip install tf-keras.
result['spoof']['Real']). If it is close to 0.5, calibrate the decision threshold in your application code (e.g., adjust is_real = spoof_prob > 0.5 to 0.3).
v1.1.3) on Python 3.11.2+ inside an isolated virtual environment (python -m venv venv).
For bug reports, feature suggestions, or custom AI/computer vision engineering integrations, reach out directly to the author and studio.